Fixed
Status Update
Comments
jb...@google.com <jb...@google.com>
ap...@google.com <ap...@google.com> #2
What version of Activity are you using? Upgrading your Activity dependency 1.7.2
which also depends on Lifecycle 2.6.1
should resolve this.
pr...@google.com <pr...@google.com> #3
Thanks. I stumbled upon https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:activity/activity/src/main/java/androidx/activity/ComponentDialog.kt;bpv=1;bpt=0
And see it was fixed in commit 602bac6c67b589d11f8f4d1441a4aec4dca0ee49.
Ill wait to upgrade until after that commit is in the stable release.
And see it was fixed in commit 602bac6c67b589d11f8f4d1441a4aec4dca0ee49.
Ill wait to upgrade until after that commit is in the stable release.
ty...@gmail.com <ty...@gmail.com> #4
It is stable in the releases I referenced above.
dr...@gmail.com <dr...@gmail.com>
lb...@gmail.com <lb...@gmail.com> #5
Fragment 1.6.1 will update the dependency of Activity to 1.7.2 so you'll get this improvement by default. As mentioned above, you can add a dependency on Activity 1.7.2 right now to fix the issue as a workaround until that release comes out.
Description
Version used: 1.7.0
Devices/Android versions reproduced on: API 33
If this is a bug in the library, we would appreciate if you could attach:
Example project attached
Description:
It appears that ComponentActivity$ReportFullyDrawnExecutorApi16Impl.this$0 leaks memory when used in an ActivityScenario if the ActivityScenario is used to recreate the Activity soon after the Activity has been launched.
Reproduction steps:
1. Create an Activity that extends ComponentActivity
2. Set a content view for the Activity in the onCreate using either setContentView(View) or setContent { <Composable> }
3. Create an instrumented test that uses LeakCanary's DetectLeaksAfterTestSuccess Test Rule
4. In the test: Launch the Activity using ActivityScenario, and then call "recreate" on the ActivityScenario
5a. Expected result: The test launches the Activity, recreates it, and the test passes.
5b. Actual result: The test launches the Activity, recreates it, and then LeakCanary detects a memory leak from ComponentActivity$ReportFullyDrawnExecutorApi16Impl.this$0 leaking an instance of the Activity.
This issue does not occur for ComponentActivity instance that do not set a content view in onCreate, and does not occur for regular android.app.Activity instances.
I have attached an example project with eight instrumented tests that show case this issue. In the ExampleInstrumentedTest.kt tests `launchExampleViewActivityAndRecreate` and `launchExampleComposeActivityAndRecreate` both fail, and all other tests succeed. The expected behaviour is that all tests should pass.