Fixed
Status Update
Comments
fo...@gmail.com <fo...@gmail.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 57ca221882695bd6a52549f4d9ea3b812e6fe87c
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Mon Mar 22 16:09:30 2021
[GH] [FragmentStrictMode] Detect <fragment> tag usage
## Proposed Changes
- Detect `<fragment>` tag usage inside XML layouts
## Testing
Test: See `FragmentStrictModeTest#detectFragmentTagUsage`
## Issues Fixed
Fixes: 153738235
This is an imported pull request fromhttps://github.com/androidx/androidx/pull/141 .
Resolves #141
Github-Pr-Head-Sha: 4ea052596e4341b9f11bcf335e2bc38045a91f19
GitOrigin-RevId: 62e7487aa4874eef6bb556490e193717cf937251
Change-Id: Iae48578e85e4e4897f806d7ade2e2a660adf9479
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentLayoutInflaterFactory.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
https://android-review.googlesource.com/1649748
Branch: androidx-main
commit 57ca221882695bd6a52549f4d9ea3b812e6fe87c
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Mon Mar 22 16:09:30 2021
[GH] [FragmentStrictMode] Detect <fragment> tag usage
## Proposed Changes
- Detect `<fragment>` tag usage inside XML layouts
## Testing
Test: See `FragmentStrictModeTest#detectFragmentTagUsage`
## Issues Fixed
Fixes: 153738235
This is an imported pull request from
Resolves #141
Github-Pr-Head-Sha: 4ea052596e4341b9f11bcf335e2bc38045a91f19
GitOrigin-RevId: 62e7487aa4874eef6bb556490e193717cf937251
Change-Id: Iae48578e85e4e4897f806d7ade2e2a660adf9479
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentLayoutInflaterFactory.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
jb...@google.com <jb...@google.com>
th...@outlook.com <th...@outlook.com> #3
This bug is also present in the 'Navigation drawer views activity' sample if enableOnBackInvokedCallback=true and Fragments 1.7.0 or higher, including 1.8.4, is used:
- Open any tab
- Perform but cancel the back gesture
- Open any other tab: Crash
FATAL EXCEPTION: main
Process: REDACTED, PID: 9480
java.lang.IllegalArgumentException: saveBackStack("a40660ad-28c0-40bd-9eb0-19015e5a56b8") must be self contained and not reference fragments from non-saved FragmentTransactions. Found reference to fragment HomeFragment{299df85} (589af71e-3fc9-44b7-bdd6-51627911ab31 id=0x7f0a01ba tag=ae6e1d49-648c-4252-9901-80d65f8f7737) in BackStackEntry{266e63e #5 a40660ad-28c0-40bd-9eb0-19015e5a56b8} that were previously added to the FragmentManager through a separate FragmentTransaction.
at androidx.fragment.app.FragmentManager.saveBackStackState(FragmentManager.java:2497)
at androidx.fragment.app.FragmentManager$SaveBackStackState.generateOps(FragmentManager.java:3833)
at androidx.fragment.app.FragmentManager.generateOpsForPendingActions(FragmentManager.java:2379)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:2046)
at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:703)
at android.os.Handler.handleCallback(Handler.java:959)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loopOnce(Looper.java:232)
at android.os.Looper.loop(Looper.java:317)
at android.app.ActivityThread.main(ActivityThread.java:8705)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
pa...@gmail.com <pa...@gmail.com> #4
Hello, do we have any news on the status of this?
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-main
Author: Ian Lake <
Link:
Prevent double expansion of transaction operations
Expand for full commit details
Prevent double expansion of transaction operations
How predictive back with fragments works is that
we pop the FragmentTransaction from the
FragmentManager, but keep a copy of that
transaction around in case the back operation
is cancelled (either via gesture or interruption
by changes to the FragmentManager).
In the cancellation case, we then re-apply the
same FragmentTransaction again, putting the
FragmentManager back into the state it was in
before the predictive back happened.
However, when using operations that are
'expanded' like setPrimaryNavigationFragment(),
we need to explicitly call collapseOps() before
re-executing the operation so that we ensure
that these transactions never have a direct
reference to fragments from other transactions.
By ensuring we only don't double expandOps(),
we can avoid cases where FragmentManager does not
allow references to previous fragments such as when
using saveBackStack().
Relnote: "Fixed an `IllegalStateException` triggered
by `saveBackStack` only after a Predictive Back gesture
was cancelled or interrupted."
Test: new PredictiveBackTest test cases
BUG: 342419080
Change-Id: I3387d9d02495112f211448d7f3c9f862299da697
Files:
- M
fragment/fragment/src/androidTest/java/androidx/fragment/app/PredictiveBackTest.kt
- M
fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
Hash: 922bb8acc3661be78480dd40f3c582af8b87f935
Date: Mon Oct 21 20:45:54 2024
il...@google.com <il...@google.com> #6
We've fixed this internally and will be available in Fragment 1.8.5.
Description
Component used: Fragment, Navigation
Version used: Fragment 1.7.0, Navigation 2.7.7
Devices/Android versions reproduced on: Poco F5, Android 14
Screen recording demonstrating the issue and sample project are attached. Predictive back gesture is enabled.
Steps to reproduce: Navigate to another tab. Perform the back gesture and cancel it. Navigate to another tab.
Exception: