Skip to content

Embedding: frames that depend only on the time they're drawn for #420

Done

Description

@michael-dm

Why: live video tools draw on-air graphics (lower thirds, scorebugs, tickers) as HTML in an embedded Chromium, which costs a browser per graphic and runs on its own clock. Rune rendering straight onto the video pipeline's wgpu device would be a far lighter replacement. That use needs frames driven by the host's clock, and no stalls or crashes on air.

  • Presentation depends on history. An element that moved since the last frame draws at fractional pixels, and one at rest snaps to whole pixels. Text under a scale re-rasterizes shortly after the scale stops changing. So the frame at t after a seek differs from the frame at t in continuous playback.
  • Rotation can't be bound live the way offset, scale and opacity can. An animated rotation rebuilds the view every frame and eases through the layout spring, so the result depends on the frame rate.
  • rune-luau reads the wall clock. os.clock, os.time, os.date and math.random's seed come from the machine, so the same script replayed for the same time can draw differently.
  • Some pipelines are built mid-animation. Layer blur, backdrop blur and the outline-text shader are built inside the first frame that needs them, which stalls that frame. prewarm_gpu warms Rune's own devices, not a renderer on a host's device.
  • A failed script shows the debug card, with its traceback and Reload button. A host showing graphics to an audience has no way to choose what appears instead.

Activity

  1. michael-dm commented on Nov 10, 2026

    @michael-dm
    Author

    More of the same, found since:

    • Text in deterministic mode steps a whole pixel. With snapping off, text still lays out from a rounded baseline, so slow text jumps a pixel every few frames while its box slides. Gliding by the position's fraction, in snapping's quarter-pixel phases, fixes it.
    • A Gaussian blur reads differently after a seek. The layer pool lends any spare up to twice the layer's area, and the hardware filter rounds by texture size, so the result depends on which earlier frame allocated the texture: up to 42 bytes apart at 1.5× and 2×. Giving a layer read between texels exactly its bucket fixes it.
    • A text whose scale stops moving draws one more frame from outlines while its atlas masks are placed, so the frame it lands on depends on whether the frame before it moved.
    • text::measure uses the fonts of the last TextSystem made. With a graphic's runtime beside the host window's, a font only the graphic has isn't found: Rune enumerates the system's fonts for it, a 1 s frame on air, then measures with fallback metrics.
    • An unknown prop is dropped silently, so a misspelled opacty renders the node fully opaque.

    And what a host driving Rune from outside needed:

    • text::DEFAULT_FONTS is private, so a host passing its own fonts has to load a copy of Inter from disk to keep it.
    • Script::render_fn draws the error card on failure. A host keeping the last good tree on air needs one render's Result<El, ScriptError>.
    • Layout runs only inside a frame. A host animating boxes itself (live_rect) needs layout at each action's time, several per frame, and every keyed element's laid-out box.
    • A native surface can't show a wgpu::Texture from the host's device, only CPU bytes or platform buffers.
  2. Hona commented on Nov 24, 2026

    @Hona
    Member

    The live rotation piece is now on dev in #1912 (3864fce): El::live_rotation binds clockwise rotation in radians about El::origin to &Live<f32>, Live::smooth, or &Tween<f32> without rebuilding or laying out the view.

    let angle = rune::Live::new(0.0_f32);
    let needle = rune::el().size(4.0, 42.0).origin(0.5, 1.0).live_rotation(&angle);
    angle.set(std::f32::consts::FRAC_PI_4);

    This follows Rune's existing El::live_scale / El::live_offset / El::rotate API shape and prop::ROTATION scene track (see examples/live-values for the rotating needle demo). Verified with headless tests on Windows and macOS plus wasm32 WebGPU and WebGL checks; a live desktop window and a Linux build were not run.

    Leaving this issue open for the remaining items:

    • Deterministic pixel-snapping, blur-bucket, and outline-text settle mode
    • Luau virtual clock, deterministic math.random, and unknown-prop errors
    • Script::try_render_fn returning Result<El, ScriptError>
    • Public text::DEFAULT_FONTS and per-runtime text::measure font resolution
    • Off-frame layout queries
    • Host-device GPU pipeline prewarm
    • wgpu::Texture backing for NativeSurface
  3. opencodejr commented on Nov 25, 2026

    @opencodejr
    Contributor

    Thanks for the detailed write-up and the follow-up list. The use case is clear, and each item names a specific gap.

    Where things stand on dev:

    • Live rotation is done: El::live_rotation (feat(live): add El::live_rotation and support wrapped/truncated live_text without panicking #1912).
    • Still open: in rune-text, DEFAULT_FONTS is still pub(crate). In rune-luau, I found no render call that returns Result<El, ScriptError>, and a failed render still draws the error card (card.rs). prewarm_gpu / prewarm_gpu_on only warm Rune's own backends, not a renderer on a host's device.
    • The rest also looks open: deterministic snapping, blur and text settling; the Luau virtual clock and seeded math.random; errors for unknown props; text::measure per runtime; layout outside a frame; and NativeSurface showing a wgpu::Texture.

    I'll treat this as a feature request and look at the remaining pieces, starting with the smaller, self-contained ones.

  4. opencodejr commented on Nov 25, 2026

    @opencodejr
    Contributor

    I opened a PR for the last point here: Script::try_render_fn renders a script function once and returns Result<El, ScriptError> instead of drawing the error card, so a host can keep its last good tree on screen or draw its own fallback. It hasn't been compiled or tested yet; the PR says so. The other points (presentation history, the Luau clock, pipeline prewarming and the follow-ups) aren't covered.

    Fixed in #2168.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions