Repository navigation
fix(hosting): Ignore frame requests after FramePacer disposal - #25196
MartinZikmund wants to merge 2 commits into
Conversation
A host event thread could request a frame while the window closed on another thread, hitting the disposed timer (ObjectDisposedException on X11 Expose). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01L4YBGyfjv1uKVn6FUFxSEF
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01L4YBGyfjv1uKVn6FUFxSEF
|
Claude finished @MartinZikmund's task in 21s —— View job Review summaryVerdict: ship (2 nits, 0 blocking)
Assessment: This is a root-cause fix, not just a guard. Cross-cutting notes
|
| _targetIntervalTicks = FpsToTicks(fps); | ||
| _timer = new Timer { AutoReset = false, Interval = TargetIntervalMs }; | ||
| _timer.Elapsed += (_, _) => onTimerElapsed(); | ||
| _timer.Elapsed += (_, _) => |
There was a problem hiding this comment.
Nit (defensive, not a regression): the _disposed check here is check-then-act and is not under _gate, so a tick already dequeued from the thread pool can still invoke onTimerElapsed() just after Dispose() returns. That's fine if the callback tolerates a closing host, but the PR description says a "pending tick after disposal is a no-op", which is only best-effort. Consider softening the wording or the comment, and confirm the callbacks in the hosts (X11 etc.) handle a late invocation.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-25196/wasm-skia-net9/index.html |
|
The build 238845 found UI Test snapshots differences: Details
|
|
|
morning4coffe-dev
left a comment
There was a problem hiding this comment.
Verified: the diff, the full FramePacer.cs at head, the new _gate/_disposed serialization, the X11 close path (X11XamlRootHost.cs:147-148), and the three FramePacer call sites (X11, macOS, Win32). Code review only; I did not build or run the unit tests.
Findings:
-
X11 can still hit the crash class this PR fixes, in the window it leaves open. The
Elapsedhandler checks_disposed(FramePacer.cs:36-41) and then callsonTimerElapsed()outside_gate. If the timer thread passes the check, and the close path then runsDispose()and_renderRequested.Dispose()(X11XamlRootHost.cs:147-148), the callback_renderRequested.Set()(X11XamlRootHost.Rendering.cs:19) throwsObjectDisposedExceptionon a threadpool thread.System.Timers.Timerdoes not catch that, so the process goes down. The macOSSignalFrameDuealready guards exactly this with a catch ofObjectDisposedException(MacOSWindowHost.cs, around line 1038), and its remarks describe the same hazard. Suggested fix: invoke the callback under_gatein the handler (lock (_gate) { if (!_disposed) onTimerElapsed(); }), soDispose()waits for an in-flight callback. All three callbacks are non-blockingSet()calls, so this does not deadlock; add a remark thatonTimerElapsedmust not block. -
The stress test (
Given_FramePacer.cs:104-125) only asserts that the requester thread throws nothing. It never has anElapsedcallback in flight, so it will not catch finding 1. A test that holds the callback open (or a callback that callsSet()on a disposed event) would. -
The new
ProjectReferencefromUno.UI.UnitTeststoUno.UI.Runtime, together withInternalsVisibleTo, pulls the full Skia runtime into the unit test build. Please confirm on CI that the unit test TFM resolution and build time are unchanged, as the description asks.
Validation: the "fails before, passes after" claim for the first test is plausible (Timer.Enabled = true throws on a disposed timer), but I have not run it.
|
@Mergifyio backport release/stable/7.0 |
🟠 Waiting for conditions to matchDetails
|
|
Tick the box to add this pull request to the merge queue (same as
|
GitHub Issue: part of #25139
PR Type:
🐞 Bugfix
What changed? 🚀
An X11
Exposecould callFramePacer.RequestFrame()on the event thread after the close path had disposed the timer, aborting the Linux Desktop WebGPU lane with exit 134.Split out of #25140 (part of the WebGPU lane stabilization tracked in #25139). In the 8 days to 2026-10-09, 36 of 39 master builds had a failed WebGPU job.
FramePacerdisposed timer (X11 exit 134)Exposecould callRequestFrame()on the event thread after the close path disposed the timerGiven_FramePacerunit tests failed with the CI exception before the fixResults (CI build 238511, every WebGPU lane forced on, all fixes combined)
PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code
https://claude.ai/code/session_01TP1JtY64etkfxxGCms44aN