Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...

    Function waitForNextRender

    • Wait for the next N render frames to complete

      Records the current renderer frame counter and waits until it advances by the specified number of frames. This replaces most waitForTimeout(100-500) calls after user actions (key presses, clicks, etc.) that trigger re-renders.

      Never fails on give-up — falls back to a state-based wait + a short time buffer if the frame counter is unavailable or if the animation loop is idle (auto-paused after inactivity), and returns normally. On a frame-starved page that buffer can be worth one or two frames rather than N. The give-up is not silent: it emits one console.warn naming which branch it took, and the boolean return says the same thing to a caller that wants to react.

      A strict, throwing variant was tried and reverted: the animation controller auto-pauses after ~2s of inactivity and this helper's kick is a single renderOnce(), so a request for several frames on an idle loop cannot be satisfied by construction. Failing there turns the healthy path red, which is exactly why the state-based fallback exists.

      Parameters

      • page: Page

        Playwright page

      • frames: number = 2

        Number of frames to wait for (default: 2)

      • timeout: number = 5000

        Cap on each INDIVIDUAL wait in ms (default: 5000), not on the call: the frame-counter read, the renderOnce() kick and the frame wait are each capped at Math.min(timeout, 3000) and the state fallback at timeout, so a fully starved page costs roughly the sum of those legs.

      Returns Promise<boolean>

      true when the counter was observed to advance by frames, false when the helper gave up and used the fallback.