Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24265] Android: Application can't recover from storage permission change

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2017-04-11T18:51:01.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.0.4
ComponentsAndroid
Labelsandroid, android-n, permissions
ReporterReymundo López
AssigneeGary Mathews
Created2016-12-21T13:38:48.000+0000
Updated2017-07-26T11:48:49.000+0000

Description

When changing the storage permissions to off (after the user already approved in the app), if the app is in background, it can't recover when the user select the app in the overview, it just crash. I added a small example with only the permissions part Steps: * Build and install app in Android N * Click in the label * Accept storage permission * Send app to background * Open Settings * Click Apps > Example App > Permissions * Remove storage permission * Try to go back to the example app, it will crash or get stuck in the splash screen * Only way to recover from this is forcing the app to close and re-open it Log for reference:
                            Process com.moovel.storagepermissions.example created for activity com.moovel.storagepermissions.example/.StoragepermissionsActivity
                            PID: 4421   UID:    GIDs:

          TiApplication  I  (main) [0,0] checkpoint, app created.
                         I  (main) [24,24] Titanium 5.5.1 (2016/09/27 05:39 b18727f)
               V8Object  W  (main) [131,155] Runtime disposed, cannot set property 'userAgent'
          TiApplication  I  (main) [12,167] Titanium Javascript runtime: v8
         TiRootActivity  I  (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
                 Module  D  Loading module: alloy -> Resources/alloy.js
                         D  Loading module: alloy/underscore -> Resources/alloy/underscore.js
                         D  Loading module: alloy/backbone -> Resources/alloy/backbone.js
                         D  Loading module: alloy/constants -> Resources/alloy/constants.js
                         D  Loading module: alloy/CFG -> Resources/alloy/CFG.js
                    art  I  Background sticky concurrent mark sweep GC freed 19063(1306KB) AllocSpace objects, 13(480KB) LOS objects, 0% free, 15MB/15MB, paused 610us total 100.631ms
                 Module  D  Loading module: alloy/controllers/index -> Resources/alloy/controllers/index.js
                         D  Loading module: alloy/controllers/BaseController -> Resources/alloy/controllers/BaseController.js
                         D  Loading module: permissions -> Resources/permissions.js
         TiRootActivity  I  (main) [0,0] checkpoint, on root activity resume. activity = com.moovel.storagepermissions.example.StoragepermissionsActivity@309f52e
                    art  I  Background partial concurrent mark sweep GC freed 4555(336KB) AllocSpace objects, 13(360KB) LOS objects, 20% free, 15MB/19MB, paused 7.148ms total 97.169ms
                         D  HostConnection::get() New Host Connection established 0xdc579e80, tid 4444
                         W  Process pipe failed
         OpenGLRenderer  I  Initialized EGL, version 1.4
                         D  Swap behavior 1
          EGL_emulation  E  tid 4444: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)
         OpenGLRenderer  W  Failed to set EGL_SWAP_BEHAVIOR on surface 0xe734f360, error=EGL_BAD_MATCH
                 Window  D  Checkpoint: postWindowCreated()
          EGL_emulation  E  tid 4444: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)
         OpenGLRenderer  W  Failed to set EGL_SWAP_BEHAVIOR on surface 0xe7350780, error=EGL_BAD_MATCH
                  TiAPI  I   [androidPermissions] - verifyStoragePermissions
      AppCompatDelegate  I  The Activity's LayoutInflater already has a Factory installed so we can not install AppCompat's
          EGL_emulation  E  tid 4444: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)
         OpenGLRenderer  W  Failed to set EGL_SWAP_BEHAVIOR on surface 0xe73506e0, error=EGL_BAD_MATCH
                         D  endAllActiveAnimators on 0xcb05cc80 (RippleDrawable) with handle 0xc9b1b200

                            Process com.moovel.storagepermissions.example (PID: 4421) ended


                            Process com.moovel.storagepermissions.example created for activity com.moovel.storagepermissions.example/org.appcelerator.titanium.TiActivity
                            PID: 4498   UID:    GIDs:

                    art  W  Unexpected CPU variant for X86 using defaults: x86
          TiApplication  I  (main) [0,0] checkpoint, app created.
                         I  (main) [18,18] Titanium 5.5.1 (2016/09/27 05:39 b18727f)
               V8Object  W  (main) [68,86] Runtime disposed, cannot set property 'userAgent'
          TiApplication  I  (main) [13,99] Titanium Javascript runtime: v8
         TiBaseActivity  W  (main) [18,117] Runtime has been disposed or app has been killed. Finishing.
          TiApplication  W  (main) [8,125] Scheduling application restart
         AndroidRuntime  D  Shutting down VM
          TiApplication  E  (main) [2385,2510] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to destroy activity {com.moovel.storagepermissions.example/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException: Attempt to invoke vir
                            tual method 'void android.view.OrientationEventListener.disable()' on a null object reference; Titanium 5.5.1,2016/09/27 05:39,b18727f
                         E  java.lang.RuntimeException: Unable to destroy activity {com.moovel.storagepermissions.example/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.OrientationEventListener.disable(
                            )' on a null object reference
                         E      at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4203)
                         E      at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4221)
                         E      at android.app.ActivityThread.-wrap6(ActivityThread.java)
                         E      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1538)
                         E      at android.os.Handler.dispatchMessage(Handler.java:102)
                         E      at android.os.Looper.loop(Looper.java:154)
                         E      at android.app.ActivityThread.main(ActivityThread.java:6119)
                         E      at java.lang.reflect.Method.invoke(Native Method)
                         E      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                         E      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                         E  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.OrientationEventListener.disable()' on a null object reference
                         E      at org.appcelerator.titanium.TiBaseActivity.onDestroy(TiBaseActivity.java:1523)
                         E      at org.appcelerator.titanium.TiActivity.onDestroy(TiActivity.java:29)
                         E      at android.app.Activity.performDestroy(Activity.java:6881)
                         E      at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1153)
                         E      at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4190)
                         E      ... 9 more
                    art  I  Starting a blocking GC HeapTrim
                         I  Starting a blocking GC HomogeneousSpaceCompact

                            Process com.moovel.storagepermissions.example (PID: 4498) ended

Attachments

FileDateSize
StoragePermissions.zip2016-12-21T13:31:33.000+00002202527

Comments

  1. Sharif AbuDarda 2016-12-21

    Hello, I have tested your issue in Android 6.0.1 device. I wasn't able to regenerate the issue exactly you described. After Removing storage permission, I try opening the app which is already in background, I see the app opens from the start with splash screen. But it never crashes or any crash log generated in the console. Thanks.
  2. Reymundo López 2016-12-21

    Yes, it works as expected in an Android 6 Device, the problem we are seeing is with Android 7.
  3. Gary Mathews 2017-02-20

    master: https://github.com/appcelerator/titanium_mobile/pull/8843
  4. Michael Gangolf 2017-02-20

  5. Gary Mathews 2017-02-20

    [~michael] Yes, I didn't want to cause any potential regressions on < 23
  6. Gary Mathews 2017-04-05

    6_0_X: https://github.com/appcelerator/titanium_mobile/pull/8926
  7. Lokesh Choudhary 2017-04-11

    Merged above PR waiting for CI build to close.
  8. Lokesh Choudhary 2017-04-21

    Verified the fix in 6.0.4.v20170420100617. Closing.

JSON Source