{"record":{"id":"0514307a55a6bada","repo":"tonhowtf/omniget","slug":"canvas-2d-ctx-null","errorCode":null,"errorMessage":"canvas 2d ctx null","messagePattern":"canvas 2d ctx null","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/routes/study/course/[id]/lesson/[lid]/+page.svelte","lineNumber":828,"sourceCode":"    return s\n      .replace(/[\\/\\\\:*?\"<>|]/g, \"_\")\n      .replace(/\\s+/g, \"_\")\n      .slice(0, 60);\n  }\n\n  async function captureScreenshot() {\n    if (!videoRef || !lesson) return;\n    if (!videoRef.videoWidth || !videoRef.videoHeight) {\n      screenshotToast = \"Vídeo ainda não carregou\";\n      setTimeout(() => (screenshotToast = \"\"), 2400);\n      return;\n    }\n    try {\n      const canvas = document.createElement(\"canvas\");\n      canvas.width = videoRef.videoWidth;\n      canvas.height = videoRef.videoHeight;\n      const ctx = canvas.getContext(\"2d\");\n      if (!ctx) throw new Error(\"canvas 2d ctx null\");\n      ctx.drawImage(videoRef, 0, 0, canvas.width, canvas.height);\n      const blob: Blob = await new Promise((resolve, reject) => {\n        canvas.toBlob(\n          (b) => (b ? resolve(b) : reject(new Error(\"toBlob null\"))),\n          \"image/png\",\n        );\n      });\n      const ts = fmtTimestamp(videoRef.currentTime);\n      const filename = `${safeForFilename(lesson.title || \"aula\")}-${ts}.png`;\n      const url = URL.createObjectURL(blob);\n      const a = document.createElement(\"a\");\n      a.href = url;\n      a.download = filename;\n      document.body.appendChild(a);\n      a.click();\n      document.body.removeChild(a);\n      setTimeout(() => URL.revokeObjectURL(url), 1000);\n      screenshotToast = `Screenshot salva (${ts})`;","sourceCodeStart":810,"sourceCodeEnd":846,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src/routes/study/course/[id]/lesson/[lid]/+page.svelte#L810-L846","documentation":"Guard in captureScreenshot: canvas.getContext('2d') returned null, meaning the browser refused to create a 2D rendering context (typically resource exhaustion or an unusable canvas size), so the video frame cannot be drawn and exported.","triggerScenarios":"Thrown at src/routes/study/course/[id]/lesson/[lid]/+page.svelte:828 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry after freeing GPU/memory resources (close other tabs or heavy media sessions)","Cap canvas dimensions to a reasonable maximum before requesting the context","Fall back to an offscreen canvas or a library-based frame capture if the 2D context is unavailable"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}