slint-ui/slint · error
frame throttle must be created on main thread
Error message
frame throttle must be created on main thread
What it means
Error "frame throttle must be created on main thread" thrown in slint-ui/slint.
Source
Thrown at internal/backends/winit/frame_throttle/apple_display_link.rs:117
#[cfg(target_os = "macos")]
pub(super) fn try_create(
window_adapter: Weak<WinitWindowAdapter>,
winit_window: &winit::window::Window,
) -> Option<Box<dyn super::FrameThrottle>> {
use objc2::runtime::AnyClass;
use objc2::sel;
use objc2_app_kit::NSView;
use raw_window_handle::{HasWindowHandle, RawWindowHandle};
// -[NSView displayLinkWithTarget:selector:] is only available on macOS
// 14.0+. The CADisplayLink class itself is reachable on older macOS via
// QuartzCore, so check for the selector instead of the class.
if !AnyClass::get(c"NSView")?.responds_to(sel!(displayLinkWithTarget:selector:)) {
return None;
}
let mtm = MainThreadMarker::new().expect("frame throttle must be created on main thread");
let RawWindowHandle::AppKit(handle) = winit_window.window_handle().ok()?.as_raw() else {
return None;
};
let ns_view: &NSView = unsafe { handle.ns_view.cast().as_ref() };
let target = DisplayLinkTarget::new(mtm, window_adapter);
let display_link = unsafe { ns_view.displayLinkWithTarget_selector(&target, sel!(tick:)) };
Some(into_throttle(target, display_link))
}
#[cfg(ios_and_friends)]
pub(super) fn try_create(
window_adapter: Weak<WinitWindowAdapter>,
_winit_window: &winit::window::Window,
) -> Option<Box<dyn super::FrameThrottle>> {
use objc2::sel;View on GitHub (pinned to 3fd8f2ec03)
Solutions
- Create the window/frame throttle on the main thread on macOS.
- Move the window creation code to the main thread.
When it happens
Trigger: Thrown at internal/backends/winit/frame_throttle/apple_display_link.rs:117 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of slint-ui/slint@3fd8f2ec03 (2026-08-19).
Data as JSON: /api/errors/bb6b24f9f9b0ffb4.
Report an issue: GitHub.