Repository navigation
Description
What happens
On a full-window Rune web page that has gone idle, the first wheel event produces its visible frame ~2 s late — once. The pan/zoom itself is computed and drawn quickly (a screenshot taken 300 ms after the wheel already shows the moved content), but the frame that presents it arrives after a long hole in the frame log. Every wheel after the first is clean at vsync.
Frame gaps around the first wheel (app-instrumented on_frame_drawn deltas, headed Chromium on Apple M2, CPU canvas via RUNE_CPU_FIRST=only):
2.1, 8.3, 32.4, <- pan applies here; a screenshot at +300 ms already shows it
2103.0, <- the hole; nothing presents for ~2.1 s
61.8 <- one more frame, then the app goes idle again
The same one-time hole reproduces on the WebGL2 path, at any scene size (10 to 20,000 nodes; the scene content is irrelevant — it reproduces with a fixed cost of one canvas(Shape) and a handful of els), and after a drag has already warmed the GPU path.
What does not cause it
Tx::instant()after handling the wheel — no change.- The app's own handling:
on_wheelconsumes the event and only mutates twof32s. Moving the wheel handling intoon_magnify(ctrl+wheel) behaves the same. - Fonts: pre-fetching the three Inter faces before
init()does not change it. - A bare 2D-canvas control page (plain
rAFloop +preventDefaultwheel listener) driven with the identical Playwright dispatch shows a worst rAF gap of 21.5 ms — so the dispatch, the browser and the synthetic wheel are not the cause. - Scene size and renderer: identical timing at 100 and 20,000 nodes, on CPU-first and WebGL2.
Reproduce
A minimal harness (cdylib crate, one canvas(Shape) surface with on_wheel/ on_magnify/ on_drag, plus a composer text_input so the web text bridge is live):
git clone https://github.com/ajianaz/rune-web-spike # branch: main, commit c3e264c
cd rune-web-spike
cargo build --target wasm32-unknown-unknown --lib --release
wasm-bindgen --target web --out-dir web --out-name app \
target/wasm32-unknown-unknown/release/spike_canvas.wasm
# serve ./web statically (mime application/wasm), then in a browser:
# click once on the canvas to give it focus, wait ~2 s, wheel onceObserved with Chromium 140 (Playwright build), --enable-unsafe-webgpu, headed, macOS 15 arm64 (Apple M2). The spike records every on_frame_drawn into window.__spikePerf.frames, so the gaps are visible from the page console.
Context
This matters for canvas-style apps (the frame after an idle user's first wheel is the one they see). Suspected neighbour: the deferred-present mechanics documented in #2470 (handover freeze and the WebGL2 completion poll on an 8 ms setTimeout), though this reproduces without a handover on a page that never leaves the CPU canvas.
Happy to test a fix or more diagnostics against the harness above.
Activity
ajianaz commentedon Nov 27, 2026
Repro pushed: https://github.com/ajianaz/rune-web-spike (branch
main, commit9e14b01). Theweb/index.htmlshell and the three Inter faces are committed; the wasm is built from source per the instructions in the issue body.opencodejr commentedon Nov 27, 2026
looked through the web wheel and frame loop (
platform/web.rs,platform/web/input.rs,platform/web/frame.rs,platform/web/bridge.js, and vendored winit's web backend) and didn't find any ~2 s delay or timer on that path: on bothRUNE_CPU_FIRST=onlyand steady-state webgl2,MouseWheelschedules onerequestAnimationFrame, andon_frame_drawnruns synchronously right aftercpu.paint/queue.presentin that same rAF callback (so if a screenshot at +300 ms already shows the pan, that frame'son_frame_drawnalready ran before +300 ms). because rune is demand-driven and draws zero frames while idle, consecutiveon_frame_drawndeltas also span the idle wait itself, unlike a continuous-rAF control page.ajianaz/rune-web-spikereturned 404 (probably private). could you share:performance.now()timestamps for the wheel dispatch,on_wheel, and eachon_frame_drawnaround it, so we can see whether the ~2.1 s delta ist_frame - t_wheel, the ~2 s idle wait before the wheel, or an extra wake ~2.1 s after the pan frame?lib.rsand dispatch snippet if the delay really is after the wheel event?Hona commentedon Nov 27, 2026
ajianaz/rune-web-spikeis accessible now, so I inspected the repro scripts alongside Rune's web wheel and frame loop (crates/rune/src/platform/web.rs,platform/web/input.rs,platform/web/frame.rs,platform/web/handover.rs,platform/web/bridge.js,input/host_events.rs,runtime/web/a11y/schedule.rs, and vendored winit's web backend).What is causing the ~2.1 s delta in the repro
wheel-visual2.mjs(as well asfirst-wheel.mjs,visual-wheel.mjs,zoom-only.mjs, andwarm-gpu.mjs) runspage.waitForTimeout(2000)(plusconst s0 = await page.screenshot()inwheel-visual2.mjs) without clearingwindow.__spikePerf.frames, and then computes consecutive deltasfs[i].t - fs[i - 1].tacross the entire array.Because Rune is demand-driven (
ControlFlow::Wait, drawing zero frames while idle), the[2.1, 8.3, 32.4, 2103.0, 61.8]trace inwheel-visual2.mjsis:2.1, 8.3, 32.4ms — boot frames drawn right after load (initial CPU frame,bridge.jsinit, resize/layout, andfull_facesfont arrival).2103.0ms — the idle period itself (waitForTimeout(2000)+ ~100 mspage.screenshot()) between the last boot frame and the first post-idle input frame (page.mouse.move(720, 450)hovering the.hit()surface).61.8ms — the delta between that hover frame and thepage.mouse.wheel(0, 240)pan frame.That accounts for every symptom reported:
s1) already shows the pan ands1 -> s2does not change: the pan frame already painted and firedon_frame_drawnimmediately on the nextrequestAnimationFrameaftermouse.wheel, and zero frames ran during the second 2 s wait.RUNE_CPU_FIRST=onlyand WebGL2, at 100 or 20,000 nodes, and withTx::instant(): onRUNE_CPU_FIRST=only,GpuStartupandDraw::HandingOvernever run; the ~2 s delta is the idle wait before input.browser-wheel.html) has a 21.5 ms max gap: it runs a continuousrequestAnimationFrame(loop)throughoutwaitForTimeout(2000), so consecutive timestamps never span the idle wait.phone-wheel.mjssaw no ~2 s hole: unlikewheel-visual2.mjs,phone-wheel.mjsclearswindow.__spikePerf.frames.length = 0beforemouse.wheeland measurestFrame - t0directly.What was checked in Rune
WindowEvent::MouseWheel,Running::window_input->host_events::web_wheelqueuesAction::Wheeland returnstrue, which immediately callswindow.request_redraw()->window.requestAnimationFrame.Browser::redraw->host_step::run), Rune steps the runtime, paints (cpu.paintorqueue.present), and callson_frame_drawn(inspect_frame) synchronously before returning.CpuOnlypath nor steady-stateGpuhas a ~2 s timer, rest delay, or deferred-present wait on wheel (web_a11y::scheduleflushes off-rAF without requesting redraws, andpage_fonts::share_laterdoes not request redraws).(Note: this was verified by reading the repro scripts and Rune's web code; the spike harness was not executed locally in a browser.)
If you clear
window.__spikePerf.framesright beforemouse.wheeland measuret_on_frame_drawn - t_wheel_dispatch(using rawperformance.now()timestamps) and still see a ~2 s delay after the wheel event, please share those timestamps and we will dig back in — otherwise this looks like expected demand-driven idle behavior rather than a Rune bug.