Fixed
Status Update
Comments
ix...@gmail.com <ix...@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
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit b57c42bc3a96fea02e15a732d1b7c22383eb010e
Author: Jeremy Woods <jbwoods@google.com>
Date: Thu Jan 14 14:11:48 2021
Ignore special effects for views not attachedToWindow
When adding fragments to the activity before the View hierarchy has been
attached to the window, if the fragment has special effects, they will
never be started. In the case of Transitions, this means there is never
an onEndTransition() callback, which causes fragment to be unable to
move to resumed.
Since unattached views will not run their transitions anyway, we should
drop any special effect operations before the special effects container
is attached to the window.
RelNote: "Fragments with transitions added before the view hierarchy is
attached now properly reach resumed."
Test: FragmentTransitionTest
Bug: 177154873
Change-Id: I1fc1db01450466f9ee012f07e4b608aa3337c838
M fragment/fragment/src/androidTest/AndroidManifest.xml
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransitionTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/SpecialEffectsController.java
M transition/transition/src/androidTest/AndroidManifest.xml
M transition/transition/src/androidTest/java/androidx/transition/FragmentTransitionTest.kt
https://android-review.googlesource.com/1551476
Branch: androidx-main
commit b57c42bc3a96fea02e15a732d1b7c22383eb010e
Author: Jeremy Woods <jbwoods@google.com>
Date: Thu Jan 14 14:11:48 2021
Ignore special effects for views not attachedToWindow
When adding fragments to the activity before the View hierarchy has been
attached to the window, if the fragment has special effects, they will
never be started. In the case of Transitions, this means there is never
an onEndTransition() callback, which causes fragment to be unable to
move to resumed.
Since unattached views will not run their transitions anyway, we should
drop any special effect operations before the special effects container
is attached to the window.
RelNote: "Fragments with transitions added before the view hierarchy is
attached now properly reach resumed."
Test: FragmentTransitionTest
Bug: 177154873
Change-Id: I1fc1db01450466f9ee012f07e4b608aa3337c838
M fragment/fragment/src/androidTest/AndroidManifest.xml
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransitionTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/SpecialEffectsController.java
M transition/transition/src/androidTest/AndroidManifest.xml
M transition/transition/src/androidTest/java/androidx/transition/FragmentTransitionTest.kt
jb...@google.com <jb...@google.com> #4
This has been fixed internally and will be available in the Fragment 1.3.0-rc02
release.
Description
Component used: Fragment
Version used: 1.3.0-rc01
Devices/Android versions reproduced on: Samsuns S10e/Android 10, Google Pixel 4XL/Android 11
Reproducing: Attached a sample app, look at
MainActivity
/MainActivityViewModel
/FirstFragment
.Description of the issue:
I have stumbled upon a Fragment lifecycle issue where under certain conditions the
Fragment#onResume()
method does not get called. Conditions of reproducing:ChangeBounds
in my example),Activity#onCreate()
as a result of aLiveData
emission.It feels like some race condition, but is surprisingly stable at reproducing (pretty much at 100%, I only failed to reproduce it once on a fresh install) at different devices.
In the logs:
Any of the following actions fix the issue:
StateFlow
instead ofLiveData
in Activity (for initiating a Fragment transaction),Once one of these workarounds has been applied, logs are like this:
or