Repository navigation
fix(android): Hand the window back from a stacked activity (backport #25901) - #26659
Open
mergify[bot] wants to merge 5 commits into
Open
mergify[bot] wants to merge 5 commits into
mergify[bot] wants to merge 5 commits into
Conversation
glBlitFramebuffer is clipped by the scissor test, which Skia leaves enabled around the damage it last painted. After a partial repaint only that strip reached the default framebuffer, so a new surface showed black elsewhere. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 241ccaa)
Disposed programs and textures went through a process-wide queue drained by any GL thread. GL names are per EGL context, so another activity's context deleted its own objects that shared the numbers, and its blits went black. Each activity owns its render view, GL thread and context, so the queue is gone: a context deletes its objects only when its own EGL context is current, and otherwise leaves them to that context's destruction. The CPU buffer is always freed. A teardown that the GL thread never ran now runs once the view detaches, after GLSurfaceView has joined that thread. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 4eb2bb9)
GLSurfaceView can still call OnDrawFrame after the renderer is torn down. Disposing the peer bound that call to a fresh invoker calling back into Java, which recursed until the stack overflowed (any activity re-creation on GL). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 59b0bcc)
An intent delivered in the standard launch mode stacks a second instance of the activity, which takes the window over. When it finished, the window closed with it and left the original frozen. The original now takes the window back, only the driving activity presents it, and a render request lost across the hand-over is asked for again. Fixes #24862 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 88602a0)
A finishing activity that still owns the window now hands it to the most recently active copy still alive, instead of closing it, when that copy did not reclaim it first (one left stopped in another task). A copy that resumes also takes the window from one that is not resumed, as when the user switches back through Recents. Also sets IsSoftwareRenderer before posting the re-record, reuses the resolved host on a renderer swap, and waits for the stacked activity's destruction before asserting the window stayed open. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit ff26512)
2 of 5 tasks
Contributor
Author
|
Tick the box to add this pull request to the merge queue (same as
|
Contributor
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
Contributor
|
The build 248442 found UI Test snapshots differences: Details
|
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.
GitHub Issue: closes #24862
PR Type:
🐞 Bugfix
What changed? 🚀
On Skia Android, an intent delivered to a running app whose activity uses the default
standardlaunch mode (for example a protocol activation) stacks a second instance of the activity. That copy takes the window over. Since #24042 it renders, but finishing it (Back) closed the window with it and left the original activity frozen on a stale frame. The protocol activation docs ask forSingleTask, which avoids the stacking, but an app that doesn't set it should still work.This fixes the hand-back and the rendering problems that the stacked case exposed:
ApplicationActivity): when the activity coming back to the foreground (OnStart, orOnResumewhen the copy finished before it was even stopped) finds that the activity driving its window is finishing, it takes the window back (accessibility helper, native elements, a fresh frame) instead of letting the window close with the copy.UnoVulkanView,UnoCanvasView,UnoWebGpuView): every activity that has held the window renders the sameCompositionTarget, so a frame from a covered activity's view replayed the driving view's recordings into its own device and consumed the target's frame state.CompositionTarget, render views): a record attempted while the new activity's view had no renderer yet was dropped with nothing asking again, and after a renderer swap theRequestNewFramewas absorbed by a request still latched for the previous view. A view now asks for a fresh record once it has negotiated a renderer (the contract the WASM host already follows), and a renderer swap also asks the host for a native frame.AndroidSoftwareGraphicsContext): disposed programs and textures went through a process-wide queue that any GL thread drained. GL names are per EGL context, so when one activity's context was torn down, the other activity deleted its own objects that shared those numbers, and every later blit was black. The queue is gone, since each activity owns its own view, GL thread and context: a context deletes its objects only while its own EGL context is current, and otherwise leaves them to that context's destruction; the CPU buffer is always freed. A teardown that the GL thread never ran now runs once the view detaches, afterGLSurfaceViewhas joined that thread.GLRetainedFramebuffer, shared by the Android, Win32 and X11 GL hosts):glBlitFramebufferis clipped by the scissor test, which Skia leaves enabled around the damage it last painted. After a partial repaint only that strip reached the default framebuffer, so a new surface (the stacked activity, or the original after the hand-back) showed black apart from the damaged strip. The blit now disables the scissor test first.UnoCanvasView): the renderer teardown disposed the renderer's Java peer, butGLSurfaceViewcan still callOnDrawFrameuntil its thread exits; the call was bound to a fresh invoker that called back into Java and recursed until the stack overflowed. This reproduces on master with any activity re-creation on the GL renderer (e.g.Given_ApplicationActivity.When_Recreated_*). The peer is now left alive so the existing torn-down guard handles late frames.Validation
Given_ApplicationActivity.When_Stacked_Activity_Finishes_Then_Window_Returns_To_Original: stacks a test-onlyStackedWindowActivity(added to the SamplesApp Android head, default launch mode) over the running activity, finishes it, and checks the window is handed back without closing and still presents frames. Before theOnResumehand-back the window closed and the app exited.Given_ApplicationActivityon the API 34 emulator: Vulkan 6/6 passed; GL and software 5 passed + the Vulkan-only test inconclusive (on master, GL crashes the app inWhen_Recreated_Dispatcher_Stays_Responsive).Given_CompositionTarget+Given_Visual_Damage29 passed, 1 inconclusive (WebGPU-only), 1 skipped.SingleTaskremoved: cold launch →uno-samples-test://deep link → Back → open a page → second deep link → Back → exit, on the Vulkan, GL (adb shell setprop debug.uno.samples.renderer gl) and software renderers. Every step renders and responds on all three. Before: frozen stale frame after Back (all renderers), black stacked activity on GL, black page after navigation on software.Known limitation
Each activity's Vulkan view creates its own
VkInstance/VkDevice. On the emulator (SwiftShader through gfxstream), repeated stack/finish cycles sometimes freeze or crash the emulator host process, after Skia allocation failures (BindBufferMemory-1). Rendering is correct up to that point; this looks like an emulator limitation and was not reproducible on other renderers. Sharing one device across activities would avoid it and is left for a follow-up.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code
This is an automatic backport of pull request #25901 done by [Mergify](https://mergify.com).