Fixed
Status Update
Comments
il...@google.com <il...@google.com>
il...@google.com <il...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 82941c128d8ef57e36a739fcfacdf006e94d1a4a
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Thu Oct 15 17:31:58 2020
[GH] Don't cache fragment classes across different class loaders
## Proposed Changes
- Don't cache fragment classes across different class loaders inside `FragmentFactory`.
## Testing
Test: Added tests to verify the change
## Issues Fixed
Fixes: 113886460
This is an imported pull request fromhttps://github.com/androidx/androidx/pull/87 .
Resolves #87
Github-Pr-Head-Sha: e5f5916840904cab91884e3f525fde4a71d5a7dc
GitOrigin-RevId: babb5e1aedec7d815aa38a50ebca89d6c3e93f00
Change-Id: I07d5541a45ccadcf7159854818000455e245d118
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentFactory.java
A fragment/fragment/src/test/java/androidx/fragment/app/FragmentFactoryTest.kt
https://android-review.googlesource.com/1462523
Branch: androidx-master-dev
commit 82941c128d8ef57e36a739fcfacdf006e94d1a4a
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Thu Oct 15 17:31:58 2020
[GH] Don't cache fragment classes across different class loaders
## Proposed Changes
- Don't cache fragment classes across different class loaders inside `FragmentFactory`.
## Testing
Test: Added tests to verify the change
## Issues Fixed
Fixes: 113886460
This is an imported pull request from
Resolves #87
Github-Pr-Head-Sha: e5f5916840904cab91884e3f525fde4a71d5a7dc
GitOrigin-RevId: babb5e1aedec7d815aa38a50ebca89d6c3e93f00
Change-Id: I07d5541a45ccadcf7159854818000455e245d118
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentFactory.java
A fragment/fragment/src/test/java/androidx/fragment/app/FragmentFactoryTest.kt
Description
Version used: alpha 0.0.5
Devices/Android versions reproduced on: Android 8.1 Oneplus 3T, Android 6.0 Moto G Turbo edition
I made a sample project which consists of a main activity and 2 fragments, FragmentA and FragmentB
Fragment A has a button to fragment B
Fragment B simply states that you are on fragment B
The main activity listens for and logs which page you are on when you navigate
The main activity has 4 buttons
1 - Pop - Calls navigation controllers popBackStack() method
1 - Pop to root - Calls navigation controllers popBackStack() method with fragment A as a destination and inclusive set to false, so you get back to the top of the stack
3 - Up - calls navigation controllers navigateUp method
4 - Check page, gives a toast with the current destinations label
The bugs:
1) If you press pop when on the home screen, you end up still on the home screen but the navigation controller seems to forget where it is. The current destination becomes null but im still on page a. I can still go to page b too. But once on page b, all further navigation fails. Not sure if this is a bug or intentional
2) To get around this i used pop to root instead. This one works fine most the time but if you hit the button for going to fragment b and simultaneously hit the pop to root button, sometimes, if you time it right, it breaks the backstack. The current destination button tells me I'm on A, the backstack size (checked via debugger) also suggests I'm on A, and therefore pop and pop to root both stop working (since it thinks I'm already at the top). Yet I see B on my screen. Checking the navigation listener, it thinks im on A too (that's the last thing logged). I'm assuming some sort of race condition or something is causing this.
When the backstack is broken in either of these 2 ways, i can still use the up button, but it causes the activity to recreate (judging by the code, i think it thinks I'm deep linked into fragment B)
Also when it is broken via
The sample project is attached.