{"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":155,"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\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 ns_view = crate::macos::ns_view(winit_window)?;\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;\n\n    let mtm = MainThreadMarker::new().expect(\"frame throttle must be created on main thread\");\n\n    let target = DisplayLinkTarget::new(mtm, window_adapter);\n    let display_link =","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/internal/backends/winit/frame_throttle/apple_display_link.rs#L137-L173","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":"3a7e700487dc74d404cad0726378053ab763d4e0","analyzedAt":"2026-08-19T23:23:16.610Z","contentChangedAt":"2026-08-19T23:23:16.610Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}