Repository navigation
[CTX-1791] fix(runtime,render,platform): resolve Hyprland workspace switch freeze and SwashSingle font RSS (#3116) - #3118
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 2 minutes. View limit details
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. |
…witch freeze and SwashSingle font RSS (#3116) - Move pre_present_notify() into Surface::present* right before frame.present() so deferred/skipped ticks never leave winit in FrameCallbackState::Requested without a wl_surface.commit. - Keep FrameCallbackState::Received intact across request_frame_callback(), reset frame_callback_state on resume from XdgWindowState::SUSPENDED, and suppress RedrawRequested while suspended in vendored winit. - Keep speculative_present_reopen open across driver commits into free swapchain slots until compositor confirmation, hold back extra frames while awaiting confirmation, and close the visibility gate back when unconfirmed. - Share Source::File font buffers across SwashSingle instances via SHARED_FONT_FILES and reuse a single scratch probe_buf during scan_dynamic_face(). - Land PR #3113 (PX-8623) review follow-ups and restore component.rs scratch-paths-exempt markers. Priority: P0 | Area: runtime, render, platform | Labels: fix, P0, area:runtime, area:render, area:platform | Milestone: v0.1.0 | RFC: OQ-none | Task: CTX-1791 Closes #3116
10a7104 to
f9e6df2
Compare
|
@coderabbitai review |
Action not completed
|
Xuepoo
left a comment
There was a problem hiding this comment.
Independent review by ctx-1791-reviewer (CarryCtx PX-8626, session 01M732RM4C6BFQ2X2VJ8DPNR75), head f9e6df2:
VERDICT: APPROVE
- Wayland Frame Callback & Suspended Workspace Handling:
pre_present_notify()moved out ofTerminalApp::drive_tickintoSurface::presentandSurface::present_draw_list_color_classifiedimmediately prior toframe.present().- Vendored
winitpreservesFrameCallbackState::Receivedinrequest_frame_callback(), resetsframe_callback_stateon resume fromXdgWindowState::SUSPENDED, and suppressesRedrawRequestedwhile suspended.
- Speculative Blind-Repair Gate Lifecycle:
speculative_present_reopenremains open across swapchain driver commits until compositor confirmation (note_present_confirmed) or explicit reveal, holds back additional frames while awaiting confirmation, and callsrestore_hidden_after_blind_repairwhen unconfirmed.
SwashSingleFont Buffer Deduplication & Scratch Reuse:- Cross-instance weak cache
SHARED_FONT_FILESdeduplicatesArc<Vec<u8>>allocations acrossSwashSingleinstances, andscan_dynamic_facereuses a singleprobe_bufacross uncached candidates.
- Cross-instance weak cache
- PR #3113 (
PX-8623) review follow-ups andcomponent.rsscratch-paths-exemptmarkers verified.
Xuepoo
left a comment
There was a problem hiding this comment.
Independent review — PR #3118 (CTX-1791)
Reviewer: independent third-party review (Hermes Agent subagent, Nous Research) — not the PR author, not the lane owner.
Model: deepseek-v4.1-flash · Date: 2026-11-11 (CST)
Head reviewed: f9e6df2f · Base: main 0acc9a9a · 22 files, +856/−154
Method. The lane worktree was treated as read-only (git status clean, no writes). Every
mutation/discrimination proof ran in a byte-identical copy at
$HOME/.hermes/cache/scratch/r3118-proof with its own CARGO_TARGET_DIR; origin/main was
built separately from git archive origin/main so rendered help could be diffed binary-to-binary
(.target/debug/bitty, 20 surfaces). CI on this head is fully green (gh pr checks 3118:
Linux Wayland 14m34s, Linux X11 20m6s, Windows 35m12s, macOS ARM64 22m5s, MSRV 1m22s,
Quality gates ×2, AUR, CodeQL, supply chain).
1. Help gate still enumerates from crate::cli::SUBCOMMANDS and fails closed — PASS
- Table:
crates/bitty-terminal/src/cli.rs:2817(SUBCOMMANDS, 18 entries). - Gate derives coverage:
crates/bitty-terminal/src/help_width.rs:129→sources()maps every
table entry throughsurface()(help_width.rs:93) and panics on an unregistered name
(help_width.rs:134). Alias resolution is asserted too (help_width.rs:151-173), including the
parser-onlycomponent→extensionalias. - Discrimination proof: in the scratch copy I appended
("frobnicate", &[])toSUBCOMMANDS
and rancargo test -p bitty-terminal --bin bitty help_width:Red in 4 tests (test result: FAILED. 2 passed; 4 failed panicked at crates/bitty-terminal/src/help_width.rs:134:17: help_width: no rendered help surface registered for `bitty frobnicate`every_subcommand_help_surface_is_covered,
every_help_tier_fits_the_documented_width,verbose_tier_differs_and_carries_the_contract,
each_contract_tier_states_its_own_boundary). Probe reverted; tree byte-identical to head again. - On the unmodified head:
cargo test -p bitty-terminal help_width --offline→ 6 passed, 0 failed
(help_width::*, 1521 filtered out, 0.04s).
2. The five residual risks on THIS head — all non-blocking
| # | Risk | Present? | Class |
|---|---|---|---|
| 1 | HELP_WRAP_COLUMNS (96) equals/outside HELP_MAX_COLUMNS (100) |
No — fixed. cli.rs:2886 = 96, help_width.rs:30 = 100, and help_width.rs:35-38 is a const assert HELP_WRAP_COLUMNS <= HELP_MAX_COLUMNS that fails compilation if it regresses. |
resolved |
| 2 | push_wrapped_line collapses internal space runs; shell-init nushell row loses alignment |
No. The nushell row is hand-wrapped, not passed through the helper (shell_init.rs:475-495), and the continuation (then \source` it from config.nu)starts at column 15 — the same value column as bash: . Both helper callers pass single-spaced input (cli.rs:2962, x.rs:322), so split_whitespace` is lossless in practice. |
cosmetic |
| 3 | No post-wrap re-check of indent+word → an 81-col token under a 20-space indent renders 101 cols | Narrower form only. Tokens are hard-split to max - width (cli.rs:2923-2937), so no token escapes. But the head prefix is never measured: a legal 121-char plugin id (validate_plugin_id allows 2×64 [a-z0-9_-], bitty-plugin-host/src/manifest.rs:40,134-191) renders 135 columns at x.rs:317-328 and hard-splits the first command one character per line (probe test in scratch copy: over_wide=[(12, 135)]). Pre-existing on main (no wrapping at all there), so not a regression. |
cosmetic (edge) |
| 4 | Gate maps help→help_help_text() and x→bundled catalog, so "18 surfaces" overstates coverage |
Yes. help_width.rs:115 measures help_help_text() (only reachable as bitty help help); bitty help --help and bitty --help render help_text_short() instead. help_width.rs:113 measures x_help_text() (safe mode) while bitty x --help calls x_help_text_with_store() (main.rs:593). Same renderer (x_help_text_for), so only the row set differs — and the synthetic wide-row test covers that (help_width.rs:287-309). |
cosmetic |
| 5 | columns() counts scalars, so CJK/emoji under-count |
Code present (help_width.rs:56-58), no live exposure. All 20 rendered surfaces contain exactly one non-ASCII code point per title: U+2014 EM DASH, east_asian_width=A (1 column). Measured unicode-aware widths equal scalar widths everywhere. |
cosmetic |
Measured rendered widths (head binary, --help)
| surface | max | surface | max | surface | max |
|---|---|---|---|---|---|
| run | 87 | list | 91 | version | 81 |
| ctl | 90 | ls | 91 | completion | 99 |
| config | 79 | inspect | 96 | cmd | 76 |
| init | 94 | dev | 98 | x | 69 |
| doctor | 75 | plugin | 96 | shell-init | 98 |
| upgrade | 73 | extension | 100 | help (bitty help help) |
89 |
| reload | 85 | bitty --help / bitty help --help |
109 |
-v tiers (6): ctl 90, plugin 96, inspect 96, dev 98, extension 100, list 91 — all ≤ 100.
Lines over 100 columns on this head: exactly one, and it is not in the gate:
bitty --help line 28 = 109 columns, crates/bitty-terminal/src/cli.rs:2782
( list <kind> Enumerate themes|…|services (alias ls)). Identical on origin/main
(109), so pre-existing; it is the one real over-wide line in the product and it is outside the
measured set because help is registered as help_help_text() (risk 4).
3. plugin_runtime::rollback() class reset — PASS
- Reset:
crates/bitty-runtime/src/plugin_runtime/mod.rs:4768. - Every reader traced.
failure_classhas exactly one reader —
recover_wall_failed_plugins(mod.rs:3731, filter atmod.rs:3747). It has four writers:
insert (mod.rs:2787), successful activation (mod.rs:3434),fail_runtime_classified
(mod.rs:4727), and the new reset (mod.rs:4768). There is no reporting/diagnostic reader, so no
path loses a verdict for display. - No typed verdict is lost. The only producer of
WallSliceTimeoutis
fail_runtime_on_suspend(mod.rs:4738-4746, fed by the timer pump atmod.rs:2370,2413),
which callsfail_runtime_classified→rollback(mod.rs:4721) → re-stamps the class on
the next statement (mod.rs:4727). Every otherrollbackcaller is an activation/validation
error with noSuspendReasonin hand, whereUnclassifiedis the correct verdict. - No deterministic failure is now retried — the opposite: pre-fix, a generation that once hit a
wall slice keptWallSliceTimeoutacross a later plain Lua error and was auto-retried. Post-fix
the class is cleared,recover_wall_failed_pluginsselects nothing, and the test at
mod.rs:5701pins it.wall_recovery_attemptsis deliberately not reset (asserted at
mod.rs:5746), so the budget still counts real wall failures. - Revert proof (scratch copy, reset line deleted, everything else untouched):
Restored →
test plugin_runtime::tests::rollback_clears_the_previous_failure_class ... FAILED panicked at crates/bitty-runtime/src/plugin_runtime/mod.rs:5743:9: assertion `left == right` failed: a rollback must not inherit the previous generation's wall class left: WallSliceTimeout right: Unclassifiedcargo test -p bitty-runtime rollback --offline→ 6 passed, 0 failed. - Note (non-blocking): the proof is a white-box field assertion. The companion integration test
(tests/plugin_timers.rs:519-555) was also strengthened in this PR (fixture body rewritten so a
retry would succeed, closing the "passes for the wrong reason" hole), but it does not itself
depend on the reset.
4. list.rs compact/verbose — PASS
Binary diff of bitty list --help and bitty ls --help, head vs origin/main:
######## list (1 diff line)
43d42
< Version: 0.0.39
######## ls (3 diff lines)
1c1
< bitty list — enumerate resources (local or runtime)
---
> bitty ls — enumerate resources (local or runtime)
43d42
< Version: 0.0.39
Exactly the two permitted deltas and nothing else — alias-aware title (list.rs:404) and the
removed compact Version: line. -v still carries it: bitty list --help -v line 44 =
Version: 0.0.39 (list.rs:453), placed between the body and the contract tier, so
verbose.starts_with(compact) still holds (help_width.rs:230).
5. The #3116 half — PASS on code, implemented-only on evidence
Addressed in code, all three layers:
- Ordering:
pre_present_notify()removed fromTerminalApp::drive_tick
(terminal_app.rs:2415-2422) and called immediately beforeframe.present()in both render
paths —gpu.rs:1654(present) andgpu.rs:1963(present_draw_list_color_classified) — via
a defaulted, cross-platform trait method (bitty-platform/src/surface.rs:117,157,256). Every
wl_surface.framerequest is now issued when state isNoneand is immediately followed by a
commit. - winit:
request_frame_callback()no longer re-arms fromReceived
(vendor/winit/.../window/state.rs:253-262),frame_callback_stateis reset on
SUSPENDED→resumed (state.rs:293-301), andRedrawRequestedis suppressed while suspended
(event_loop/mod.rs:513-516). The match overFrameCallbackStatestays exhaustive over its
three variants (no#[non_exhaustive]), so there is no sentinel constant and no
unreachable_patternssuppression. Patch hash and tree digest invendor/winit/PATCHES.md
verify:sha256(patch 0003)=82a2948…and the tree digest7304ebac…both recompute exactly;
scripts/check-vendored-winit.sh→ OK. - Runtime gate:
speculative_present_reopenis no longer cleared by a driver commit
(present.rs:8146-8152, 8652-8656); frames are held back while the blind repair awaits
confirmation (present.rs:2336, 3552); the gate closes back on an unconfirmed repair
(present.rs:2470). The wake is real, not self-healing by luck:present_confirm_wake()
(terminal_app.rs:1597-1603) is joined intoAboutToWait(pinned by
tests.rs:1146 about_to_wait_arms_the_present_confirm_deadline), so the deadline is guaranteed
to fire even whilepresent_owed()is false. - RSS:
SHARED_FONT_FILESweak cache +probe_bufreuse (shaped.rs:206-222, 496-556, 1021-1117) are real; the new test provesArc::ptr_eqacross twoSwashSingleinstances and
that a scan miss retains nothing.
Platform-cfg correctness: clean. The diff adds zero cfg(...) attributes (grep over
origin/main...HEAD), so there is no definition whose only consumer is cfg(target_os="linux");
SurfaceSource::pre_present_notify has a no-op default for headless fakes and the wgpu consumer is
unconditional. CI Windows (35m) and macOS ARM64 (22m) both pass.
Assertions the code does not support (flagging, all non-blocking):
- "resolve the Hyprland workspace switch freeze" — no automated repro exists for the freeze.
The only new test (present.rs:14535 a_committed_blind_repair_that_stays_unconfirmed_closes_the_gate_again)
covers the runtime gate, not the winit/ordering change; the PR body carries no manual
Hyprland validation record. This half isimplemented-only. - "SwashSingle font RSS optimization" — no before/after RSS numbers anywhere in the PR body.
The in-code claim "[heap]RSS stays at ~167 MiBPrivate_Dirty" (shaped.rs:1028) is a
measurement that no test or CI job reproduces; the test proves sharing, which is necessary
but not sufficient for the RSS claim. - "the default
--helpoutput is unchanged fromorigin/main" (list.rs:449-451) is false
as written —origin/mainprintsVersion: 0.0.39in the compact body and this head does not.
The removal is intended (see check 4); the comment's justification is not. - Cosmetic:
SurfaceKind::Gpu.targetstill carries#[allow(dead_code)]with the comment "Keep
the window alive" (gpu.rs:971-973) although the field is now the notify handle. Stale.
6. MSRV 1.85 — PASS
$ cargo +1.85 check -p bitty-terminal -p bitty-runtime --offline
Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.78s
MSRV_EXIT=0
No let-chains in the new code (the const assert at help_width.rs:35-38 is a plain
assert! in const context, legal on 1.85; HELP_WRAP_COLUMNS is also read at runtime by
push_wrapped_line, so it is not const-eval-only).
7. Gates — PASS
$ cargo fmt --all -- --check → exit 0 (no output)
$ cargo clippy -p bitty-terminal -p bitty-runtime --tests --offline -- -D warnings
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.36s → exit 0
$ cargo test -p bitty-terminal help_width --offline
test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 1521 filtered out
$ cargo test -p bitty-runtime rollback --offline
test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 1556 filtered out
$ ./scripts/check-scratch-paths.sh → scratch-paths: OK
$ ./scripts/check-vendored-winit.sh → tree digest and patch hash match
just check soak was not run (host-speed-sensitive; every gate it aggregates that this PR can
move — fmt, clippy, MSRV, vendored-winit, scratch-paths, help_width, rollback — was run
individually above, and the CI Quality gates (1)/(2) jobs pass on this head).
Residual risks (all non-blocking)
bitty --helprenders 109 columns (cli.rs:2782) and is not measured by the gate because
helpis registered ashelp_help_text()(help_width.rs:115). Pre-existing on main. —
cosmetic (coverage)bitty x --helphead prefix is unbounded: a legal ~120-char plugin id renders 135 columns
and hard-splits a command one char per line (x.rs:317-328,cli.rs:2923-2937). Pre-existing
shape (main rendered it unwrapped), and the PR strictly improves the common case. —
cosmetic (edge)columns()counts scalars (help_width.rs:56): correct today (only U+2014 appears), but a
wide-glyph plugin id would under-count. — cosmetic- Hyprland freeze fix is unverified by test (see 5.1); the
pre_present_notify()call moved
from the event-loop thread to the presenter thread for the async path (gpu.rs:1963), which the
PR body does not discuss. Needs one manual workspace-switch soak on Hyprland before/after
release. — non-blocking, manual validation owed - RSS claim unmeasured (see 5.2); the dedup is real, the MiB figure is not reproduced. —
non-blocking, measurement owed - A slow-but-visible compositor can be treated as hidden: an unconfirmed blind repair closes
the gate (present.rs:2470) even if the surface is actually mapped, costing one
HIDDEN_REPAIR_INTERVAL_MScycle. Bounded and self-healing (hidden_repair_deadline), but it is
a new failure mode introduced by the stricter "commit ≠ confirmation" rule. — non-blocking - False code comment at
list.rs:449-451("unchanged fromorigin/main");ctlandreload
still printVersion:in their compact bodies, so the "version belongs to-v" tiering is not
applied consistently. — cosmetic #[allow(dead_code)]on the now-usedSurfaceKind::Gpu.target(gpu.rs:971-973). — cosmetic
Bottom line
All seven checks pass on f9e6df2f. The gate is genuinely table-derived and provably fails closed;
the five prior residual risks are either fixed or reduced to cosmetics; the rollback reset is
correct against every reader and is proven by a revert; the CTX-1788 follow-ups (help_width gate,
alias-aware list title, Version tiering, rollback class reset, scratch-path markers) are all
present and behave as described. The #3116 half is coherent, platform-clean and CI-green, but its
central claim (no more workspace-switch freeze) rests on design reasoning rather than a test or a
recorded manual repro — worth one manual Hyprland soak, not a merge blocker.
VERDICT: APPROVE
Priority: P0 | Area: runtime, render, platform | Labels: fix, P0, area:runtime, area:render, area:platform | Milestone: v0.1.0 | RFC: OQ-none | Task: CTX-1791
Closes #3116
Summary
pre_present_notify()out ofTerminalApp::drive_tickand intoSurface::present/Surface::present_draw_list_color_classifiedimmediately beforeframe.present()so ticks that defer or skip presenting never leavewinitinFrameCallbackState::Requestedwithout awl_surface.commit.winit: preserveFrameCallbackState::Receivedinrequest_frame_callback(), resetframe_callback_statewhen resuming fromXdgWindowState::SUSPENDED, and suppressRedrawRequestedwhilewindow.is_suspended().Runtime.speculative_present_reopenopen across swapchain driver commits until compositor confirmation (note_present_confirmed) or explicit reveal, hold back additional frames while the single blind-repair frame awaits confirmation, and callrestore_hidden_after_blind_repairwhen unconfirmed.SwashSingleFont Heap RSS Optimization:Source::Filefont byte allocations (Arc<Vec<u8>>) acrossSwashSingleinstances via process-wide weak cacheSHARED_FONT_FILES.probe_buf: Vec<u8>across uncached file candidates duringSwashSingle::scan_dynamic_faceand promote only the matching face intoArc<Vec<u8>>.PX-8623) Review Follow-ups:entry.failure_classonPluginRuntime::rollback, rewrite plugin body beforerecover_wall_failed_plugins()inplugin_timers, derivehelp_widthcoverage fromcli::SUBCOMMANDS, and restorescratch-paths-exemptmarkers incomponent.rs.