Fixed
Status Update
Comments
il...@google.com <il...@google.com> #2
This is not a Navigation issue, but an issue with Fragments, so I'm moving it to that component.
It seems to me that you are popping the Fragment off the back stack that contains the shared element View that you're trying to use. When a Fragment is popped off the back stack, its Views are detached and destroyed, so I'm curious on your use case where you're expecting those Views to still exist?
It seems to me that you are popping the Fragment off the back stack that contains the shared element View that you're trying to use. When a Fragment is popped off the back stack, its Views are detached and destroyed, so I'm curious on your use case where you're expecting those Views to still exist?
sa...@gmail.com <sa...@gmail.com> #3
My use case seems pretty common when you want to move forward in the stack with a shared element transition and doesn't want to go back to that screen but another screen previously added to the stack.
I understand the screen is detached since it's not added to the stack but then shouldn't that screen wait for transition to complete befofe being detached?
I understand the screen is detached since it's not added to the stack but then shouldn't that screen wait for transition to complete befofe being detached?
il...@google.com <il...@google.com> #4
Yep, it should work.
For future reference, this is the exception message I get running your sample (thanks, it was very helpful):
2018-12-07 11:10:56.152 19973-19973/com.example.samystudio.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.samystudio.myapplication, PID: 19973
java.lang.NullPointerException: Attempt to invoke interface method 'boolean java.util.Collection.contains(java.lang.Object)' on a null object reference
at androidx.collection.MapCollections.retainAllHelper(MapCollections.java:481)
at androidx.collection.ArrayMap.retainAll(ArrayMap.java:164)
at androidx.fragment.app.FragmentTransition.captureOutSharedElements(FragmentTransition.java:801)
at androidx.fragment.app.FragmentTransition.configureSharedElementsReordered(FragmentTransition.java:573)
at androidx.fragment.app.FragmentTransition.configureTransitionsReordered(FragmentTransition.java:233)
at androidx.fragment.app.FragmentTransition.startTransitions(FragmentTransition.java:133)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2424)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2372)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
at androidx.fragment.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
For future reference, this is the exception message I get running your sample (thanks, it was very helpful):
2018-12-07 11:10:56.152 19973-19973/com.example.samystudio.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.samystudio.myapplication, PID: 19973
java.lang.NullPointerException: Attempt to invoke interface method 'boolean java.util.Collection.contains(java.lang.Object)' on a null object reference
at androidx.collection.MapCollections.retainAllHelper(MapCollections.java:481)
at androidx.collection.ArrayMap.retainAll(ArrayMap.java:164)
at androidx.fragment.app.FragmentTransition.captureOutSharedElements(FragmentTransition.java:801)
at androidx.fragment.app.FragmentTransition.configureSharedElementsReordered(FragmentTransition.java:573)
at androidx.fragment.app.FragmentTransition.configureTransitionsReordered(FragmentTransition.java:233)
at androidx.fragment.app.FragmentTransition.startTransitions(FragmentTransition.java:133)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2424)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2372)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
at androidx.fragment.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
il...@google.com <il...@google.com>
em...@gmail.com <em...@gmail.com> #5
This is currently one of our highest crashes. Is there a short term solution we can try or can we expect an update soon?
[Deleted User] <[Deleted User]> #6
We had to remove our shared element transitions because of this crash with Navigation and popUpTo. Is there a better workaround?
ap...@google.com <ap...@google.com> #7
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 0cd3b081e65a5a15e2d1a9bf32399cb10c4d07ae
Author: jbwoods <jbwoods@google.com>
Date: Tue Jul 09 14:01:35 2019
Fix NPE when combining pop with add transaction
When adding a transaction with a shared transition after popping a
transaction without a shared transition, if reordering is allowed, a NPE
is thrown. This ensures that the reordered transactions will not break.
Test: Added Test
BUG: 120507394
Change-Id: Id37913b642cf4b4fe30ff52cfeed9f28be87f850
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransitionTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentTransition.java
https://android-review.googlesource.com/1013801
https://goto.google.com/android-sha1/0cd3b081e65a5a15e2d1a9bf32399cb10c4d07ae
Branch: androidx-master-dev
commit 0cd3b081e65a5a15e2d1a9bf32399cb10c4d07ae
Author: jbwoods <jbwoods@google.com>
Date: Tue Jul 09 14:01:35 2019
Fix NPE when combining pop with add transaction
When adding a transaction with a shared transition after popping a
transaction without a shared transition, if reordering is allowed, a NPE
is thrown. This ensures that the reordered transactions will not break.
Test: Added Test
BUG: 120507394
Change-Id: Id37913b642cf4b4fe30ff52cfeed9f28be87f850
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransitionTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentTransition.java
jb...@google.com <jb...@google.com> #8
This has been fixed internally and will be available in the Fragment 1.2.0-alpha02 release.
Description
Version used: 1.0.0-alpha07
Devices/Android versions reproduced on: emulator API 27
If you add shared element to a navigation action from a screen that won't be added to backstack then app crash, check sample attached to reproduce. From navigation_main.xml resource if you remove popUpTo="@+id/home" from screen1 action everything goes fine.