Fixed
Status Update
Comments
il...@google.com <il...@google.com> #2
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-master-dev
commit f80486e6c25c9b50ac9f3b088cc5c33368642cc8
Author: Ian Lake <ilake@google.com>
Date: Fri Apr 12 14:02:29 2019
Ensure retained Fragments can't desync from saved state
When the instance state of the FragmentManager is
already saved, operations can still affect the set
of retained Fragments, which still need to be in
sync when the FragmentManager is recreated in
restoreSaveState().
By avoiding updating the FragmentManagerViewModel,
we ensure that we have a consistent state when we
come back up.
Test: new FragmentLifecycleTest
Fixes: 130433793
Change-Id: I66076adf50816587ae564f46e119b150e0c30360
M fragment/src/androidTest/java/androidx/fragment/app/FragmentLifecycleTest.kt
M fragment/src/main/java/androidx/fragment/app/FragmentManagerImpl.java
https://android-review.googlesource.com/943631
https://goto.google.com/android-sha1/f80486e6c25c9b50ac9f3b088cc5c33368642cc8
Branch: androidx-master-dev
commit f80486e6c25c9b50ac9f3b088cc5c33368642cc8
Author: Ian Lake <ilake@google.com>
Date: Fri Apr 12 14:02:29 2019
Ensure retained Fragments can't desync from saved state
When the instance state of the FragmentManager is
already saved, operations can still affect the set
of retained Fragments, which still need to be in
sync when the FragmentManager is recreated in
restoreSaveState().
By avoiding updating the FragmentManagerViewModel,
we ensure that we have a consistent state when we
come back up.
Test: new FragmentLifecycleTest
Fixes: 130433793
Change-Id: I66076adf50816587ae564f46e119b150e0c30360
M fragment/src/androidTest/java/androidx/fragment/app/FragmentLifecycleTest.kt
M fragment/src/main/java/androidx/fragment/app/FragmentManagerImpl.java
Description
Version used: 1.1.0-alpha06
When adding a retained Fragment when a FragmentManager that has its state saved, the set of retained Fragments is still updated. This can lead to inconsistencies when restoreSaveState is called since it was unaware of the newly retained Fragment.
Stacktrace:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.lithium.leona.openstud, PID: 19140
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lithium.leona.openstud/com.lithium.leona.openstud.activities.LauncherActivity}: java.lang.IllegalStateException: Could not find active fragment with unique id d3d7d2aa-4ea1-4a2b-833c-6404dcddf62a
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2955)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4919)
at android.app.ActivityThread.-wrap19(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1702)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: java.lang.IllegalStateException: Could not find active fragment with unique id d3d7d2aa-4ea1-4a2b-833c-6404dcddf62a
at androidx.fragment.app.FragmentManagerImpl.restoreSaveState(FragmentManagerImpl.java:2434)
at androidx.fragment.app.FragmentController.restoreSaveState(FragmentController.java:194)
at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:279)
at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:85)
at com.lithium.leona.openstud.activities.LauncherActivity.onCreate(LauncherActivity.java:21)
at android.app.Activity.performCreate(Activity.java:7183)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2908)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4919)
at android.app.ActivityThread.-wrap19(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1702)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)