Fixed
Status Update
Comments
ma...@cyberagent.co.jp <ma...@cyberagent.co.jp> #3
After update to Fragments 1.2.0-alpha01, it seems the same exception still happens (Also tried update appcompat:1.1.0-rc01)
The latest example project was attached
The latest example project was attached
lc...@gmail.com <lc...@gmail.com> #4
Sorry, <ma...@cyberagent.co.jp> is also my mail.
il...@google.com <il...@google.com> #5
Thanks for confirming, I was able to reproduce your issue.
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #6
Project: platform/frameworks/support
Branch: androidx-master-dev
commit e6ce39f90140f19068852a99713e19680ff20559
Author: Ian Lake <ilake@google.com>
Date: Wed Jul 24 14:30:55 2019
Remove cancelled postponed transactions when popped
When popping a postponed fragment transaction,
remove the transaction from the list of postponed
transactions when cancelling it.
This prevents cases where we attempt to execute
the postponed transaction despite it already
being cancelled.
Test: new test passes
BUG: 138251858
Change-Id: Ie2f23923ad761a35c43df8716e46e51183dbc010
M fragment/fragment/src/androidTest/java/androidx/fragment/app/PrimaryNavFragmentTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
https://android-review.googlesource.com/1090762
https://goto.google.com/android-sha1/e6ce39f90140f19068852a99713e19680ff20559
Branch: androidx-master-dev
commit e6ce39f90140f19068852a99713e19680ff20559
Author: Ian Lake <ilake@google.com>
Date: Wed Jul 24 14:30:55 2019
Remove cancelled postponed transactions when popped
When popping a postponed fragment transaction,
remove the transaction from the list of postponed
transactions when cancelling it.
This prevents cases where we attempt to execute
the postponed transaction despite it already
being cancelled.
Test: new test passes
BUG: 138251858
Change-Id: Ie2f23923ad761a35c43df8716e46e51183dbc010
M fragment/fragment/src/androidTest/java/androidx/fragment/app/PrimaryNavFragmentTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
an...@google.com <an...@google.com> #7
il...@google.com <il...@google.com> #8
Turns out that this was actually a more serious, long standing issue with Fragments that was just exposed by more recent changes.
We'll be releasing a new 1.1.0-rc04 for Fragments with this fix and update Navigation 2.1 to depend on it.
We'll be releasing a new 1.1.0-rc04 for Fragments with this fix and update Navigation 2.1 to depend on it.
Description
Version used: 2.1.0-beta02
Devices/Android versions reproduced on:
When using sharedElementTransition from Fragment A to Fragment B, we call Fragment#postponeEnterTransition first at Fragment B onCreateView.
Then if we press back button or navigate to other fragment before Fragment#startPostponedEnterTransition of Fragment B was called, the following exception will happen when trying to navigate to other fragments.
StackTrace:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.fragmenttransitionbug, PID: 8900
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean androidx.fragment.app.FragmentManagerImpl.isPrimaryNavigation(androidx.fragment.app.Fragment)' on a null object reference
at androidx.fragment.app.Fragment.performPrimaryNavigationFragmentChanged(Fragment.java:2662)
at androidx.fragment.app.FragmentManagerImpl.dispatchParentPrimaryNavigationFragmentChanged(FragmentManagerImpl.java:2805)
at androidx.fragment.app.FragmentManagerImpl.setPrimaryNavigationFragment(FragmentManagerImpl.java:2800)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:422)
at androidx.fragment.app.FragmentManagerImpl.completeExecute(FragmentManagerImpl.java:1989)
at androidx.fragment.app.FragmentManagerImpl$StartEnterTransitionListener.completeTransaction(FragmentManagerImpl.java:3379)
at androidx.fragment.app.FragmentManagerImpl.executePostponedTransaction(FragmentManagerImpl.java:1769)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1800)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
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)
Is this the correct behavior?
Since it's a common pattern when using Glide to load a remote image with sharedElementTransition.
We want to call Fragment#startPostponedEnterTransition after the remote image was ready to show.
But the loading can take some time which cause the above situation to happen.
A sample project was attached.
If this is a bug in the library, we would appreciate if you could attach:
- Sample project to trigger the issue.
- A screenrecord or screenshots showing the issue (if UI related).