slint-ui/slint · error
Cannot show component
Error message
Cannot show component: {err} What it means
ComponentInstance::show failed after build_and_show successfully created the preview component instance on the existing window. Showing the instance makes it the visible content of the remote-viewer window; a failure here means the runtime could not present the component (window/backend rejection), and it is treated as an unrecoverable anyhow error.
Solutions
- Retry via show_current so the placeholder is reinstalled and the component is re-created and shown from scratch.
- Verify the window and platform event loop are still alive at swap time; guard the swap against concurrent teardown.
- Update editor and viewer to matching slint versions to rule out runtime incompatibilities.
- Read the inner error from new_instance.show() to identify the platform/backend cause and fix the window setup.
Defensive patterns
Strategy: try-catch
Try / catch
match new_instance.show() {
Ok(()) => { *user_instance = Some(new_instance); },
Err(err) => {
// window/backend refused the show; fall back to the placeholder
tracing::error!("Cannot show component: {err}");
let _ = swap_to_placeholder(placeholder, user_instance, chrome, "Preview failed", RemoteViewerState::PreviewError);
}
} Prevention
- Confirm the slint platform/event loop is running before swapping components.
- Check window liveness before calling show on a swapped-in instance.
- Reuse one window per viewer process instead of creating/destroying windows rapidly.
- Keep editor and viewer on matching slint versions.
When it happens
Trigger: new_instance.show() returns Err after create_with_existing_window succeeded in build_and_show — the window backend refuses to show the freshly swapped-in component (window already closing, platform event-loop failure, renderer unavailable).
Common situations: User disconnects or the device window is destroyed during the swap; embedded platform backend cannot show a second component on the same window; slint runtime/platform initialization problems on the target device.
Related errors
- Cannot create component instance
- Cannot create placeholder
- Cannot show placeholder
- First argument not an array
- Second argument not an integer
AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16).
Data as JSON: /api/errors/895ef5cecc80859f.
Report an issue: GitHub.
Appendix: source
Thrown at tools/viewer/remote.rs:411
}
PreviewCompilation::ComponentNotFound => {
swap_to_placeholder(
placeholder,
user_instance,
chrome,
"Component not found",
RemoteViewerState::PreviewError,
)?;
return Ok(());
}
PreviewCompilation::Unavailable => return Ok(()),
};
let new_instance = component
.create_with_existing_window(placeholder.window())
.map_err(|err| anyhow::anyhow!("Cannot create component instance: {err}"))?;
new_instance.show().map_err(|err| anyhow::anyhow!("Cannot show component: {err}"))?;
*user_instance = Some(new_instance);
// The placeholder is hidden now, but keep its state property truthful.
placeholder.set_state(RemoteViewerState::Previewing);
Ok(())
}
/// Everything on the placeholder screen that doesn't depend on what the
/// connection is doing.
///
/// [`swap_to_placeholder`] builds a whole new window each time, so anything
/// missing from [`Chrome::apply`] silently disappears the first time the
/// preview is swapped out.
struct Chrome {
/// Newline-separated `ip:port` list the editor can be pointed at.
address: String,
/// Friendly device name. Bonjour can rename us on iOS resume, so this
/// isn't fixed for the life of the process.
name: String,View on GitHub (pinned to bb937076de)