slint-ui/slint · error
Component should cleanly upgrade here
Error message
Component should cleanly upgrade here
What it means
This panic occurs in object_tree.rs:4968 during the component snapshotting/restore logic. The code maps entries of `use_component` weak references back to strong `Component` references and asserts the `Weak::upgrade` succeeds — the referenced component must still be alive at this point in the pipeline. If it was already dropped, the compiler's ownership invariant around component snapshots is violated.
Solutions
- Retry compilation with the latest stable Slint compiler version to rule out a known regression.
- Simplify the .slint import graph — remove cyclic or redundant imports that may interact with the snapshot mechanism.
- For compiler contributors: verify `use_component` entries are kept alive (strong refs held) until this restore point runs.
- File a minimal reproducer as a compiler bug.
Defensive patterns
Strategy: validation
Validate before calling
// Prefer flat, acyclic import graphs
fn validate_imports(files: &[String]) -> Result<(), String> {
// reject duplicate and cyclic imports before invoking the compiler
// e.g. build a graph and check with toposort
Ok(())
} Prevention
- Avoid redundant/cyclic .slint imports that stress the snapshot mechanism.
- Compile with stable Slint releases, not ad-hoc builds.
- Contributors: hold strong references to snapshotted components until restore completes.
When it happens
Trigger: Running the compiler pass that restores recorded component usage (rebuilding a map from en -> Either<Weak<Component>, ...>) when a recorded weak component reference has been freed — e.g. components dropped between snapshot and restore due to a pass-ordering bug or re-entrant compilation of the same document.
Common situations: Compiler development touching the snapshot/restore mechanism (e.g. around `compile_with_builtin_libraries` or dependency tracking); nightly compiler builds; unusual import graphs that cause components to be dropped early.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- constraint must have binding
- EmbedTextures builds the shared font collection
- internal compiler error: more than one strong reference…
- LibGlobal not found
- named struct declarations have symbol counters
AI-assisted analysis of slint-ui/slint@3a7e700487 (2026-09-16).
Data as JSON: /api/errors/4fba559ccc4434a1.
Report an issue: GitHub.
Appendix: source
Thrown at internal/compiler/object_tree.rs:5028
}
pub fn retain(
&mut self,
func: impl FnMut(&mut (ExportedName, Either<Rc<Component>, Type>)) -> bool,
) {
self.components_or_types.retain_mut(func)
}
pub(crate) fn snapshot(&self, snapshotter: &mut crate::typeloader::Snapshotter) -> Self {
let components_or_types = self
.components_or_types
.iter()
.map(|(en, either)| {
let en = en.clone();
let either = match either {
itertools::Either::Left(l) => itertools::Either::Left({
Weak::upgrade(&snapshotter.use_component(l))
.expect("Component should cleanly upgrade here")
}),
itertools::Either::Right(r) => itertools::Either::Right(r.clone()),
};
(en, either)
})
.collect();
Self { components_or_types }
}
}
impl std::iter::IntoIterator for Exports {
type Item = (ExportedName, Either<Rc<Component>, Type>);
type IntoIter = std::vec::IntoIter<Self::Item>;
fn into_iter(self) -> Self::IntoIter {
self.components_or_types.into_iter()View on GitHub (pinned to 3a7e700487)