Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 9083f9204e16dccf0358a1d776ece90b99be959b
Author: Jeremy Woods <jbwoods@google.com>
Date: Tue Mar 14 20:11:42 2023
Adjust the timing of OnBackStackChangeCommitted
As currently implemented, onBackStackChangeCommit passes detached
fragments into the callback. Having a fragment with a cleared state is
not very useful.
The more correct timing for this callback would be after the transaction
has been committed but prior to the operations being executed.
RelNote: "The timing of the
`OnBackStackChangedListener.onBackStackChangeCommited` callback has been
adjusted to execute before fragment operations are executed. This
ensures that the callback will never be passed a fragment that is
detached."
Test: Adjusted OnBackStackChagnedListenerTest
Bug: 273568280
Change-Id: I66a76810202a9b44b9d4bdffa03be5ed2b28a1e3
M fragment/fragment/src/androidTest/java/androidx/fragment/app/OnBackStackChangedListenerTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
https://android-review.googlesource.com/2486363
Branch: androidx-main
commit 9083f9204e16dccf0358a1d776ece90b99be959b
Author: Jeremy Woods <jbwoods@google.com>
Date: Tue Mar 14 20:11:42 2023
Adjust the timing of OnBackStackChangeCommitted
As currently implemented, onBackStackChangeCommit passes detached
fragments into the callback. Having a fragment with a cleared state is
not very useful.
The more correct timing for this callback would be after the transaction
has been committed but prior to the operations being executed.
RelNote: "The timing of the
`OnBackStackChangedListener.onBackStackChangeCommited` callback has been
adjusted to execute before fragment operations are executed. This
ensures that the callback will never be passed a fragment that is
detached."
Test: Adjusted OnBackStackChagnedListenerTest
Bug: 273568280
Change-Id: I66a76810202a9b44b9d4bdffa03be5ed2b28a1e3
M fragment/fragment/src/androidTest/java/androidx/fragment/app/OnBackStackChangedListenerTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
jb...@google.com <jb...@google.com> #3
This has been fixed internally and will be available in the Fragment 1.6.0-alpha08
release.
pr...@google.com <pr...@google.com> #4
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.fragment:fragment:1.6.0-alpha08
Description
The current timing of `onBackStackChangeCommitted` means that it received fragments that have been detached from the `FragmentManager` and had all of the state deleted, which is not very useful in the callback.
It seems that the timing of `onBackStackChangeStarted` is the correct timing for both callback as currently implemented. We should adjust `onBackStackChangeCommitted` to reflect that. In the future, as fragment integrates with predictive back APIs, we anticipate that the timing of `onBackStackChangeStarted` may change.