Repository navigation
Fix long-conversation freeze on macOS (WKWebView) - #97
Conversation
Review — WKWebView long-conversation freeze shim (verified against live Core)Reviewed this end-to-end. The diagnosis and the shim design are both correct, and I verified the Core-side contract it depends on directly against What the fix does: installs a document-start, main-frame-only Verification I did against live Core (
Tests: the One design note (non-blocking): matching on the stringified function body is inherently brittle — a Core refactor that keeps the bug but rewrites the reset (e.g. Blocking item before merge: this is a Swift change and Swift can't build on our Linux CI, so it needs a Mac-agent build + |
Correction + re-verification at
|
| Claim I made | Actual live state |
|---|---|
| #6654 is the merged core fix | #6654 is an open issue, not a PR — bug(perf): virtual measurement retry budget resets during window-key oscillation |
commit ec7f8bd is the fix |
No such commit exists in core |
commit f1fb2ea is on master |
Exists (f1fb2eacc) but is not an ancestor of origin/master — it's branch history |
| #6668 is not a real core PR | Correct that it isn't merged — it is CLOSED unmerged |
The live vehicle is open PR #6717 (fix(perf): don't reset virtual measurement retry budget on window-key oscillation (#6654), head 05b6d5b47, MERGEABLE, not yet merged). So the right reference for your CHANGELOG/docs/code comment is issue #6654, fixed by PR #6717 — and the fix has not shipped yet. Sorry for sending you at a bad SHA; my earlier read used git log --all, which surfaced branch commits I then wrongly asserted were on master.
2. The shim is correct for every user today — verified, not assumed
origin/master still contains the buggy shape, so the guard correctly reports "core still broken" and keeps virtualization off:
if(_messageVirtualMeasurementCycleKey!==cycleKey){
_messageVirtualMeasurementCycleKey=cycleKey;
_messageVirtualMeasurementRetryCount=0; // ← the bug, still on master
}Also still true, re-confirmed: ui.js is a classic defer script so the scheduler is a real window global; core's serving path isn't minified; and virtualization is opt-in (virtualize_transcript), so this is a no-op for nearly everyone.
3. New finding — the guard misclassifies a fix shape core actually wrote
I extracted the real scheduler source from every historical shape of this fix and ran your exact guard predicate (BrowserWindowController.swift:112-115, whitespace-stripped substring test) against each:
| Core scheduler shape | Actually fixed? | Your guard says fixed? | |
|---|---|---|---|
origin/master today |
no | no | ✅ |
d4e4ed3 — reset line deleted outright |
yes | yes | ✅ |
fc7eee3 — reset moved inside a once-per-burst guard |
yes | no | ❌ |
3a449dc — seen-keys burst tracking |
yes | yes | ✅ |
05b6d5b — #6717's current head |
yes | yes | ✅ |
The miss is fc7eee3, a real commit on #6717's own branch history. It fixes #6654 by moving the reset so it fires once per measurement burst instead of on every cycle-key change:
if(!_messageVirtualMeasurementBurstActive){
_messageVirtualMeasurementRetryCount=0; // ← substring still present, but the bug is gone
_messageVirtualMeasurementBurstActive=true;
}Oscillation can no longer renew the budget, so the bug is genuinely fixed — but the literal _messageVirtualMeasurementRetryCount=0 survives, so your guard reads it as "still buggy".
This fails in the safe direction, which is the important part: the shim keeps virtualization disabled, so nobody gets the freeze back. The cost is that the shim would never self-remove — Mac users would silently lose virtualization forever on a fixed core, with no signal. That's the opposite of the failure mode I warned about last time (I worried about re-enabling a buggy virtualizer; the realistic risk is actually a stuck-off shim).
Good news: #6717's current head is classified correctly, so if it lands as-is the shim self-removes exactly as you designed. The blind spot only bites if core lands the burst-guard variant instead.
Suggested hardening (cheap, and it makes the guard match intent rather than text): test for the reset inside the cycle-key branch rather than anywhere in the function — e.g. match !==cycleKey followed by the reset before the closing brace, or simply treat the presence of _messageVirtualMeasurementBurstActive / _messageVirtualMeasurementSeenKeys as a positive "core has the newer burst-tracking fix" signal. Either keeps the safe default while letting the shim actually retire.
What I still can't do from here
Unchanged from my last review and still blocking: Swift can't build on our Linux CI, so this needs a Mac-agent swift build + swift test pass and an independent review posted from the nesquena account before it merges. The LongConversationCompatibilityTests look non-vacuous by reading (they extract the production script from source and exercise all four states in JavaScriptCore), but I have not executed them.
@nesquena — when you get a chance: Mac build/test loop on this branch, please.
Summary
The diagnosis, the shim design, the fail-closed behaviour and the self-removal mechanism are all still right, and the implementation is careful. Three things to change before merge, none structural:
- Reference issue #6654 / PR #6717 in the CHANGELOG, docs and code comment — not #6668, and not the commits I gave you earlier.
- Optionally harden the guard against the burst-guard shape above so the shim can actually retire.
- Mac build/test +
nesquenareview.
Gate: Codex (gpt-5.6-sol) route verified healthy this round; the substantive evidence here is my own harness replicating your guard predicate against five real core scheduler shapes extracted from core's git history, plus live state checks against origin/master and PR #6717. Reviewed at exact head af0b04e10e1f6b611203ed3d4a514ee5362de5db.
The transcript reads window._virtualizeTranscript from every scroll event (_currentMessageVirtualWindow via _scheduleMessageVirtualizedRender), so the getter re-stringified and re-scanned the ~3 KB scheduler source on each read. Cache the verdict per scheduler function identity and reclassify only when the function is replaced. Two new JSC tests pin the read count and the reclassify-on-replace path. Also point the CHANGELOG, code comment and docs at hermes-webui issue #6654 and fix PR #6717 (first shipped in exp-v0.52.374) instead of #6668, and document that the text-match guard fails safe if a later fix leaves the literal reset in place. Co-authored-by: itradesize <100155999+itradesize@users.noreply.github.com>
Maintainer finish at
|
| Core ref | Has #6717? | Shim result |
|---|---|---|
v0.52.113 (current stable channel) |
no | virtualization off ✅ |
exp-v0.52.373 |
no | off ✅ |
exp-v0.52.374 (first with #6717) |
yes | server setting honoured ✅ |
exp-v0.52.379, master |
yes | honoured ✅ |
So the shim is still doing useful work for Mac users on the stable channel who opted into virtualization, and it has already retired itself on experimental and master.
macOS CI. Your fork's original run never started (zero jobs), so I approved the workflow for the new head. swift test on macos-14 passed: 69 tests, 0 failures, including all 7 LongConversationCompatibilityTests (run 36213114251).
Advisor gate. Fable reviewed the full diff and focused on my commit. The cache is correct: user scripts get a fresh closure per document, bfcache keeps the closure and scheduler together, and main-frame-only excludes iframes. Its only blocking item was "no macOS build has ever run", and the green run above covers that.
Branch was 0 behind main, no plist/build.sh/entitlement changes, no new framework imports. Merged with a merge commit so your two commits keep their authorship. The [Unreleased] CHANGELOG heading gets stamped with the version at the next release tag.
Gate: Fable (claude-fable-5-1) on exact head e09877b4f290291db8aa6b132300cd0660131841. Codex was unavailable this round (usage limit), so the adversarial evidence is my own harness: literal-script extraction, five real core scheduler shapes, and three mutation runs. Plus the green macos-14 swift test run.
Fixes the macOS app becoming permanently unresponsive when opening long conversations.
The issue is caused by the WebUI transcript virtualization scheduler repeatedly resetting its retry budget under WKWebView.
This adds a macOS-only compatibility guard that disables virtualization only when the affected scheduler behavior is detected. The server and WebUI deployment are unchanged.
Verified with focused regression tests and the full XCTest suite.