{"record":{"id":"bc6894038c0ef7f5","repo":"iced-rs/iced","slug":"read-from-font-system","errorCode":null,"errorMessage":"Read from font system","messagePattern":"Read from font system","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graphics/src/compositor.rs","lineNumber":70,"sourceCode":"\n    /// Loads a font from its bytes.\n    fn load_font(&mut self, font: Cow<'static, [u8]>) -> Result<(), font::Error> {\n        crate::text::font_system()\n            .write()\n            .expect(\"Write to font system\")\n            .load_font(font);\n\n        // TODO: Error handling\n        Ok(())\n    }\n\n    /// Lists all the available font families.\n    fn list_fonts(&mut self) -> Result<Vec<font::Family>, font::Error> {\n        use std::collections::BTreeSet;\n\n        let font_system = crate::text::font_system()\n            .read()\n            .expect(\"Read from font system\");\n\n        let families = BTreeSet::from_iter(font_system.families());\n\n        Ok(families.into_iter().map(font::Family::name).collect())\n    }\n\n    /// Presents the [`Renderer`] primitives to the next frame of the given [`Surface`].\n    ///\n    /// [`Renderer`]: Self::Renderer\n    /// [`Surface`]: Self::Surface\n    fn present(\n        &mut self,\n        renderer: &mut Self::Renderer,\n        surface: &mut Self::Surface,\n        viewport: &Viewport,\n        background_color: Color,\n        on_pre_present: impl FnOnce(),\n    ) -> Result<(), SurfaceError>;","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/iced-rs/iced/blob/2cffa99b395d84fe469b44dccb56bbacd2f1a157/graphics/src/compositor.rs#L52-L88","documentation":"`Compositor::list_fonts` snapshots family names from the global font system under a read lock; `.expect(\"Read from font system\")` fires only when the RwLock is poisoned by a prior panic under one of its guards. This path serves the debug/devtools UI that enumerates installed families.","triggerScenarios":"Opening the font list in iced's debug tooling (beacon/devtools) or calling list_fonts after the shared font-system lock was poisoned by an earlier text-pipeline panic; concurrently with load_font writes on a poisoned lock.","commonSituations":"Debug UI introspecting fonts during a session where a render thread already panicked inside layout/shaping; hot font loading combined with a swallowed first panic.","solutions":["Trace the first panic that poisoned the font-system lock — the read failure is downstream","Recover from poison: `read().unwrap_or_else(PoisonError::into_inner)`","Load fonts before starting threads that lay out text, so the lock is effectively uncontended","Keep the debug/devtools UI off in sessions where you are diagnosing text panics"],"exampleFix":"// before\nlet font_system = crate::text::font_system().read().expect(\"Read from font system\");\n// after\nlet font_system = crate::text::font_system()\n    .read()\n    .unwrap_or_else(std::sync::PoisonError::into_inner);","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enumerate fonts from the main thread before rendering starts, not from tooling mid-session","Any earlier panic under the font-system lock poisons it — resolve that first panic","Avoid mixing font loads and font listing concurrently during startup","Maintainers: unwrap_or_else(PoisonError::into_inner) keeps listing functional after poisoning"],"tags":["rust","iced","graphics","font","cosmic-text","rwlock","lock-poisoning","panic"],"backgroundTag":"lock-poisoned","analyzedSha":"2cffa99b395d84fe469b44dccb56bbacd2f1a157","analyzedAt":"2026-08-16T19:41:49.083Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}