Status Update
Comments
ki...@google.com <ki...@google.com>
jp...@gmail.com <jp...@gmail.com> #2
Branch: androidx-master-dev
commit 164bb50bcabe96a05e80c2d9ce03533e1dc6d26e
Author: Ian Lake <ilake@google.com>
Date: Mon Oct 14 11:03:23 2019
Fix FragmentContainerView inflation with obfuscation
Instead of using a literal for the class name, using
FragmentContainerView.class.getName() to support
obfuscation via ProGuard.
Test: ran testapp with obfuscation
Fixes: 142657034
Change-Id: I9ae40ddb5d3308790d6963f09f3eb110837dbb4c
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentLayoutInflaterFactory.java
al...@google.com <al...@google.com> #3
al...@google.com <al...@google.com> #4
We poked at this one a bit. There's a lot going on in ActivityCompat.recreate()
and we weren't able to reach a functional regression test during our GVC debug session. Though -- now that I think about it -- we didn't rule out interactions with AppCompatActivity
. Our test only extended Activity
, and it might have been passing because it worked fine.
al...@google.com <al...@google.com> #5
Poked at this a bit more. I removed the dependency on AppCompat, so this is purely a Compat and/or OS issue.
In the "failed" state, the activity has recreated and the new activity has the following properties:
mCreated = true
mResumed = false
mStopped = true
The activity has also called in to onResume
and onPostResume
despite not entering the resumed state. Calling hasWindowFocus()
reports true
.
al...@google.com <al...@google.com> #6
So, it looks like we at least have something to go on. We can't directly access those properties, though, and the activity otherwise looks like it's in the correct state, so I'm still not sure. From a mResumed
appear to be:
It's possible that we're somehow partially-executing a pause or stop after the activity resumes? It would have to be something in the ActivityCompat.recreate()
codepath doing it, though, since the platform recreate()
call is fine.
On the plus side, that means we don't have to debug platform code. Yet.
al...@google.com <al...@google.com> #7
aosp/1383907 finishes up the regression test that I was attempting to create yesterday, so you should be able to make adjustments to the ActivityCompat.recreate()
code with a little more certainty now. Basically we're relying on the fact that onPostResume()
gets called when the activity isn't technically in the resumed state -- it shows up as CREATED and never moves to RESUMED -- which indicates the failure.
al...@google.com <al...@google.com> #8
Interesting findings from today! We stepped through the LifecycleCheckCallbacks
in ActivityRecreator
using the debugger to verify the activity lifecycle and noticed that (1) the "old" activity is being destroyed before our test can catch it, so our test is still wrong and (2) the "new" activity is using the same mToken
as the old activity on API 21.
We didn't have time to verify what was happening on API 24, but the test behaved differently -- I think it was passing based on the lifecycle events, but the test was written incorrectly and failed.
al...@google.com <al...@google.com> #9
Tentative plan is to avoid using mToken
to check Activity
equality on SDK 21-23. Instead, we'll try using the hashCode()
.
al...@google.com <al...@google.com> #10
Note that mToken
is used to avoid holding a reference to the Activity
.
al...@google.com <al...@google.com> #11
Test doesn't work because launchActivity
actually returns the second activity if recreate()
is successful!
val firstActivity = activityTestRule.launchActivity(null)
// Wait for the old activity to be destroyed.
PollingCheck.waitFor(5000) {
firstActivity.isDestroyed
}
al...@google.com <al...@google.com> #12
Tried to fix the test, but the second activity never reaches RESUMED
. I think this means we've addressed the issue with API 21 and 22 such that they behave like API 23.
It looks like the activity runs all the way through to RESUMED
but then receives a call to onPaused
and -- according to the lifecycle manager -- remains in the STARTED
state. Forever.
al...@google.com <al...@google.com> #13
API <= 23 doesn't support calling recreate() outside of the STARTED
state, so we'll try posting on the Handler
to delay the work until we reach the right state. Since we can't observe the state directly, though, we're going to have to post it to the Handler
all the time.
ap...@google.com <ap...@google.com> #14
Branch: androidx-master-dev
commit 42808e39fb69f457e1d3d07237425c3df9416c26
Author: Alan Viverette <alanv@google.com>
Date: Wed Jul 29 16:05:48 2020
Ensure that ActivityCompat.recreate() works from onResume on SDK <= 23
Adds tests for onResume, onStart, and onStop that verify behavior across
all API levels.
Relnote: "Allow ActivityCompat.recreate() to be safely called from any
lifecycle state on any API level."
Bug: 160122826
Test: ActivityCompatRecreateFromLifecycleStatesTest
Change-Id: I62dde2d9041eb5b7ba2344380841aa03848d42e0
M core/core/src/androidTest/AndroidManifest.xml
A core/core/src/androidTest/java/androidx/core/app/ActivityCompatRecreateFromResumeTestCase.kt
A core/core/src/androidTest/java/androidx/core/app/ActivityCompatRecreateLifecycleTestActivity.kt
M core/core/src/main/java/androidx/core/app/ActivityCompat.java
M core/core/src/main/java/androidx/core/app/ActivityRecreator.java
ap...@google.com <ap...@google.com> #15
Branch: snap-temp-L43700000691908123
commit d99565ea445577278517dc13a6783b68f8fec238
Author: Alan Viverette <alanv@google.com>
Date: Wed Jul 29 16:05:48 2020
Ensure that ActivityCompat.recreate() works from onResume on SDK <= 23
Adds tests for onResume, onStart, and onStop that verify behavior across
all API levels.
Relnote: "Allow ActivityCompat.recreate() to be safely called from any
lifecycle state on any API level."
Bug: 160122826
Test: ActivityCompatRecreateFromLifecycleStatesTest
Change-Id: I62dde2d9041eb5b7ba2344380841aa03848d42e0
(cherry picked from commit 5dcfcd6b3593e8237ecb306053979433e75f9515)
M core/core/src/androidTest/AndroidManifest.xml
A core/core/src/androidTest/java/androidx/core/app/ActivityCompatRecreateFromResumeTestCase.kt
A core/core/src/androidTest/java/androidx/core/app/ActivityCompatRecreateLifecycleTestActivity.kt
M core/core/src/main/java/androidx/core/app/ActivityCompat.java
M core/core/src/main/java/androidx/core/app/ActivityRecreator.java
ap...@google.com <ap...@google.com> #16
Branch: snap-temp-L39700000691908325
commit facb88fa7f503056bbbd9284cdd58c22073f354a
Author: Alan Viverette <alanv@google.com>
Date: Wed Jul 29 16:05:48 2020
Ensure that ActivityCompat.recreate() works from onResume on SDK <= 23
Adds tests for onResume, onStart, and onStop that verify behavior across
all API levels.
Relnote: "Allow ActivityCompat.recreate() to be safely called from any
lifecycle state on any API level."
Bug: 160122826
Test: ActivityCompatRecreateFromLifecycleStatesTest
Change-Id: I62dde2d9041eb5b7ba2344380841aa03848d42e0
(cherry picked from commit 5dcfcd6b3593e8237ecb306053979433e75f9515)
M core/core/src/androidTest/AndroidManifest.xml
A core/core/src/androidTest/java/androidx/core/app/ActivityCompatRecreateFromResumeTestCase.kt
A core/core/src/androidTest/java/androidx/core/app/ActivityCompatRecreateLifecycleTestActivity.kt
M core/core/src/main/java/androidx/core/app/ActivityCompat.java
M core/core/src/main/java/androidx/core/app/ActivityRecreator.java
ap...@google.com <ap...@google.com> #17
Branch: snap-temp-L39600000691945594
commit 09508097fd54b56c93298563e880862ba8d8944d
Author: Alan Viverette <alanv@google.com>
Date: Wed Jul 29 16:05:48 2020
Ensure that ActivityCompat.recreate() works from onResume on SDK <= 23
Adds tests for onResume, onStart, and onStop that verify behavior across
all API levels.
Relnote: "Allow ActivityCompat.recreate() to be safely called from any
lifecycle state on any API level."
Bug: 160122826
Test: ActivityCompatRecreateFromLifecycleStatesTest
Change-Id: I62dde2d9041eb5b7ba2344380841aa03848d42e0
(cherry picked from commit 5dcfcd6b3593e8237ecb306053979433e75f9515)
M core/core/src/androidTest/AndroidManifest.xml
A core/core/src/androidTest/java/androidx/core/app/ActivityCompatRecreateFromResumeTestCase.kt
A core/core/src/androidTest/java/androidx/core/app/ActivityCompatRecreateLifecycleTestActivity.kt
M core/core/src/main/java/androidx/core/app/ActivityCompat.java
M core/core/src/main/java/androidx/core/app/ActivityRecreator.java
an...@google.com <an...@google.com> #18
The following changes were cherrypicked through
Release Track:
Changes: aosp/1426928
Description
On API 21, when
ActivityCompat.recreate()
is called fromActivity.onStart()
orActivity.onResume()
, the newly created activity becomes stuck on a black screen. However, callingActivity.recreate()
directly doesn't cause any issues.I've created a very simple sample project to reproduce the issue:https://github.com/jpmcosta/AndroidTestProject/tree/43793368a74f97fff17818ebb5455594910b3002
The first time you open the app it will try to recreate the activity using
ActivityCompat.recreate()
and it will show a black screen. You should go back and reopen the app.The second time you open the app (if the app's process is not killed) it will try to recreate the activity using
Activity.recreate()
directly and it will succeed in doing so.Component used: AppCompat
Version used: 1.3.0-alpha01
Devices/Android versions reproduced on: Emulator API 21