{"record":{"id":"89196e0842117441","repo":"alyssaxuu/screenity","slug":"offscreen-busy-recorder","errorCode":"offscreen-busy-recorder","errorMessage":"offscreen-busy-recorder","messagePattern":"offscreen-busy-recorder","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/pages/Background/offscreen/ensureRemuxOffscreen.js","lineNumber":51,"sourceCode":"  // in-editor BufferTarget fallback. We never displace the recorder ourselves:\n  // closing it mid-capture kills the recording and aborts TUS finalize.\n  const waitDelaysMs = [0, 500, 1000, 1500, 2000, 2000];\n  for (let i = 0; i < waitDelaysMs.length; i += 1) {\n    if (waitDelaysMs[i] > 0) {\n      await new Promise((r) => setTimeout(r, waitDelaysMs[i]));\n    }\n    const contexts = await chrome.runtime.getContexts({});\n    const existing = contexts.find(\n      (c) => c.contextType === \"OFFSCREEN_DOCUMENT\",\n    );\n    if (!existing) break;\n    const existingUrl =\n      typeof existing.documentUrl === \"string\" ? existing.documentUrl : \"\";\n    if (existingUrl.endsWith(REMUX_OFFSCREEN_URL)) return;\n    if (existingUrl.includes(\"offscreenrecorder.html\")) {\n      // Recorder still closing; wait and retry. Give up only on the last try.\n      if (i === waitDelaysMs.length - 1) {\n        throw new Error(\"offscreen-busy-recorder\");\n      }\n      continue;\n    }\n    // A different offscreen (audio beep / upload resume): close it and proceed.\n    try {\n      await chrome.offscreen.closeDocument();\n    } catch (err) {\n      console.warn(\"ensureRemuxOffscreen: closeDocument failed\", err);\n    }\n    break;\n  }\n\n  try {\n    await chrome.offscreen.createDocument({\n      url: REMUX_OFFSCREEN_URL,\n      reasons: [\"WORKERS\"],\n      justification:\n        \"Re-mux fragmented MP4 recording to standard MP4 using a worker that writes to OPFS via a sync access handle.\",","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/alyssaxuu/screenity/blob/512606387b8d07dda5e63bb428bd063f0a2a3ed0/src/pages/Background/offscreen/ensureRemuxOffscreen.js#L33-L69","documentation":"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.","triggerScenarios":"Thrown at src/pages/Background/offscreen/ensureRemuxOffscreen.js:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry ensureRemuxOffscreen after the recording finishes and the recorder closes its offscreen doc","Signal the recorder to close the offscreen document only after capture ends, then retry","Queue the remux request and drain it when the OFFSCREEN_DOCUMENT context disappears"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"512606387b8d07dda5e63bb428bd063f0a2a3ed0","analyzedAt":"2026-09-02T20:59:09.419Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}