Repository navigation
fix(window): defer the repaint size nudge and skip it on macOS 26 - #10253
Conversation
The show/restore repaint jiggle mutated the window frame synchronously inside AppKit's window-state dispatch. On macOS 26 (Tahoe), windows are scene-backed and a frame update sent re-entrantly from scene-update handling can self-deadlock the main thread in FrontBoardServices (kernel-confirmed spindump: performAsyncAndWait on the callout queue the main thread was draining). - Defer the setSize nudge to a fresh event-loop turn so it never runs inside the show/restore dispatch. - On Darwin 25+ (macOS 26) skip the nudge entirely and rely on webContents.invalidate(); the nudge works around a pre-Tahoe black-surface compositor bug.
📝 WalkthroughWalkthroughAdds a Darwin release helper that identifies macOS Tahoe or newer from Darwin major versions. Updates 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 7c4fb293-2480-4448-b4b2-078572dfa3a0
📒 Files selected for processing (4)
src/main/window/createMainWindow.test.tssrc/main/window/createMainWindow.tssrc/main/window/macos-tahoe-release.test.tssrc/main/window/macos-tahoe-release.ts
| const major = Number.parseInt(darwinRelease, 10) | ||
| return Number.isFinite(major) && major >= 25 |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
Does JavaScript Number.parseInt('25-invalid', 10) return 25, and does it accept trailing invalid characters?
💡 Result:
Yes, Number.parseInt('25-invalid', 10) returns 25 [1][2]. The function operates by parsing the string from left to right [3][4]. When it encounters a character that is not a valid numeral for the specified radix (in this case, base 10), it stops parsing, ignores that character and all subsequent characters, and returns the integer value parsed up to that point [5][3][6]. Because the sequence "25" is valid in base 10 and the hyphen ("-") is not a valid numeral, the function successfully parses "25" and discards "-invalid" [5][3][4]. This behavior confirms that JavaScript's parseInt (and by extension, Number.parseInt) accepts and ignores trailing invalid characters [7][6].
Citations:
- 1: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt
- 2: https://github.com/mdn/content/blob/main/files/en-us/web/javascript/reference/global_objects/number/parseint/index.md
- 3: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt
- 4: https://stackoverflow.com/questions/67998993/why-does-number-parseint111aaa-works-like-its-supposed-to-in-js-what-is-th
- 5: https://learn.microsoft.com/en-us/scripting/javascript/reference/parseint-function-javascript?redirectedfrom=MSDN
- 6: https://stackoverflow.com/questions/9429113/is-parseint-supposed-to-work-like-this
- 7: https://stackoverflow.com/questions/46621185/what-is-the-critical-difference-between-number-parseint-number-parsefloat
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Files:"
git ls-files | rg '(^|/)macos-tahoe-release(\.test)?\.ts$' || true
echo
echo "Source outline:"
for f in $(git ls-files 'src/main/window/macos-tahoe-release.ts' 'src/main/window/macos-tahoe-release.test.ts'); do
echo "--- $f ---"
wc -l "$f"
cat -n "$f"
done
echo
echo "JS parseInt semantics for relevant inputs:"
node - <<'JS'
const inputs = ['', 'unknown', '25-invalid', '25.0.bad', '25', '25.0', '26.1', '24', 'foo25', '25invalid']
for (const s of inputs) {
const major = Number.parseInt(s, 10)
const current = Number.isFinite(major) && major >= 25
console.log(JSON.stringify(s), { major, current })
}
JSRepository: stablyai/orca
Length of output: 2097
Reject partially numeric release strings.
Number.parseInt('25-invalid', 10) returns 25, so malformed inputs like 25-invalid or 25.0.bad are classified as Tahoe while still falling through to pre-Tahoe for non-numeric releases.
src/main/window/macos-tahoe-release.ts#L6-L7: validate the complete release format before comparing the major version.src/main/window/macos-tahoe-release.test.ts#L15-18: addfalseexpectations for25-invalidand25.0.bad.
Proposed fix
- const major = Number.parseInt(darwinRelease, 10)
- return Number.isFinite(major) && major >= 25
+ const match = /^(\d+)(?:\.\d+)*$/.exec(darwinRelease)
+ return match !== null && Number(match[1]) >= 25📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const major = Number.parseInt(darwinRelease, 10) | |
| return Number.isFinite(major) && major >= 25 | |
| const match = /^(\d+)(?:\.\d+)*$/.exec(darwinRelease) | |
| return match !== null && Number(match[1]) >= 25 |
📍 Affects 2 files
src/main/window/macos-tahoe-release.ts#L6-L7(this comment)src/main/window/macos-tahoe-release.test.ts#L15-L18
…e the reveal reflow (#10473) * fix(window): restore the macOS 26 reflow without touching the native frame #10253 stopped the main-thread deadlock by skipping the repaint size nudge on macOS 26, but invalidate() repaints without reflowing, so the h-dvh root kept a stale viewport height and the status bar stayed clipped off-screen (STA-2383) on every Tahoe reveal, restore and wake. Drive the reflow through device emulation instead: a +1px emulated viewport, reverted a frame later, makes the renderer recompute layout without any NSWindow mutation, so the FrontBoardServices re-entrancy that wedged the main thread for 109 minutes is still never triggered. Verified against real Electron 43.1.0 on macOS 26.3.1 (Darwin 25.3.0): the renderer sees the resize and relayouts, the native frame is untouched, the viewport and devicePixelRatio restore exactly across zoom levels, overlapping calls collapse to one cycle, and a 1px delta never crosses a terminal cell boundary so no pane reports new geometry (no SIGWINCH to running shells). Also close two gaps in the surrounding code: - the pre-Tahoe size jiggle now clears its WeakSet latch in a finally block, so a throwing setSize can no longer suppress every later repaint for that window - cover powerMonitor 'resume' under the Tahoe guard, the other AppKit dispatch context implicated in the freeze * fix(tray): keep NSStatusItem scene updates off the AppKit callout stack The main-window repaint was only one of the two doors into the macOS 26 FrontBoardServices deadlock. Showing or restoring the window calls setTrayAttention(false) straight from the window event handler, and tray.setImage/setToolTip drive an NSStatusItem scene update — the same re-entrant scene mutation from inside AppKit's own dispatch, matching the stackshot in openai/codex#23695. Defer the native mutation to a fresh event-loop turn so the callout frame is vacated first. The attention flag itself still flips synchronously: rapid show/hide would otherwise mis-dedupe against a value that had not landed yet. Bursts collapse to a single repaint, and because the deferred pass reads current module state rather than a captured value, a coalesced schedule can never apply a stale icon. applyTrayImage already no-ops on a destroyed tray, so a repaint still queued when the tray goes away is harmless. * fix(window): reflow maximized and fullscreen windows on macOS 26 too The maximized/fullscreen bail-out predates the Tahoe path and exists only to keep the size nudge from resizing a window out of those states. Emulation never touches the frame, so that guard was suppressing the reflow for no reason — and a maximized window strands its dvh layout exactly like a normal one. Run the Tahoe branch before the guard. Verified on macOS 26.3.1 that the emulated viewport reflows a maximized and a fullscreen window while leaving both states intact. * fix(window): retry the viewport restore instead of stranding the renderer If disableDeviceEmulation threw while the webContents was still alive, the previous code swallowed the error and cleared the latch anyway, leaving the renderer pinned at the emulated 1px-taller viewport for the rest of the window's life — and letting the next reveal stack a fresh cycle on top of it. Retry the restore on a bounded schedule and hold the latch while a retry is pending. A destroyed webContents still short-circuits, since the emulated viewport dies with it, and the attempt budget keeps a permanently failing restore from pinning the latch forever.
…ablyai#10253) The show/restore repaint jiggle mutated the window frame synchronously inside AppKit's window-state dispatch. On macOS 26 (Tahoe), windows are scene-backed and a frame update sent re-entrantly from scene-update handling can self-deadlock the main thread in FrontBoardServices (kernel-confirmed spindump: performAsyncAndWait on the callout queue the main thread was draining). - Defer the setSize nudge to a fresh event-loop turn so it never runs inside the show/restore dispatch. - On Darwin 25+ (macOS 26) skip the nudge entirely and rely on webContents.invalidate(); the nudge works around a pre-Tahoe black-surface compositor bug.
…e the reveal reflow (stablyai#10473) * fix(window): restore the macOS 26 reflow without touching the native frame stablyai#10253 stopped the main-thread deadlock by skipping the repaint size nudge on macOS 26, but invalidate() repaints without reflowing, so the h-dvh root kept a stale viewport height and the status bar stayed clipped off-screen (STA-2383) on every Tahoe reveal, restore and wake. Drive the reflow through device emulation instead: a +1px emulated viewport, reverted a frame later, makes the renderer recompute layout without any NSWindow mutation, so the FrontBoardServices re-entrancy that wedged the main thread for 109 minutes is still never triggered. Verified against real Electron 43.1.0 on macOS 26.3.1 (Darwin 25.3.0): the renderer sees the resize and relayouts, the native frame is untouched, the viewport and devicePixelRatio restore exactly across zoom levels, overlapping calls collapse to one cycle, and a 1px delta never crosses a terminal cell boundary so no pane reports new geometry (no SIGWINCH to running shells). Also close two gaps in the surrounding code: - the pre-Tahoe size jiggle now clears its WeakSet latch in a finally block, so a throwing setSize can no longer suppress every later repaint for that window - cover powerMonitor 'resume' under the Tahoe guard, the other AppKit dispatch context implicated in the freeze * fix(tray): keep NSStatusItem scene updates off the AppKit callout stack The main-window repaint was only one of the two doors into the macOS 26 FrontBoardServices deadlock. Showing or restoring the window calls setTrayAttention(false) straight from the window event handler, and tray.setImage/setToolTip drive an NSStatusItem scene update — the same re-entrant scene mutation from inside AppKit's own dispatch, matching the stackshot in openai/codex#23695. Defer the native mutation to a fresh event-loop turn so the callout frame is vacated first. The attention flag itself still flips synchronously: rapid show/hide would otherwise mis-dedupe against a value that had not landed yet. Bursts collapse to a single repaint, and because the deferred pass reads current module state rather than a captured value, a coalesced schedule can never apply a stale icon. applyTrayImage already no-ops on a destroyed tray, so a repaint still queued when the tray goes away is harmless. * fix(window): reflow maximized and fullscreen windows on macOS 26 too The maximized/fullscreen bail-out predates the Tahoe path and exists only to keep the size nudge from resizing a window out of those states. Emulation never touches the frame, so that guard was suppressing the reflow for no reason — and a maximized window strands its dvh layout exactly like a normal one. Run the Tahoe branch before the guard. Verified on macOS 26.3.1 that the emulated viewport reflows a maximized and a fullscreen window while leaving both states intact. * fix(window): retry the viewport restore instead of stranding the renderer If disableDeviceEmulation threw while the webContents was still alive, the previous code swallowed the error and cleared the latch anyway, leaving the renderer pinned at the emulated 1px-taller viewport for the rest of the window's life — and letting the next reveal stack a fresh cycle on top of it. Retry the restore on a bounded schedule and hold the latch while a retry is pending. A destroyed webContents still short-circuits, since the emulated viewport dies with it, and the attempt budget keeps a permanently failing restore from pinning the latch forever.
Problem
A macOS 26.5.1 user hit a permanent main-thread deadlock (kernel-confirmed via spindump: unresponsive 1305+s) inside AppKit/FrontBoardServices scene-update handling: a window-frame update delivered from the window server re-entered frame code, sent a scene update back with
performAsyncAndWaiton the FrontBoard callout queue the main thread was already draining, and waited on itself forever. The deadlock stack is entirely Apple frames, but it requires re-entrant frame updates — and ourshow/restorerepaint jiggle callssetSizesynchronously inside AppKit's window-state dispatch, which is exactly that re-entrant shape. The jiggle also fires up to 4 frame updates per visibility transition since #9395 doubled it.macOS 26 (Tahoe) windows are scene-backed; this machinery does not exist pre-26.
Fix
show/restoredispatch (applies to all macOS versions; frame mutation from inside a windowing callback is never safe).webContents.invalidate()alone. The nudge exists to work around a pre-Tahoe black-surface compositor bug; on Tahoe it is unneeded risk. Newmacos-tahoe-release.tsholds the version gate.Behavior is unchanged pre-Tahoe apart from the one-turn deferral (revert still lands 32ms later; the terminal SIGWINCH pattern is identical).
Testing
setSize.vitest(77 tests),oxlint,typecheck:nodeall green.ELI5
When the Orca window comes back on screen (un-minimize, reopen), macOS sometimes forgets to repaint it, leaving it black. Our workaround was to "wiggle" the window — make it 1px wider, then put it back — which forces a repaint. The problem: we did the wiggle at the exact moment macOS was in the middle of its own window bookkeeping, and on macOS 26 interrupting that bookkeeping can freeze the entire app forever (that's the deadlock a user hit). This PR waits until macOS finishes its bookkeeping before wiggling, and on macOS 26 it doesn't wiggle at all — it just asks the window to repaint directly, because the wiggle is dangerous there and the bug it worked around is a pre-macOS-26 bug.
Trade-offs
invalidate()alone doesn't fix. Accepted deliberately: a black flash is recoverable; the deadlock is not. If reports come in, the follow-up is a Tahoe-safe repaint path, not restoring the nudge.25+= macOS 26) — no build/minor granularity. If Apple fixes the deadlock in a later 26.x, we still skip the nudge there; that stays correct since it's unneeded on 26 anyway.