{"record":{"id":"d31db7e4104543b0","repo":"lencx/ChatGPT","slug":"core-window-failed-to-get-window-size","errorCode":null,"errorMessage":"[core:window] Failed to get window size","messagePattern":"\\[core:window\\] Failed to get window size","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src-tauri/src/core/setup.rs","lineNumber":52,"sourceCode":"            {\n                core_window = core_window\n                    .title_bar_style(TitleBarStyle::Overlay)\n                    .hidden_title(true);\n            }\n\n            core_window = core_window\n                .resizable(true)\n                .inner_size(800.0, 600.0)\n                .min_inner_size(300.0, 200.0)\n                .theme(Some(AppConf::get_theme(&handle)));\n\n            let core_window = core_window\n                .build()\n                .expect(\"[core:window] Failed to build window\");\n\n            let win_size = core_window\n                .inner_size()\n                .expect(\"[core:window] Failed to get window size\");\n            // Wrap the window in Arc<Mutex<_>> to manage ownership across threads\n            let window = Arc::new(Mutex::new(core_window));\n\n            let main_view =\n                WebviewBuilder::new(\"main\", WebviewUrl::App(\"https://chatgpt.com\".into()))\n                    .auto_resize()\n                    .on_download({\n                        let app_handle = handle.clone();\n                        let download_path = Arc::new(Mutex::new(PathBuf::new()));\n                        move |_, event| {\n                            match event {\n                                DownloadEvent::Requested { destination, .. } => {\n                                    let download_dir = app_handle\n                                        .path()\n                                        .download_dir()\n                                        .expect(\"[view:download] Failed to get download directory\");\n                                    let mut locked_path = download_path\n                                        .lock()","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/lencx/ChatGPT/blob/a6de9a8b61077fa63ad5c3ecbe2bc12e0cb4b4b9/src-tauri/src/core/setup.rs#L34-L70","documentation":"Panic from Window::inner_size() (Result-returning getter in tauri v2) failing right after the window is built. inner_size() queries the platform window; it returns Err when the underlying window handle is gone (window closed between build and the query), the event loop is not running on the main thread yet, or the windowing backend (winit/tao) cannot talk to the display server. It is only used here to size the three child webviews, so a sensible 800x600 fallback exists.","triggerScenarios":"The \"core\" window being closed or destroyed immediately after build (user, OS, or another plugin) before inner_size() runs; querying from the async runtime task on Linux before the window is fully mapped; a Wayland/X11 error making the platform call fail.","commonSituations":"Racing window.close()/destroy in tests or via tray/protocol handlers; Linux Wayland sessions where size queries before the first frame can fail; tauri v2 migration where inner_size() changed from returning Size to Result<PhysicalSize<u32>, Error> and old unwrap-style code kept panicking.","solutions":["Fall back to the configured logical size 800x600 via unwrap_or(PhysicalSize::new(800, 600)) since that is what inner_size(800.0, 600.0) requested","Log the Err instead of panicking so child webview layout still proceeds with the default size","Defer sizing until the first WindowEvent::Resized/ScaleFactorChanged, which carries an authoritative size"],"exampleFix":"// before\nlet win_size = core_window\n    .inner_size()\n    .expect(\"[core:window] Failed to get window size\");\n\n// after\nlet win_size = core_window\n    .inner_size()\n    .unwrap_or_else(|e| {\n        eprintln!(\"[core:window] inner_size failed: {e}\");\n        PhysicalSize::new(800, 600)\n    });","handlingStrategy":"fallback","validationCode":"// prefer a known-good default before querying the platform\nconst DEFAULT_SIZE: tauri::PhysicalSize<u32> = tauri::PhysicalSize::new(800, 600);","typeGuard":"fn safe_inner_size(w: &tauri::Window) -> tauri::PhysicalSize<u32> {\n    w.inner_size().unwrap_or(tauri::PhysicalSize::new(800, 600))\n}","tryCatchPattern":"let win_size = core_window.inner_size().unwrap_or_else(|e| {\n    eprintln!(\"[core:window] inner_size failed: {e}\");\n    PhysicalSize::new(800, 600)\n});","preventionTips":["Treat geometry getters as advisory in tauri v2 (they return Result)","Mirror the builder's requested inner_size(800.0, 600.0) as the fallback","Re-read the authoritative size from WindowEvent::Resized once events flow"],"tags":["tauri","window","rust","panic","fallback"],"backgroundTag":null,"analyzedSha":"a6de9a8b61077fa63ad5c3ecbe2bc12e0cb4b4b9","analyzedAt":"2026-08-16T08:31:13.240Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}