Skip to content

feat(webview): provide native scale snapshot to page bootstrap #200

Closed

Description

@zackees

Context

FastLED migration PR FastLED/cli#242 still directly owns Tauri because its Windows viewer reads the native window scale factor and applies 0.92 / scale only above 1.0 (crates/fastled-cli/src/tauri_viewer.rs:364). Browser devicePixelRatio is not the same contract. Kernel page bootstrap (#195, PR #197) runs before page code but currently has no native scale snapshot. Native creation already has a dispatcher on the off-UI creation thread; the private backend scale getter synchronously routes a message to the event loop.

Proposal

Provide an immutable creation-time native-window scale snapshot in the trusted caller bootstrap context, before the first document executes. Keep backend handles and queries private. Preserve origin/main-frame guards and script-free default routes. FastLED retains Windows-only zoom arithmetic and DOM policy.

Acceptance criteria

  • Focused RED test for missing bootstrap scale context, then GREEN for finite positive fractional values and invalid-value fallback.
  • Query native scale off the UI thread after creating the window and before scheduling webview creation; no synchronous getter inside its UI closure.
  • Context is available before page code on initial load and same-origin reload, never injected into subframes, and supplies no native IPC or mutable host capability.
  • Existing Linux bootstrap/isolation/teardown proof remains green; native Windows proof and supported-target checks pass before release.
  • FastLED subsequently consumes this context and removes direct viewer implementation dependencies after viewer integration validation.

Decisions

  • P2 migration capability: required to preserve existing Windows behavior, not a request to change zoom defaults.
  • Expose a frozen lexical kernalWindow.initialScaleFactor value to trusted bootstrap source; reserve and document the binding rather than adding a general native eval or IPC API.
  • Snapshot only at creation; moving across monitors later does not update it, matching the current one-time FastLED adjustment.
  • Fall back to 1.0 for query failure or non-finite/non-positive scale, matching the existing app query fallback and preventing invalid JS numeric literals.
  • No new dependency, runtime, public backend type or default-feature GUI activation.

Related issues

Extends #195 (explicit native page bootstrap).

Activity

  1. zackees commented on Sep 16, 2026

    @zackees
    CollaboratorAuthor

    Complete; closing with the evidence.

    kernal-api — the native scale snapshot reaches the page bootstrap. src/tauri.rs reads the window's scale_factor() and threads it into the origin-scoped bootstrap script (script.for_origin(&request.url, dispatcher.scale_factor().unwrap_or(1.0))), with for_origin guarding a non-finite or non-positive value rather than passing it through. The test is bootstrap_exposes_native_scale_snapshot_before_caller_source (src/tauri.rs:1554), whose name states the ordering guarantee this issue is about: the snapshot is present before caller source runs.

    🤖 Generated with Claude Code

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