Repository navigation
Skip EmptyActivity launch in InstrumentationActivityInvoker on API 30+. - #2546
Merged
Merged
Conversation
copybara-service
Bot
force-pushed
the
piper_1028569570
branch
2 times, most recently
from
November 30, 2026 22:25
4f7df9b to
377520c
Compare
`InstrumentationActivityInvoker.finishActivity()` previously launched `EmptyActivity` synchronously before finishing the activity under test (and again when finishing a `BootstrapActivity`), which slows down `ActivityScenario` teardown and stalls when finishing activities on restricted or secondary displays. Skip the `EmptyActivity` launch on API 30+ (Android 11+) and finish the activity directly before broadcasting cleanup intents for `BootstrapActivity`, `ActivityResultWaiter`, and any existing empty facilitator activities. Retain the `EmptyActivity` workaround on API 29 and below. On API 29 and earlier, `ActivityStack.finishCurrentActivityLocked()` adds a `PAUSED` activity that is still visible behind another resumed activity (such as a dialog or translucent overlay) to `mFinishingActivities` and waits for an `activityIdle` callback that never arrives, preventing `onStop()` and `onDestroy()` from running. Android 11 (API 30) fixed this in `ActivityRecord.completeFinishing()` by checking whether `addToFinishingAndWaitForIdle()` scheduled a resume before deferring destruction. PiperOrigin-RevId: 1032973839
copybara-service
Bot
force-pushed
the
piper_1028569570
branch
from
November 30, 2026 22:39
377520c to
ea2ea81
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Skip EmptyActivity launch in InstrumentationActivityInvoker on API 30+.
InstrumentationActivityInvoker.finishActivity()previously launchedEmptyActivitysynchronously before finishing the activity under test (and again when finishing aBootstrapActivity), which slows downActivityScenarioteardown and stalls when finishing activities on restricted or secondary displays.Skip the
EmptyActivitylaunch on API 30+ (Android 11+) and finish the activity directly before broadcasting cleanup intents forBootstrapActivity,ActivityResultWaiter, and any existing empty facilitator activities.Retain the
EmptyActivityworkaround on API 29 and below. On API 29 and earlier,ActivityStack.finishCurrentActivityLocked()adds aPAUSEDactivity that is still visible behind another resumed activity (such as a dialog or translucent overlay) tomFinishingActivitiesand waits for anactivityIdlecallback that never arrives, preventingonStop()andonDestroy()from running. Android 11 (API 30) fixed this inActivityRecord.completeFinishing()by checking whetheraddToFinishingAndWaitForIdle()scheduled a resume before deferring destruction.