{"record":{"id":"3d109adc143be505","repo":"slint-ui/slint","slug":"cannot-create-placeholder-err","errorCode":null,"errorMessage":"Cannot create placeholder: {err}","messagePattern":"Cannot create placeholder: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tools/viewer/remote.rs","lineNumber":454,"sourceCode":"        window.set_address(SharedString::from(self.address.as_str()));\n        window.set_name(SharedString::from(self.name.as_str()));\n        window.set_slint_version(SharedString::from(SLINT_VERSION));\n        window.set_build_info(build_info());\n        window.set_third_party_licenses(self.licenses.clone());\n        window.set_pairing_disabled(self.pairing_disabled);\n    }\n}\n\n/// Reinstall a fresh placeholder onto the existing window and drop the user instance.\nfn swap_to_placeholder(\n    placeholder: &mut RemoteViewerWindow,\n    user_instance: &mut Option<slint_interpreter::ComponentInstance>,\n    chrome: &Chrome,\n    message: &str,\n    state: RemoteViewerState,\n) -> anyhow::Result<()> {\n    let fresh = RemoteViewerWindow::new_with_existing_window(placeholder.window())\n        .map_err(|err| anyhow::anyhow!(\"Cannot create placeholder: {err}\"))?;\n    chrome.apply(&fresh);\n    fresh.set_message(SharedString::from(message));\n    fresh.set_state(state);\n    fresh.show().map_err(|err| anyhow::anyhow!(\"Cannot show placeholder: {err}\"))?;\n    *placeholder = fresh;\n    *user_instance = None;\n    Ok(())\n}\n\n/// Platform-specific override for the friendly device name. Returns `None` on platforms\n/// where the default chain in `Connection` (pretty hostname → hostname, then Bonjour on\n/// Apple) is already best.\nfn device_name_override() -> Option<String> {\n    #[cfg(target_os = \"android\")]\n    {\n        ANDROID_DEVICE_NAME.lock().unwrap_or_else(|e| e.into_inner()).clone()\n    }\n    #[cfg(not(target_os = \"android\"))]","sourceCodeStart":436,"sourceCodeEnd":472,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/tools/viewer/remote.rs#L436-L472","documentation":"RemoteViewerWindow::new_with_existing_window failed while swap_to_placeholder tried to rebuild the placeholder UI on the existing window (used to show compile errors, pairing info, or 'component not found'). Creating a fresh placeholder window from the existing slint window failed, so the viewer cannot even display its fallback screen; the error is wrapped in anyhow and propagated as unrecoverable.","triggerScenarios":"swap_to_placeholder is invoked by run_async or build_and_show (on CompilationError/ComponentNotFound) and RemoteViewerWindow::new_with_existing_window(placeholder.window()) returns Err — the window handle is invalid/closed or the placeholder component cannot be instantiated into it.","commonSituations":"Device window was closed while an error message was being displayed; the placeholder .slint UI fails to instantiate on this backend; racing teardown during editor disconnect.","solutions":["Verify the underlying window (placeholder.window()) is still valid before swapping; if the window is gone, exit the run loop instead of swapping.","Update the viewer/editor to matching slint versions so the placeholder UI compiles and instantiates.","Retry the connection flow from scratch so a fresh window and placeholder are created.","Inspect the inner error from new_with_existing_window for the concrete instantiation failure cause."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match swap_to_placeholder(placeholder, user_instance, chrome, &message, RemoteViewerState::PreviewError) {\n    Ok(()) => {},\n    Err(e) if e.to_string().starts_with(\"Cannot create placeholder\") => {\n        // window is gone: exit the run loop instead of continuing\n        tracing::error!(\"{e:#}\");\n        return; // or break out of the connection loop\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Verify placeholder.window() is still valid before rebuilding the placeholder.","Avoid calling swap_to_placeholder after the connection/window has begun teardown.","Keep the placeholder .slint UI in sync with the viewer's slint version.","Test error-path swaps (compile error, component not found) on all supported platforms."],"tags":["slint","window","placeholder","remote-viewer"],"backgroundTag":"component-instantiation-failed","analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}