Skip to content

feat(macos): Dedicated Metal render thread - #23594

Merged
morning4coffe-dev merged 15 commits into
feature/breakingchangesfrom
dev/mazi/render-macos-renderthread
Aug 24, 2026
Merged

morning4coffe-dev merged 15 commits into
feature/breakingchangesfrom
dev/mazi/render-macos-renderthread

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Jun 29, 2026 •

Copy link
Copy Markdown
Member

Moves macOS Metal rendering (draw + GPU flush + present) off the UI thread onto a dedicated render thread, mirroring the existing Win32, X11, and iOS render threads. macOS was the only Skia host still drawing on the UI/main thread, so a slow present or VSync wait directly stalled input and layout.

Driven entirely by master's existing per-host contract — InvalidateRender() wakes the render thread, which draws the recorded SKPicture via OnNativePlatformFrameRequested and presents. No shared-scheduler changes (no OnFramePresented / SupportsRenderThrottle).

What changed

  • MacOSRenderThread (mirrors Win32's RenderThread): an AutoResetEvent-signalled loop that acquires a drawable, draws, Flush(submit: true), then presents.
  • InvalidateRender → SignalNewFrame() on the Metal path (software path unchanged).
  • Native acquire/present split using CAMetalLayer.nextDrawable (thread-safe, unlike MTKView.currentDrawable which is main-thread-only), wrapped in @autoreleasepool; paused=YES; enableSetNeedsDisplay=NO; maximumDrawableCount = 2.
  • A paused MTKView never runs the draw cycle that applies a new drawable size to its CAMetalLayer, so drawableSizeWillChange: now applies it explicitly, and uno_window_acquire_next_frame reports the acquired texture's own dimensions rather than the layer's drawableSize (the two can disagree mid-resize).
  • Clip-path (uno_window_clip_svg) updates marshalled to the main thread (AppKit layer mutation).

Measured impact

Workload: Performance_1000ButtonsContinuousRendering (1000 buttons + forever ColorAnimation). Both builds are the same merged master, differing only in src/Uno.UI.Runtime.Skia.MacOS/. sample at 1 ms, two independent runs (40 s + 25 s), Apple M4, 120 Hz display.

UI thread availability

Main thread master this PR
Busy 62.1 – 64.8 % 7.6 – 8.2 %
Idle (free for input/layout) 35.2 – 37.9 % 91.8 – 92.4 %

Where master's main-thread time went (inclusive, % of main-thread samples)

Frame master this PR
drawInMTKView 39.1 % 0 %
currentDrawable 39.1 % 0 %
MetalDraw (managed) 38.9 % 0 %

drawInMTKView (12840 samples) ≈ currentDrawable (12831) — essentially all of that 39 % is the blocking drawable/VSync wait, which is exactly what this PR removes from the UI thread.

Throughput — no regression, better worst case

FPS master this PR
Median 120 120
Mean 114.7 118.5
Min 61 85

Both saturate the 120 Hz display; the PR is better on mean and notably better on worst-case frame time. Process CPU was also lower (~22–27 % vs ~29–37 %).

Validation

Validated on macOS 26.2 / Xcode 26.2 / Apple M4 with a locally built libUnoNativeMac.dylib, running SamplesApp.Skia.Generic:

  • Rendering correctness — glyph/text rendering pixel-diffed against master on Icons/FontIconControlTest: 0 differing pixels across the full content area (the only delta was title-bar chrome from window focus state).
  • Native element clipping — ContentPresenter/ContentPresenter_NativeEmbedding_ZIndex (overlapping WebViews, animated Z-order): identical clip geometry to master (3 distinct clip paths, 1 update/sec matching the animation, no redundant re-application).
  • AcrylicBrush — framebuffer sampling works from the render thread, including live slider-driven tint updates.
  • MediaPlayerElement — video playback with transport controls composited over the native layer, including resize during playback.
  • Resize — grow and shrink, at both 1x and 2x backing scale.
  • Fullscreen enter/exit, minimize/restore.
  • Render thread idle behaviour — blocked on __psynch_cvwait in 1729/1735 samples (99.7 %), ~1 % process CPU while idle; no spin when the window is occluded/minimized and nextDrawable returns nil.
  • Shutdown — clean, no ObjectDisposedException, no crash reports.

Not covered

  • A live drag between two displays with different backing scale factors. The scale-change path was exercised by running at both 1x and 2x (same drawableSizeWillChange: funnel), but a hot display switch is untested.
  • Intel (x86_64) hardware — validated on Apple Silicon only. The dylib builds universal.

@github-actions github-actions Bot added the platform/macos 🍏 Categorizes an issue or PR as relevant to the macOS platform label Jun 29, 2026
@github-actions

github-actions Bot commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 5m 10s —— View job


Code Review

  • Gather context and read changed files
  • Review C# changes (MacOSWindowHost, NativeUno)
  • Review Objective-C changes (UNOMetalViewDelegate, UNOWindow)
  • Post inline review comments
  • Update summary

Verdict: fix-first (draft PR, as intended — 1 crash-risk finding before this ships)

Summary

The design is sound and mirrors the Win32/X11 pattern correctly. The ObjC drawable lifecycle (CAMetalLayer.nextDrawable + maximumDrawableCount=2 + paused=YES) is appropriate, and the C# render loop structure is clean. However there are five issues across the two layers worth resolving before this goes non-draft:

# Severity Finding
1 Critical Dispose() disposes _frameSignal/_presentedEvent after a potentially-timed-out Join, which crashes the process if the render thread is blocked in nextDrawable — see inline on line 950
2 Significant drawInMTKView: still calls the legacy managed MetalDraw path; a system-triggered redraw (GPU reset, subview setNeedsDisplay:) would produce a GRContext data race with the render thread — see inline on ObjC line 109
3 Significant First-frame sizing bootstrap (_initializationCompleted + UpdateWindowSize()) from the legacy MetalDraw path is not replicated in RenderThreadMetalDraw; relies solely on the native resize callback, which is a known fragile path (uno-private#319) — see inline on line 102
4 Minor _presentedEvent / WaitForNextPresent are dead code; reset+set every frame for nothing — see inline on line 908
5 Minor _lastSvgClipPath is accessed with Volatile.Read/Write on the render thread but via plain field accesses in the still-reachable legacy MetalDraw() — inconsistent, makes the two paths harder to reason about — see inline on line 127
6 Note maximumDrawableCount=2 trade-off (double vs. triple buffering) deserves a comment explaining the stutter risk under slow frames — see inline on ObjC line 333

Cross-cutting notes

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 220116 has failed on Uno.UI - CI.

@MartinZikmund
MartinZikmund force-pushed the dev/mazi/render-macos-renderthread branch from 8906333 to 569d9ed Compare July 13, 2026 08:45
@github-actions

github-actions Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 5m 48s —— View job


Code Review

  • Gather context and understand the PR
  • Read changed C# files
  • Read changed Objective-C files
  • Post inline review comments
  • Update summary

Verdict: fix-first (draft PR, as intended — issues below must be resolved before promotion)

Summary

The overall design is sound: CAMetalLayer.nextDrawable (thread-safe) + paused=YES + enableSetNeedsDisplay=NO is the right contract for a background render loop, and the C# MacOSRenderThread mirrors the Win32 pattern cleanly. However, several issues remain unresolved from the prior review pass, plus one new finding (resource leak):

# Severity Finding Inline
1 Critical Dispose() disposes _frameSignal/_presentedEvent after an unchecked Thread.Join — if the join times out, the render thread's subsequent _presentedEvent.Set() (outside the inner try/catch) terminates the process with ObjectDisposedException ↗
2 Significant Pre-existing drawInMTKView: still calls MetalDraw() / GRContext on the main thread with no isPaused guard — a latent data race if the delegate fires during an active render-thread draw ↗
3 Significant GRBackendRenderTarget / SKSurface in RenderThreadMetalDraw are disposed on the happy path only — any exception leaks both Skia native resources (new finding, not in prior review) ↗
4 Significant First-frame sizing bootstrap (_initializationCompleted + UpdateWindowSize) from MetalDraw() not replicated in RenderThreadMetalDraw ↗
5 Minor _presentedEvent / WaitForNextPresent are dead code — hot-path overhead for nothing ↗
6 Minor _lastSvgClipPath uses Volatile.Read on the render thread but plain field access in MetalDraw() — inconsistent memory ordering ↗
7 Note maximumDrawableCount=2 comment should document the stutter-under-load trade-off ↗

Cross-cutting notes

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 221937 has failed on Uno.UI - CI.

@github-actions

github-actions Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 3m 58s —— View job


Code Review

  • Gather context and read changed files
  • Compare with previous review findings to check what's been addressed
  • Review C# changes (MacOSWindowHost.cs)
  • Review Objective-C changes (UNOMetalViewDelegate.m, UNOWindow.m)
  • Post inline review comments
  • Update summary

Verdict: fix-first (draft PR, as intended — one significant finding remains open before promotion)

Progress since last review

Good iteration — five of the six prior findings are resolved:

# Prior finding Status
1 Critical — Dispose() crash if join times out ✅ Fixed: join return value is now checked; primitives are intentionally leaked (with warning log) on timeout
2 Significant — drawInMTKView: / GRContext data race ✅ Fixed: if (view.isPaused) return; guard added with explanatory comment
3 Significant — GRBackendRenderTarget/SKSurface leak on exception ✅ Fixed: try/finally with ?.Dispose() now covers exception paths
4 Significant — first-frame sizing bootstrap not replicated ⚠️ Still open — see inline comment on line 104
5 Minor — _presentedEvent/WaitForNextPresent dead code ✅ Addressed: // TODO: comment documents intent to wire for future OnFramePresented/SupportsRenderThrottle
6 Minor — _lastSvgClipPath volatile inconsistency ✅ Fixed: field marked private volatile string? — all accesses on both paths are now correctly ordered
7 Note — maximumDrawableCount=2 comment lacking trade-off ✅ Fixed: comment now explains double-buffering latency/headroom trade-off

Remaining open finding

Finding #4 (Significant): RenderThreadMetalDraw receives nativeWidth/nativeHeight from the drawable but never uses them to initialize managed layout. The legacy MetalDraw() path drives UpdateWindowSize(nativeWidth / scale, nativeHeight / scale) on first draw to compensate for the race documented in uno-private#319, where drawableSizeWillChange: fires before SizeChanged has subscribers. Without this, the first frame may render into a zero-size composition. See inline comment.

Cross-cutting notes

  • No event Action/event Action<T>; no async void; no .GetAwaiter().GetResult() — clean.
  • Compile validation only — PR correctly remains draft pending macOS CI + hardware testing.
  • The overall design (acquire/draw/flush+present on the render thread, clip-path marshalled back to main) is correct and mirrors Win32 cleanly.
  • The GRContext thread-affinity risk is now properly guarded by both paused=YES in ObjC and the isPaused early-exit in drawInMTKView:.

@MartinZikmund

MartinZikmund commented Jul 14, 2026 •

Copy link
Copy Markdown
Member Author

PR review triage — automated pass

No code change / no new commit this pass. Branch head remains 5aad3c28b9. All three unresolved threads are the same concern and are blocked on a decision plus real macOS hardware, so shipping an unvalidated change would be worse than leaving it open.

Reviewed by code inspection only — no build/test was run here; Azure Pipelines CI validates on push.

Needs @MartinZikmund input (3) — left open

All three threads below raise the identical point: RenderThreadMetalDraw (MacOSWindowHost.cs:104) does not replicate the legacy MetalDraw() first-frame sizing bootstrap (the _initializationCompleted guard that calls UpdateWindowSize(nativeWidth / scale, nativeHeight / scale) on first draw, per uno-private#319). You already replied to two of them leaving them open for yourself; the newest one adds a concrete code suggestion.

file:line the point why it needs you
src/Uno.UI.Runtime.Skia.MacOS/UI/Xaml/Window/MacOSWindowHost.cs:104 First-frame sizing bootstrap not replicated in the render-thread draw path (thread 1 — you already replied "left open for @MartinZikmund"). Needs an Intel + Apple-Silicon run to confirm whether the initial drawableSizeWillChange: resize is dropped before SizeChanged has subscribers.
src/Uno.UI.Runtime.Skia.MacOS/UI/Xaml/Window/MacOSWindowHost.cs:104 Same concern, re-raised (thread 2 — you already replied "left open for @MartinZikmund"). Same — a duplicate of thread 1; blocked on the same hardware check.
src/Uno.UI.Runtime.Skia.MacOS/UI/Xaml/Window/MacOSWindowHost.cs:104 Same concern (thread 3, newest) with a suggested NativeDispatcher.Main.Enqueue(...) bootstrap. The suggestion is subtle and risky, see below. Not applied.

Why I did not apply the suggested fix in thread 3:

  1. Cross-thread race. The snippet writes _initializationCompleted inside a main-thread lambda while the render thread reads it every frame — an unsynchronized field race (it isn't volatile).
  2. Re-enqueues every frame. Right after Enqueue, it checks !_initializationCompleted (still false, the lambda hasn't run) and returns, so every render-thread draw enqueues another UpdateWindowSize until SizeChanged has subscribers.
  3. Your own analysis stands. UpdateWindowSize raises SizeChanged synchronously; marshalling it to the main thread and early-returning could regress into a permanently-blank window (the render thread only wakes on InvalidateRender), which is a worse failure than a stale size.
  4. May already be moot. The static Resize native callback (MacOSWindowHost.cs:438) already calls UpdateWindowSize independently of the draw path, and RenderThreadMetalDraw is only reached via IXamlRootHost.InvalidateRender (raised after the managed host is up). The only genuinely open question — is the initial resize callback still dropped? — can only be answered on hardware.

This is a "needs compiling + real-device validation to trust" change, so per the debugging-discipline rules I've flagged it rather than shipping an unvalidated guess. Nothing is being auto-resolved.

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 222199 has failed on Uno.UI - CI.

@morning4coffe-dev morning4coffe-dev self-assigned this Jul 25, 2026
@github-actions

github-actions Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @morning4coffe-dev's task in 5m 44s —— View job


Code Review

  • Gather context and understand the PR
  • Read changed C# files (MacOSWindowHost.cs, NativeUno.cs)
  • Read changed Objective-C files (UNOMetalViewDelegate.m, UNOWindow.m, headers)
  • Compare with previous review findings to check what's been addressed
  • Post inline review comments
  • Update summary

Verdict: fix-first (draft PR — one minor correctness finding from the new commit; the first-frame sizing question remains the last gating item before non-draft)

Progress since last review (July 14)

The new commit 334284e8 fix(macos): Correct render thread drawable acquisition and sizing correctly migrates drawable acquisition from MTKView.currentDrawable (main-thread-only) to CAMetalLayer.nextDrawable (thread-safe). All previously resolved findings remain fixed.

# Prior finding Status
1 Critical — Dispose() crash if join times out ✅ Fixed
2 Significant — drawInMTKView: / GRContext data race ✅ Fixed (if (view.isPaused) return; guard)
3 Significant — GRBackendRenderTarget/SKSurface leak on exception ✅ Fixed (using blocks)
4 Significant — first-frame sizing bootstrap not replicated ⚠️ Still open — requires hardware validation on Intel + Apple Silicon
5 Minor — _presentedEvent/WaitForNextPresent dead code ✅ Addressed (TODO comment)
6 Minor — _lastSvgClipPath volatile inconsistency ✅ Fixed (private volatile string?)
7 Note — maximumDrawableCount=2 trade-off undocumented ✅ Fixed

New findings in this pass

# Severity Finding Inline
8 Minor metalLayer.drawableSize is read after nextDrawable on the render thread; a concurrent main-thread resize could update drawableSize between the two calls, causing the reported texture dimensions to mismatch the actual drawable. Should read drawable.texture.width/height instead. ↗
9 Note _lastSvgClipPath is written eagerly before the native call succeeds, differing from MetalDraw's write-on-success pattern. Retry semantics are correct but subtly delayed by one main-thread dispatch; worth a brief comment so future readers understand the intent. ↗
10 Note ManualResetEventSlim for WaitForNextPresent has a latent ordering issue when eventually wired: a caller can see the previous frame's signal as "current". Should use AutoResetEvent or a generation counter when that contract is implemented. ↗

Cross-cutting notes

  • Compile validation only — PR correctly remains draft; C# builds clean per prior reports. The new ObjC change in 334284e8 requires macOS CI to validate the native compile.
  • Architecture is sound: CAMetalLayer.nextDrawable (render thread) + paused=YES + isPaused early-exit guard in drawInMTKView: correctly enforces exclusive GRContext ownership. The retained-layer / swapchain-surface split is a clean separation: XAML-layout-sized content in the retained layer, pixel-exact swapchain surface for the texture blit.
  • GRContext thread affinity — created on main thread, flushed on render thread. paused=YES is the exclusion mechanism; the isPaused guard is the second layer. No new concurrent-access paths introduced.
  • No event Action/event Action<T>; no async void; no .GetAwaiter().GetResult() — clean.
  • Shutdown ordering is correct: render thread is joined before GRContext/native teardown in WindowClose.

morning4coffe-dev and others added 13 commits August 22, 2026 15:06
uno_window_acquire_next_frame looked up the MTKView through
contentViewController.view, which is the plain container NSView holding the
rendering view, so the kind check always failed and the render thread never
drew or presented a single frame.

RenderThreadMetalDraw also sized the swapchain GRBackendRenderTarget from the
managed XamlRoot bounds instead of the acquired texture, so any disagreement
between the two (window resize) rendered the app into a sub-rect of the
drawable. Restore the RetainedLayer indirection used by the legacy draw path
and by X11: the app draws into the retained layer at the managed size, and only
the blit targets the drawable at its own size. That also keeps the canvas
stable across frames, so damage-region rendering stays enabled.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 232da7e5-d077-4700-95a3-673fb777537d
The render thread needs a pace, and the only rate that makes sense is the one
the compositor recycles drawables at. NSScreen.maximumFramesPerSecond gives it;
0 means unknown, so the caller keeps its configured rate. Falls back to the main
screen because a window that was never ordered front has no screen of its own.

Also drops a stale comment claiming maximumDrawableCount is 2 — uno_window_create
sets 3 — and says what actually matters about nextDrawable: it does not simply
block, it gives up after ~1s and returns nil once the pool is exhausted.
…rottle it

macOS is the only Skia host whose render thread had no pace. X11 and Win32 both
got one in #21299; macOS was left driving frames straight off InvalidateRender,
relying on nextDrawable to block until the compositor was ready.

That works only while the compositor keeps up. Once the layer's drawable pool is
exhausted nextDrawable does not block-and-succeed, it blocks for ~1s and returns
nil — so an unpaced loop that acquires as fast as it is signalled outruns the
compositor and converts every frame into a one-second stall, then retries into
the same wall. On the hosted CI agents this dominated the run.

Pace frame requests through FramePacer, exactly as X11 does, so acquisitions
happen at most once per refresh interval. A timer drives the pace rather than the
display, which keeps the render clock ticking when the display does not — an
occluded window, or a headless agent.

Retries of an unpresentable frame stay (dropping one permanently latches
CompositionTarget's render-requested flag and hangs anything awaiting a frame)
but are now paced and back off to 1s, so a window that can never present no
longer spins the GPU. The backoff waits on the shutdown event, so Dispose still
joins promptly.

Also logs the render surface, the screen refresh rate and the resolved pace once
per window, and warns when consecutive frames cannot be presented. Nothing
currently records whether a drawable was ever vended, which is why this failure
mode was invisible for months.
…rdown

Dispose stops the pacer before disposing the events, but a timer callback already
in flight can still run after Timer.Dispose returns and would then Set a disposed
handle. System.Timers.Timer does not swallow that on .NET Core, so it would
surface as an unhandled exception on a timer thread while a window is closing —
and the runtime-test suite closes secondary windows constantly.
…lure

Build 228360 timed out with 801 hard 3.05s +/- 0.05 gaps and emitted zero
"could not present" warnings, which proved the previous threshold useless as a
diagnostic: it only fired on the fourth consecutive failure, so any pattern of
one to three would have looked identical to a healthy run.

Time the acquisition instead and report the first call that fails or blocks over
100ms, then at most one report per 5s. That distinguishes "the render thread is
stuck in nextDrawable" from "the render thread is idle and the time goes
elsewhere" — which the previous run could not.
Reaching the Idle queue should cost microseconds. On the macOS CI leg 475 of
1504 distinct tests deterministically pay a 3.05s gap that throws nothing, which
is consistent with WaitForIdle itself blocking: WaitFor only re-evaluates its
deadline between awaits, so a slow await never trips the timeout it exists to
enforce and the cost stays invisible.

Log a throttled line when a pair of idle round-trips exceeds 500ms. This touches
the shared harness rather than the macOS host on purpose — the question is
whether the Idle queue is starved, which is not a macOS-specific measurement —
but it is slow-path only and Linux/Win32 (15.4 and 18.9 min on this build) will
not reach it. Addresses the "stalls are undiagnosable" gap in #24006.
UnitTestsControl retries a failed test twice (DefaultRepeatCount = 3) and logs
nothing when it does; the retry loop sits inside InvokeTestMethod while the
"Running test" line is emitted outside it. A test that fails twice and passes on
the third attempt is therefore indistinguishable in the log from one that was
simply slow — it just reports as passed with ~3x its real duration.

That is very likely what the macOS render-thread leg is showing: 815 inter-test
gaps of 3.05s +/- 0.046, which is 3 x WaitFor's 1000ms default timeout, on 475
tests that are deterministically affected while nextDrawable and the Idle queue
were both measured healthy.

Log the retry (with the exception that caused it) and the WaitFor timeout (with
its caller, line, elapsed time and idle round-trip count), both on the failure
path only.
…path

This is the cause of the branch's macOS CI regression.

The non-threaded MetalDraw re-delivers the native window size from every draw
until the managed host has subscribed to SizeChanged, because the first native
size updates arrive before managed initialization completes (the FIXME for
uno-private#319). RenderThreadMetalDraw never had that block, so a size that
arrives too early is lost and the window's XamlRoot.Bounds stays 0x0.

CoreServices.RequestAdditionalFrame silently does nothing while bounds are zero
(CoreServices.cs:67), and it is what schedules OnTick — which runs UpdateLayout
and RaiseLoadedEvent. So for an affected window no layout ever runs, ActualWidth
and ActualHeight stay 0, and WaitForLoaded's condition can never become true.

The visible result was a hard 3.05s quantum on ~32% of test boundaries: WaitFor
burns its full 1000ms timeout, the runner silently retries twice (logging
nothing), and the test then reports Failed — invisible in CI because
ReportTestResult never writes to the console and the run is cancelled before the
NUnit XML is written. Tests that pass a larger timeout scale exactly with it
(3000ms -> 9.01s, 5000ms -> 15.3s, 30000ms -> 90.2s), which is what identified
the retry as the multiplier.

UpdateWindowSize raises SizeChanged into the managed tree, so the bootstrap is
marshalled to the UI thread; the render thread is asked for another frame while
it is pending, and that request is paced so it cannot spin.
Console.WriteLine was the wrong channel for these. UnitTestsControl replaces
Console.Out with a TextWriterDuplicator that overrides only Write(char), so every
console line written during a test is pushed through it one character at a time
and is also captured into that test's recorded output — a poor fit for a
diagnostic that fires on a hot failure path.

Use what the surrounding code already uses: UnitTestsControl's own _log (the
Logger behind the "Running test" lines) and, for the static WindowHelper,
typeof(WindowHelper).Log() as in Given_HotReloadWorkspace. Both respect log-level
filtering and carry a category, and CI already enables them via
AddFilter("Uno.UI.Runtime.Skia", Debug) and the app's Information default.
Build 228902 was green on macOS (23.4 min, third consecutive pass) with two
failures elsewhere, both in code this branch cannot reach:

  LinuxFB  Given_BitmapIcon.When_Foreground_Changed_With_ShowAsMonochrome_True
           (expected FFFF0000, got transparent)
  WASM 2   Given_ListViewBase.When_Incremental_Load_ShouldStop
           (Actual <7> is not less than <7>)

Master's own LinuxFB leg fails a different pixel test at a similar rate
(1 of 9 sampled builds: Given_FrameworkElement_Opacity.When_Opacity), so these
look like flakes on weak legs rather than a regression. Re-running to confirm:
if LinuxFB passes here, the BitmapIcon failure is flake, not this branch.
@MartinZikmund
MartinZikmund changed the base branch from master to feature/breakingchanges August 22, 2026 14:57
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/render-macos-renderthread branch from 6b58c6a to f236fab Compare August 22, 2026 14:57
@github-actions

github-actions Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 5m 13s —— View job


Code Review

  • Gather context and understand the PR
  • Read changed C# files (MacOSWindowHost.cs, NativeUno.cs, test files)
  • Read changed Objective-C files (UNOMetalViewDelegate.m/h, UNOWindow.m/h)
  • Compare with previous review findings
  • Post inline review comments
  • Update summary

Verdict: ship — same 14 commits reviewed across prior passes, rebased onto master. macOS CI is now green (21.1 min, 8006 tests, two consecutive successful runs). All blocking and significant findings are resolved. Three pre-existing notes remain open, plus two new note-level findings in this pass.

Status of all prior findings

# Finding Status
1 Dispose() crash if join times out ✅ Fixed (unbounded join + _shutdown interrupt)
2 drawInMTKView: / GRContext data race ✅ Fixed (isPaused guard)
3 GRBackendRenderTarget/SKSurface leak on exception ✅ Fixed (using blocks)
4 First-frame sizing bootstrap not replicated ✅ Fixed (637060aa — volatile _initializationCompleted, enqueued UpdateWindowSize)
5 _presentedEvent/WaitForNextPresent dead code ✅ Documented; correct Reset/Set ordering
6 _lastSvgClipPath volatile inconsistency ✅ Fixed (private volatile)
7 maximumDrawableCount undocumented trade-off ✅ Addressed (now 3, comment updated)
8 Drawable dimensions TOCTOU ✅ Fixed (reads drawable.texture.width/height)
11 catch (Exception) explanation ✅ Comment added
14 ScreenParametersChanged gap ⚪ Note-level, carried forward
15 _lastAcquireLogTimestamp shared between slow/failed ⚪ Note-level, carried forward
16 Empty ObjectDisposedException catch body ⚪ Note-level, carried forward — inline comment posted
17 WaitFor<T> typed overload doesn't log before throwing ⚪ Note-level, carried forward
QA-1–3 Three runtime bugs ✅ Fixed

New findings this pass

# Severity Finding Inline
18 Note uno_window_acquire_next_frame, uno_window_present_frame, and uno_window_discard_frame are declared in both UNOMetalViewDelegate.h and UNOWindow.h. Since UNOWindow.h already #imports UNOMetalViewDelegate.h, the declarations in UNOWindow.h are redundant — a signature change in one location won't be caught as a mismatch by the compiler. ↗
19 Note // FIXME: comment at line 149 links to uno-private#319 which is inaccessible to external contributors. The prose already describes the issue clearly; the private URL can be removed. ↗

Cross-cutting notes

  • No event Action/event Action<T>; no async void; no .GetAwaiter().GetResult() — clean.
  • Shutdown ordering (unbounded join before GRContext/native teardown) is correct and deterministic.
  • Thread-safety model (paused=YES + isPaused C# guard + _metalRenderThread is not null guard + volatile _initializationCompleted) correctly enforces exclusive GRContext ownership through all lifecycle phases.
  • FramePacer mirrors X11: RequestFrame() → timer → _frameSignal.Set() → render; OnFrameStart() called at loop top. Backoff uses _shutdown.Wait() so Dispose() interrupts it immediately.
  • PR description mentions maximumDrawableCount = 2 — the code correctly uses 3 (triple-buffering). The description note is stale; worth updating before merge.

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 228997 has failed on Uno.UI - CI.

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 229536 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 163

Details
  • skia-linux-screenshots: 73 changed over 2366

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png
    • ButtonClippingTestsControl.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • ContentControl_Inheritance.png
    • Examples.png
    • ImageBrush_Stretch.png
    • Image_Margin_Large.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • Buttons.png
    • CalendarView_Theming.png-dark
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • DynamicFont.png
  • skia-windows-screenshots: 163 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ClipboardTests.png-dark
    • ElementLevelTheme.png-dark
    • CalendarView_Theming.png
    • FocusManagerTest.png-dark
    • FocusManagerTest.png
    • ColorPickerSample.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • BitmapImage_vs_SvgImageSource.png-dark
    • ExpanderColorValidationPage.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • Buttons.png
    • CalendarView_Theming.png-dark
    • ChatBox.png-dark
    • ChatBox.png
    • Focus_FocusState.png-dark
    • Focus_FocusState.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_Enumeration.png-dark
    • ImageBrushInList.png-dark

@morning4coffe-dev
morning4coffe-dev merged commit 7aab4ba into feature/breakingchanges Aug 24, 2026
47 checks passed
@morning4coffe-dev
morning4coffe-dev deleted the dev/mazi/render-macos-renderthread branch August 24, 2026 14:30
MartinZikmund added a commit to ramezgerges/uno that referenced this pull request Sep 21, 2026
unoplatform#23594 pauses the MTKView and returns early from drawInMTKView when paused,
but the branch ticks external-present (WebGPU) contexts from drawInMTKView,
so after the merge those windows never drew. Switch that view to draw
notifications and let its callback through; Skia-on-Metal is unaffected.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01XsQppKuZgijApgJxaTZt81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation platform/macos 🍏 Categorizes an issue or PR as relevant to the macOS platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants