alyssaxuu/screenity · error · Error

offscreen-busy-recorder

offscreen-busy-recorder

Error message

offscreen-busy-recorder

What it means

Sentinel error from ensureRemuxOffscreenImpl: after walking the full waitDelaysMs backoff sequence, an OFFSCREEN_DOCUMENT still exists — it is occupied by the recorder. Chrome allows only one offscreen doc and the code deliberately never displaces the recorder (closing it would kill the capture and abort TUS finalize), so remuxing cannot start right now.

Source

Thrown at src/pages/Background/offscreen/ensureRemuxOffscreen.js:51

  // in-editor BufferTarget fallback. We never displace the recorder ourselves:
  // closing it mid-capture kills the recording and aborts TUS finalize.
  const waitDelaysMs = [0, 500, 1000, 1500, 2000, 2000];
  for (let i = 0; i < waitDelaysMs.length; i += 1) {
    if (waitDelaysMs[i] > 0) {
      await new Promise((r) => setTimeout(r, waitDelaysMs[i]));
    }
    const contexts = await chrome.runtime.getContexts({});
    const existing = contexts.find(
      (c) => c.contextType === "OFFSCREEN_DOCUMENT",
    );
    if (!existing) break;
    const existingUrl =
      typeof existing.documentUrl === "string" ? existing.documentUrl : "";
    if (existingUrl.endsWith(REMUX_OFFSCREEN_URL)) return;
    if (existingUrl.includes("offscreenrecorder.html")) {
      // Recorder still closing; wait and retry. Give up only on the last try.
      if (i === waitDelaysMs.length - 1) {
        throw new Error("offscreen-busy-recorder");
      }
      continue;
    }
    // A different offscreen (audio beep / upload resume): close it and proceed.
    try {
      await chrome.offscreen.closeDocument();
    } catch (err) {
      console.warn("ensureRemuxOffscreen: closeDocument failed", err);
    }
    break;
  }

  try {
    await chrome.offscreen.createDocument({
      url: REMUX_OFFSCREEN_URL,
      reasons: ["WORKERS"],
      justification:
        "Re-mux fragmented MP4 recording to standard MP4 using a worker that writes to OPFS via a sync access handle.",

View on GitHub (pinned to 512606387b)

Solutions

  1. Retry ensureRemuxOffscreen after the recording finishes and the recorder closes its offscreen doc
  2. Signal the recorder to close the offscreen document only after capture ends, then retry
  3. Queue the remux request and drain it when the OFFSCREEN_DOCUMENT context disappears
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at src/pages/Background/offscreen/ensureRemuxOffscreen.js:51 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of alyssaxuu/screenity@512606387b (2026-09-02). Data as JSON: /api/errors/89196e0842117441. Report an issue: GitHub.