slint-ui/slint · error

the event loop runs inside the context that owns this platfo

Error message

the event loop runs inside the context that owns this platform

What it means

Error "the event loop runs inside the context that owns this platform" thrown in slint-ui/slint.

Source

Thrown at internal/backends/android-activity/lib.rs:114

        app: AndroidApp,
        listener: impl Fn(&PollEvent<'_>) + 'static,
    ) -> Self {
        let mut this = Self::new(app);
        this.event_listener = Some(Box::new(listener));
        this
    }
}

impl i_slint_core::platform::Platform for AndroidPlatform {
    fn create_window_adapter(&self) -> Result<Rc<dyn WindowAdapter>, PlatformError> {
        Ok(self.window.clone())
    }
    fn run_event_loop(&self) -> Result<(), PlatformError> {
        let ctx = self
            .context
            .get()
            .and_then(|ctx| ctx.upgrade())
            .expect("the event loop runs inside the context that owns this platform");
        let vsync = vsync::VsyncDriver::new(self.app.create_waker());
        loop {
            let mut timeout = ctx.duration_until_next_timer_update();
            // While animating, the vsync thread wakes this loop at each display refresh
            // so rendering tracks the refresh rate instead of a fixed poll timeout.
            let animating = self.window.window.has_active_animations();
            vsync.set_animating(animating);
            if animating && !vsync.is_driving() {
                // The vsync thread is not driving frames (still starting, or unavailable);
                // fall back to a periodic wakeup so animations still advance.
                let frame_duration = Duration::from_millis(10);
                timeout = Some(timeout.map_or(frame_duration, |x| x.min(frame_duration)));
            }
            // `request_redraw()` only raises the flag, so a request issued outside the
            // poll would otherwise wait here for an unrelated wakeup.
            if self.window.pending_redraw.get() {
                timeout = Some(Duration::ZERO);
            }

View on GitHub (pinned to 3fd8f2ec03)

Solutions

  1. Run the event loop from the platform's owning context instead of a custom one.
  2. Follow the Android activity lifecycle expected by the backend.

When it happens

Trigger: Thrown at internal/backends/android-activity/lib.rs:114 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/4757c0901fcb2711. Report an issue: GitHub.