Repository navigation
fix(composition): Guarantee a frame for every render request, without a stall recovery (backport #25941) - #26271
Closed
mergify[bot] wants to merge 15 commits into
Closed
mergify[bot] wants to merge 15 commits into
mergify[bot] wants to merge 15 commits into
Conversation
A request made before the window's host registered, or latched for a renderer that was then replaced, was never answered. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 566270f)
The flip handler returned to idle with an unconditional write, discarding a request made in between, and a failed frame dropped one too. poll is also retried on EINTR. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit e006b45)
…ered A frame that could not be scheduled, or was skipped while the GPU caught up, left the request consumed or the latch stuck. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 77e1975)
The pacer now exists before the host registers, and events that another thread read into Xlib's queue are handled without waiting for the next socket event. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit e0c5aca)
The window can be asked for frames before graphics negotiation creates the thread, and those requests had nothing to signal. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 184a749)
The display pass consumes needsDisplay, so skipping the frame without re-arming lost the request. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 1047651)
Every host now answers a request with a frame, so re-asking after 2 s only re-requested renders still queued, which tripped NativeDispatcher's one-render-per-target assert (fixes #25303). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 8e7f7ee)
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 1e2deb0)
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 2c6f0db)
Win32 and X11 Vulkan drop the first frame after a resize, and UIKit Metal one with no drawable; each now asks its platform for another frame. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit e9d00fb)
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 73eb19f)
A request no longer draws inline: it wakes the page-flip thread through an eventfd when idle, so InvalidateRender never throws into its caller. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 3d8604e)
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit c3e279d)
An idle window gets no frames, so measuring from the last one reported a request that was milliseconds old as outstanding for seconds. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit c459608)
The frame dropped after a resize draws the old recording; the re-record it triggers already asks for the next frame, and re-asking early could present that old recording into the resized swapchain. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 6fe4f36)
Merged
1 of 5 tasks
Contributor
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
Contributor
|
The build 244996 did not find any UI Test snapshots differences. |
Contributor
Author
|
This pull request is closed, so it cannot be queued. Reopen it to get the box back. |
Member
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 #25303
PR Type:
🐞 Bugfix
What changed? 🚀
A Debug build on Skia Android (Vulkan) could abort at a slow cold start, on
Debug.Assert(details.renderAction is null)inNativeDispatcher.EnqueueRender(#25303).Cause.
CompositionTarget.IsRenderRequestStalledre-asked the host for a frame after 2 s without one, and re-armed the frame handshake. At a cold start the host had simply not produced a frame for a few seconds while the UI thread was busy, so the render queued by the previous frame was still pending. The next frame then queued a second render for the same target, which is what the assert rejects.The recovery dates from the Apple/Android lanes hanging on animations (
79d8c7820f). It turned out a host was not losing frames:CompositionTargetitself never asked for one after an ahead-of-time paint, whicheff8d1cb41fixed. The recovery stayed as a safety net.This PR removes it. Instead, every host now guarantees the contract it was covering: once
InvalidateRender()is called for a live window, the host eventually callsOnNativePlatformFrameRequested. With no recovery re-arming the handshake, "one queued render per target" is a real invariant again and the assert stays.I audited every host against that contract (Android, iOS/tvOS, macOS, Win32, X11, WebAssembly, Linux framebuffer DRM and software, Headless). The gaps it found are fixed in separate commits:
fix(composition)XamlRootMap.Registernow asks the new host for it (CompositionTarget.OnHostAttached). After a renderer swap, the request merged into one latched for the old renderer; the host is now asked directly. It goes through the sameAskHostForFrame(); #25901 takes this version when it rebases.fix(framebuffer)pollis retried onEINTRinstead of throwing on the page-flip thread. A flip completion that finds no flip in flight now throws (logged by the handler) instead of spinning.fix(framebuffer)InvalidateRender, so any caller (a property setter, layout,Register) could receive a rendering exception. Only the page-flip thread draws now: a request made while idle wakes it through aneventfdit polls alongside the card.fix(wasm)_pendingInvalidatewas cleared before the readiness checks and left set if the JS interop threw, either consuming a request without a frame or blocking all later ones. It is now cleared only when the frame is delivered.fix(x11)poll.fix(win32)_renderThread?.SignalNewFrame()while the thread was null. One frame is now signalled when the thread starts.fix(macos)fix(headless)fix(rendering)refactor(composition)IsRenderRequestStalled's re-ask and handshake re-arm.feat(composition)Apart from the UIKit dropped present above, the audit found no gap on Android or iOS/tvOS that this PR must close.
CurrentActivity, the finished activity, and that activity'sOnDestroycloses the window anyway. So this PR does not depend on fix(android): Hand the window back from a stacked activity #25901.Not in this PR (follow-up found by the same audit): an exception in a frame ends the render loop on X11, UIKit Metal and the Android GL canvas. That is a bug to fix on its own; the stall warning makes it visible.
Validation
Uno.UI,Uno.UI.Runtime.Win32,.X11,.MacOS,.Linux.FrameBufferand.WebAssembly.Browserbuild with analyzers on, with no warnings in the changed files.Given_CompositionTarget,Given_AnimatedVisualPlayer,Given_Storyboard,Given_DoubleAnimation,Given_RenderTargetBitmapandGiven_Window.Given_Windowtheme tests that fail the same way on master on this dark-themed machine.Given_CompositionTarget,Given_AnimatedVisualPlayerandGiven_Storyboard: 46 pass, 0 fail.Uno.UI,.Win32,.X11,.Linux.FrameBuffer); the UIKit change is left to CI.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code
This is an automatic backport of pull request #25941 done by [Mergify](https://mergify.com).