Tasks not cleaned up after `ActivityScenario.launch`
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 28/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- android, kotlin
- Domain
- mobile, testing-qa
Research direction
Start with the ActivityScenario.launch and scenario.close calls shown in the issue, then reproduce on Android 13 and inspect the reported adb shell dumpsys activity recents output. Compare the MainActivity and InstrumentationActivityInvoker$EmptyActivity tasks to determine whether both should be removed when the scenario closes; done means the behavior is explained or cleanup is corrected and verified.
Written by the indexing model from the issue text.
Description
Description
I am trying for the first time to use ActivityScenario.launch in instrumented tests for a physical device. No matter what I do, I cannot get the tasks to be cleaned up.
Steps to Reproduce
- Using Samsung Galaxy. Close all apps first.
- Use code below
main
class MainActivity : ComponentActivity()
test
class LaunchAndroidInstrumentedTests {
@Test
fun activityStarts() {
val scenario = ActivityScenario.launch(MainActivity::class.java)
scenario.close()
}
}
Expected Results
When the test is done, there are no running apps.
Actual Results
When the test is done, my phone shows 2 running apps.
If I run adb shell dumpsys activity recents, I see this at the bottom of the output
Visible recent tasks (most recent first):
* RecentTaskInfo #0:
id=5745 userId=0 hasTask=false lastActiveTime=3723437970
baseIntent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=matt.launch.test/androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity }
realActivity={matt.launch.test/androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity}
isExcluded=false activityType=standard windowingMode=fullscreen supportsSplitScreenMultiWindow=true supportsMultiWindow=true
taskDescription { colorBackground=#ff303030 colorPrimary=#ff212121 iconRes=/0 iconBitmap=false resizeMode=RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION minWidth=-1 minHeight=-1 colorBackgroundFloating=#ff424242 }
lastSnapshotData { taskSize=Point(1080, 2316) contentInsets=Rect(0, 67 - 0, 126) bufferSize=Point(1080, 2316) }
* RecentTaskInfo #1:
id=5744 userId=0 hasTask=false lastActiveTime=3723437784
baseIntent=Intent { flg=0x10008000 cmp=matt.launch/.MainActivity }
realActivity={matt.launch/matt.launch.MainActivity}
isExcluded=false activityType=standard windowingMode=fullscreen supportsSplitScreenMultiWindow=true supportsMultiWindow=true
taskDescription { colorBackground=#fff0f0f3 colorPrimary=#ff191c1e iconRes=/0 iconBitmap=false resizeMode=RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION minWidth=-1 minHeight=-1 colorBackgroundFloating=#fff0f0f3 }
lastSnapshotData { taskSize=Point(1080, 2316) contentInsets=Rect(0, 67 - 0, 126) bufferSize=Point(1080, 2316) }
To summarize, the EmptyActivity and MainActivity were not properly cleaned up. On my phone, they actually show as two different apps in the recent app list. Both are blank white screens, but one of them says "matt.launch.MainActivity". The other one has no text.
AndroidX Test and Android OS Versions
androidx.test: 1.5.0
android OS: 13
Link to a public git repo demonstrating the problem:
I did not make one because I am hoping there is a quick solution or that it will be easy to reproduce with the code I copied and pasted above. If there is not quick solution and it is not simple to reproduce, I will be happy to make a repo. Please just let me know.
- Dominant language
- Java
- Stars
- 1.2k
- Forks
- 342
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from android/android-test
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
android/android-test#681 · 2 comments · 1 reaction ·
-
ξεκσνδξδ Open
Difficulty 5/5 Over a week Newbie friendliness 1/100
android/android-test#2499 ·
-
ησξξσ Open
Difficulty 5/5 Over a week Newbie friendliness 1/100
android/android-test#2498 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
android/android-test#2473 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
android/android-test#2461 · 6 comments · 4 reactions ·
All issues in android/android-test
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
area/frontend
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100