Repository navigation
fix(android): Hand the window back from a stacked activity - #25901
ramezgerges merged 5 commits into
Conversation
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 242671 found UI Test snapshots differences: Details
|
|
|
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
5dea343 to
d0f16ca
Compare
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 242862 found UI Test snapshots differences: Details
|
d0f16ca to
cef80dc
Compare
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
cef80dc to
e7ad6fd
Compare
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
Xiaoy312
left a comment
There was a problem hiding this comment.
LGTM. The scissor, GL-peer and software-context fixes look right and are well explained. A few non-blocking notes inline.
One more nit outside the diff: the comment on LaunchMode = SingleTask in src/SamplesApp/SamplesApp/Platforms/Android/MainActivity.Android.cs still says the window "moves to it and closes with it". With this PR it no longer closes, so SingleTask is now about routing the intent through OnNewIntent.
|
The build 243326 found UI Test snapshots differences: Details
|
|
@Mergifyio backport release/stable/7.0 |
✅ Backports have been createdDetails
|
e7ad6fd to
f7cd365
Compare
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 243719 found UI Test snapshots differences: Details
|
2a55e4c to
b98c7f5
Compare
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 244089 found UI Test snapshots differences: Details
|
b98c7f5 to
320ae3b
Compare
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 244372 found UI Test snapshots differences: Details
|
320ae3b to
41828a3
Compare
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 244913 found UI Test snapshots differences: Details
|
|
This pull request is merged. |
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]>
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]>
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]>
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 unoplatform#24862 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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]>
41828a3 to
ff26512
Compare
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 245443 found UI Test snapshots differences: Details
|
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. |
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 246903 found UI Test snapshots differences: Details
|
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