Skip to content
This repository has been archived by the owner on Sep 3, 2023. It is now read-only.

Crash when saving state with Jetpack Navigation components #11

Open
ash2osh opened this issue Mar 24, 2019 · 7 comments
Open

Crash when saving state with Jetpack Navigation components #11

ash2osh opened this issue Mar 24, 2019 · 7 comments
Labels
bug Something that needs to be fixed. help wanted Need external help to figure out the problem.

Comments

@ash2osh
Copy link

ash2osh commented Mar 24, 2019

Library Version:

2.2.3

Affected Device(s):

XIAOMI note 3 android 7.1.2

Describe the Bug:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.foooo.baaar, PID: 29733
    java.lang.IllegalStateException: Failure saving state: active PermissionFragment{b24a4fa} has cleared index: -1
        at androidx.fragment.app.FragmentManagerImpl.saveAllState(FragmentManager.java:2960)
        at androidx.fragment.app.Fragment.performSaveInstanceState(Fragment.java:2628)
        at androidx.fragment.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:2910)
        at androidx.fragment.app.FragmentManagerImpl.saveAllState(FragmentManager.java:2971)
        at androidx.fragment.app.FragmentController.saveAllState(FragmentController.java:134)
        at androidx.fragment.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:591)
        at androidx.appcompat.app.AppCompatActivity.onSaveInstanceState(AppCompatActivity.java:510)
        at android.app.Activity.performSaveInstanceState(Activity.java:1415)
        at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1301)
        at android.app.ActivityThread.callCallActivityOnSaveInstanceState(ActivityThread.java:4597)
        at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3908)
        at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3971)
        at android.app.ActivityThread.-wrap25(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1541)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:153)
        at android.app.ActivityThread.main(ActivityThread.java:6244)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)

To Reproduce:

  1. using jetpack navigation launch fragment
  2. run runWithPermissions(Permission.WRITE_EXTERNAL_STORAGE) { doSomeStuff()}
  3. press home and save state with override fun onSaveInstanceState(outState: Bundle) { super.onSaveInstanceState(outState) // Save recycler view state outState.putParcelable("LIST_STATE_KEY", mLayoutManager?.onSaveInstanceState()) }
  4. crash

Expected Behavior:
when i press home without doing runWithPermissions(Permission.WRITE_EXTERNAL_STORAGE) { doSomeStuff()} it works fine otherwise it crashes

@afollestad
Copy link
Owner

Hmm, I'm unable to reproduce this on stock Android.

@ash2osh
Copy link
Author

ash2osh commented Mar 27, 2019

will try to do it on stock 7.1.2

@ash2osh
Copy link
Author

ash2osh commented Mar 31, 2019

ok same problem on emulator api 27
my project is at https://github.com/ash2osh/fetchTest

press the fab
grant permission
press home
CRASH

@afollestad
Copy link
Owner

afollestad commented Mar 31, 2019

The only error I see is totally unrelated to Assent:

Permission Denial: startForeground from pid=3408, uid=10102 requires android.permission.FOREGROUND_SERVICE

Still looking - but your sample does not support all Android versions.

@ash2osh
Copy link
Author

ash2osh commented Mar 31, 2019

please try it on api 27 not 28 i must have missed something

@afollestad
Copy link
Owner

Got it:

java.lang.IllegalStateException: Failure saving state: active PermissionFragment{6af4169} has cleared index: -1
        at androidx.fragment.app.FragmentManagerImpl.saveAllState(FragmentManager.java:2960)
        at androidx.fragment.app.Fragment.performSaveInstanceState(Fragment.java:2628)
        at androidx.fragment.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:2910)
        at androidx.fragment.app.FragmentManagerImpl.saveAllState(FragmentManager.java:2971)
        at androidx.fragment.app.FragmentController.saveAllState(FragmentController.java:134)
        at androidx.fragment.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:591)
        at androidx.appcompat.app.AppCompatActivity.onSaveInstanceState(AppCompatActivity.java:510)

Unfortunately right now, I have no idea what could cause this or how to fix it

@afollestad afollestad added bug Something that needs to be fixed. help wanted Need external help to figure out the problem. and removed cannot reproduce labels Mar 31, 2019
@szili9992
Copy link

Greetings.

I'm also having this exact problem. Basically I'm launching the camera app with an intent and right as I launch it I get the same exception. I'm guessing it might have something to do with the new Jetpack Navigation component. First time using it in and I didn't have this problem before. I know it's not much but hope it helped a little and you can resolve it. Your library is kickass .

 java.lang.IllegalStateException: Failure saving state: active PermissionFragment{c6fc9b8} has cleared index: -1
        at androidx.fragment.app.FragmentManagerImpl.saveAllState(FragmentManager.java:2960)
        at androidx.fragment.app.Fragment.performSaveInstanceState(Fragment.java:2628)
        at androidx.fragment.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:2910)
        at androidx.fragment.app.FragmentManagerImpl.saveAllState(FragmentManager.java:2971)
        at androidx.fragment.app.FragmentController.saveAllState(FragmentController.java:134)
        at androidx.fragment.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:591)
        at androidx.appcompat.app.AppCompatActivity.onSaveInstanceState(AppCompatActivity.java:510)
        at android.app.Activity.performSaveInstanceState(Activity.java:1549)
        at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1443)
        at android.app.ActivityThread.callActivityOnSaveInstanceState(ActivityThread.java:4809)
        at android.app.ActivityThread.callActivityOnStop(ActivityThread.java:4157)
        at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:4121)
        at android.app.ActivityThread.handleStopActivity(ActivityThread.java:4196)
        at android.app.servertransaction.StopActivityItem.execute(StopActivityItem.java:41)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

@afollestad afollestad changed the title crash when doing save state Crash when saving state with Jetpack Navigation components May 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something that needs to be fixed. help wanted Need external help to figure out the problem.
Projects
None yet
Development

No branches or pull requests

3 participants