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.

Solutions

  1. Create the window/frame throttle on the main thread on macOS.
  2. 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@3a7e700487 (2026-08-19). Data as JSON: /api/errors/bb6b24f9f9b0ffb4. Report an issue: GitHub.

Appendix: source

Thrown at internal/backends/winit/frame_throttle/apple_display_link.rs:155

#[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;

    // -[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 ns_view = crate::macos::ns_view(winit_window)?;

    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;

    let mtm = MainThreadMarker::new().expect("frame throttle must be created on main thread");

    let target = DisplayLinkTarget::new(mtm, window_adapter);
    let display_link =

View on GitHub (pinned to 3a7e700487)