Skip to content

Windows: a window that animates while its GPU arrives hands over to it at once - #710

Merged
Hona merged 1 commit into
devfrom
ib-3-handover
Nov 12, 2026
Merged

Hona merged 1 commit into
devfrom
ib-3-handover

Conversation

@Hona

@Hona Hona commented Nov 12, 2026

Copy link
Copy Markdown
Member

During the CPU-to-GPU hand-over (#689), both renderers drew every frame, and the window committed to the GPU only on a turn that found the latest GPU frame finished. An animating window replaced that frame on every frame, so it never found one finished.

  • Seen: on the visible desktop, OpenCode (Rune) handed over late or never in 4 of 6 launches. Its spinner draws every ~40 ms. One launch handed over at 2,045 ms; three never did before quitting at ~1,900 ms. The static probe window always handed over (24 of 24), which is why the merge didn't show it.
  • Change: while handing over, one frame is drawn by both renderers. Nothing more is drawn until the GPU has finished that frame. The turn that finds it done commits, then redraws on the GPU whatever was asked for in between. That's at most one frame's GPU time. A device lost while it waits leaves the window on the CPU.

Checked: cargo check -p rune.

…t at once

During the hand-over both renderers drew every frame, and the commit waited for a turn that found the latest GPU frame finished. An animating window (OpenCode's spinner, a frame every ~40 ms) replaced that frame each time, so the hand-over came 1.6 s late or never (4 of 6 visible-desktop launches). One frame is now drawn by both, nothing more until the GPU has finished it; the turn that finds it done commits and redraws on the GPU. A device lost meanwhile keeps the window on the CPU.
Copilot AI balanced review requested due to automatic review settings November 12, 2026 01:29
@Hona
Hona merged commit 9b2cb52 into dev Nov 12, 2026
1 check passed
@Hona
Hona deleted the ib-3-handover branch November 12, 2026 01:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Hona added a commit that referenced this pull request Nov 12, 2026
… when it's ready

A full-window page no longer waits for WebGPU to draw: the CPU renderer (render::cpu_boot) paints the real view into a 2D canvas under the WebGPU canvas from the module's first frame, and the page is live from it (input, hover, typing and animation on every frame). The WebGPU canvas lies over it, see-through (opacity 0), and takes the input all along. Once the page has drawn nothing for 250 ms (3 s after its first frame at the latest) it asks for the GPU, so the browser makes the adapter and compiles the pipelines after the first frames are up, not while the first one waits to show. Then: a submit after the renderer's pipelines tells when they're built; frames go on drawing into the see-through canvas until every pipeline check has answered; one frame is drawn by both renderers from the same instances; nothing new is drawn until the GPU's is done; then the GPU's canvas shows and the CPU's goes, in one turn (the native hand-over's order, #689/#710/#781). Without WebGPU the page stays on the CPU; a device lost after the hand-over brings the CPU back (the device's glyph masks fill again on the CPU, Atlas::refill_gpu_masks). Pages that are the document or sit inline, and apps with a compositor, start on the GPU as before.

Measured (headless Chromium 1223, 1280x800, rune-desktop's Home): first frame presented 574-916 ms from navigation, was 1,427 on the GPU; the hand-over frame differs from the CPU's in 4,430 of 1,024,000 px by at most 1; a CPU first frame is fill 3 + paint 21 + put 10 ms with wasm SIMD, a typical later frame 0.5 ms.

cpu_boot reads the page's clock (crate::time::Instant). The CPU canvas puts only the changed rectangles, turned into RGBA (wasm SIMD when the build has it) through a buffer in the page's memory (an ImageData over the module's memory took the browser 60-70 ms to put). Rune's marks are the page's performance marks too. globalThis.RUNE_CPU_FIRST = off / only, __runeCpuFrames, __runeDrift and RUNE_LOSE_GPU_AFTER are for measuring harnesses.
Hona added a commit that referenced this pull request Nov 12, 2026
… when it's ready (#809)

* Web: a page draws its first frames on the CPU, and WebGPU takes over when it's ready (WIP)

* Web: a page paints its first frames on the CPU, and WebGPU takes over when it's ready

A full-window page no longer waits for WebGPU to draw: the CPU renderer (render::cpu_boot) paints the real view into a 2D canvas under the WebGPU canvas from the module's first frame, and the page is live from it (input, hover, typing and animation on every frame). The WebGPU canvas lies over it, see-through (opacity 0), and takes the input all along. Once the page has drawn nothing for 250 ms (3 s after its first frame at the latest) it asks for the GPU, so the browser makes the adapter and compiles the pipelines after the first frames are up, not while the first one waits to show. Then: a submit after the renderer's pipelines tells when they're built; frames go on drawing into the see-through canvas until every pipeline check has answered; one frame is drawn by both renderers from the same instances; nothing new is drawn until the GPU's is done; then the GPU's canvas shows and the CPU's goes, in one turn (the native hand-over's order, #689/#710/#781). Without WebGPU the page stays on the CPU; a device lost after the hand-over brings the CPU back (the device's glyph masks fill again on the CPU, Atlas::refill_gpu_masks). Pages that are the document or sit inline, and apps with a compositor, start on the GPU as before.

Measured (headless Chromium 1223, 1280x800, rune-desktop's Home): first frame presented 574-916 ms from navigation, was 1,427 on the GPU; the hand-over frame differs from the CPU's in 4,430 of 1,024,000 px by at most 1; a CPU first frame is fill 3 + paint 21 + put 10 ms with wasm SIMD, a typical later frame 0.5 ms.

cpu_boot reads the page's clock (crate::time::Instant). The CPU canvas puts only the changed rectangles, turned into RGBA (wasm SIMD when the build has it) through a buffer in the page's memory (an ImageData over the module's memory took the browser 60-70 ms to put). Rune's marks are the page's performance marks too. globalThis.RUNE_CPU_FIRST = off / only, __runeCpuFrames, __runeDrift and RUNE_LOSE_GPU_AFTER are for measuring harnesses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants