{"record":{"id":"bb6b24f9f9b0ffb4","repo":"slint-ui/slint","slug":"frame-throttle-must-be-created-on-main-thread","errorCode":null,"errorMessage":"frame throttle must be created on main thread","messagePattern":"frame throttle must be created on main thread","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backends/winit/frame_throttle/apple_display_link.rs","lineNumber":117,"sourceCode":"\n#[cfg(target_os = \"macos\")]\npub(super) fn try_create(\n    window_adapter: Weak<WinitWindowAdapter>,\n    winit_window: &winit::window::Window,\n) -> Option<Box<dyn super::FrameThrottle>> {\n    use objc2::runtime::AnyClass;\n    use objc2::sel;\n    use objc2_app_kit::NSView;\n    use raw_window_handle::{HasWindowHandle, RawWindowHandle};\n\n    // -[NSView displayLinkWithTarget:selector:] is only available on macOS\n    // 14.0+. The CADisplayLink class itself is reachable on older macOS via\n    // QuartzCore, so check for the selector instead of the class.\n    if !AnyClass::get(c\"NSView\")?.responds_to(sel!(displayLinkWithTarget:selector:)) {\n        return None;\n    }\n\n    let mtm = MainThreadMarker::new().expect(\"frame throttle must be created on main thread\");\n\n    let RawWindowHandle::AppKit(handle) = winit_window.window_handle().ok()?.as_raw() else {\n        return None;\n    };\n    let ns_view: &NSView = unsafe { handle.ns_view.cast().as_ref() };\n\n    let target = DisplayLinkTarget::new(mtm, window_adapter);\n    let display_link = unsafe { ns_view.displayLinkWithTarget_selector(&target, sel!(tick:)) };\n\n    Some(into_throttle(target, display_link))\n}\n\n#[cfg(ios_and_friends)]\npub(super) fn try_create(\n    window_adapter: Weak<WinitWindowAdapter>,\n    _winit_window: &winit::window::Window,\n) -> Option<Box<dyn super::FrameThrottle>> {\n    use objc2::sel;","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/slint-ui/slint/blob/3fd8f2ec03c2aa8a95d5f4b9daa299c7b8bf4016/internal/backends/winit/frame_throttle/apple_display_link.rs#L99-L135","documentation":"Error \"frame throttle must be created on main thread\" thrown in slint-ui/slint.","triggerScenarios":"Thrown at internal/backends/winit/frame_throttle/apple_display_link.rs:117 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Create the window/frame throttle on the main thread on macOS.","Move the window creation code to the main thread."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fd8f2ec03c2aa8a95d5f4b9daa299c7b8bf4016","analyzedAt":"2026-08-19T23:23:16.610Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}