{"record":{"id":"0d2f437050c5e0da","repo":"zed-industries/zed","slug":"drawing-canvas-text-error","errorCode":null,"errorMessage":"drawing Canvas text: {error:?}","messagePattern":"drawing Canvas text: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_web/src/canvas_text.rs","lineNumber":172,"sourceCode":"        }\n        if canvas.canvas.width() != width {\n            canvas.canvas.set_width(width);\n        }\n        if canvas.canvas.height() != height {\n            canvas.canvas.set_height(height);\n        }\n        canvas.configure(css_font)?;\n        canvas\n            .context\n            .clear_rect(0.0, 0.0, f64::from(width), f64::from(height));\n        canvas\n            .context\n            .fill_text(\n                text,\n                -f64::from(bounds.origin.x.0) + f64::from(subpixel_offset.0),\n                -f64::from(bounds.origin.y.0) + f64::from(subpixel_offset.1),\n            )\n            .map_err(|error| anyhow!(\"drawing Canvas text: {error:?}\"))?;\n        let image = canvas\n            .context\n            .get_image_data(0.0, 0.0, f64::from(width), f64::from(height))\n            .map_err(|error| anyhow!(\"reading Canvas text raster pixels: {error:?}\"))?;\n        let mut pixels = image.data().0;\n        ensure!(\n            pixels.len() == byte_count,\n            \"Canvas text raster returned {} bytes, expected {byte_count}\",\n            pixels.len()\n        );\n        if color {\n            for pixel in pixels.chunks_exact_mut(4) {\n                pixel.swap(0, 2);\n            }\n            Ok(pixels)\n        } else {\n            let mut alpha = Vec::new();\n            alpha","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/zed-industries/zed/blob/916fc2b8cb3a815cbef4a3b40e13081be72036b6/crates/gpui_web/src/canvas_text.rs#L154-L190","documentation":"Thrown in rasterize() when OffscreenCanvasRenderingContext2d::fill_text returns a rejected promise while drawing the glyph run onto the shared text canvas, after configure() and clear_rect succeeded. The browser refused to render the text — typically because the 2D context became invalid or a browser-internal draw failure occurred — so no pixel data exists yet and the rasterization of this text run fails for the caller.","triggerScenarios":"Thrown at crates/gpui_web/src/canvas_text.rs:172 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the rasterization once, optionally after recreating the OffscreenCanvas, since the failure is often a transient context error","Fall back to an empty/blank raster for this glyph so rendering degrades instead of breaking the whole frame","Log the JsValue via js_sys::Error::from to capture the browser-side reason before falling back","Reuse the canvas-wide validation already in place (finite subpixel offsets, size/pixel caps) to rule out caller-side inputs before retrying"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"916fc2b8cb3a815cbef4a3b40e13081be72036b6","analyzedAt":"2026-09-19T19:09:50.599Z","contentChangedAt":"2026-09-19T19:09:50.599Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}