lencx/ChatGPT · critical
[core:window] Failed to get window size
Error message
[core:window] Failed to get window size
What it means
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.
Source
Thrown at src-tauri/src/core/setup.rs:52
{
core_window = core_window
.title_bar_style(TitleBarStyle::Overlay)
.hidden_title(true);
}
core_window = core_window
.resizable(true)
.inner_size(800.0, 600.0)
.min_inner_size(300.0, 200.0)
.theme(Some(AppConf::get_theme(&handle)));
let core_window = core_window
.build()
.expect("[core:window] Failed to build window");
let win_size = core_window
.inner_size()
.expect("[core:window] Failed to get window size");
// Wrap the window in Arc<Mutex<_>> to manage ownership across threads
let window = Arc::new(Mutex::new(core_window));
let main_view =
WebviewBuilder::new("main", WebviewUrl::App("https://chatgpt.com".into()))
.auto_resize()
.on_download({
let app_handle = handle.clone();
let download_path = Arc::new(Mutex::new(PathBuf::new()));
move |_, event| {
match event {
DownloadEvent::Requested { destination, .. } => {
let download_dir = app_handle
.path()
.download_dir()
.expect("[view:download] Failed to get download directory");
let mut locked_path = download_path
.lock()View on GitHub (pinned to a6de9a8b61)
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
Example fix
// before
let win_size = core_window
.inner_size()
.expect("[core:window] Failed to get window size");
// after
let win_size = core_window
.inner_size()
.unwrap_or_else(|e| {
eprintln!("[core:window] inner_size failed: {e}");
PhysicalSize::new(800, 600)
}); Defensive patterns
Strategy: fallback
Validate before calling
// prefer a known-good default before querying the platform const DEFAULT_SIZE: tauri::PhysicalSize<u32> = tauri::PhysicalSize::new(800, 600);
Type guard
fn safe_inner_size(w: &tauri::Window) -> tauri::PhysicalSize<u32> {
w.inner_size().unwrap_or(tauri::PhysicalSize::new(800, 600))
} Try / catch
let win_size = core_window.inner_size().unwrap_or_else(|e| {
eprintln!("[core:window] inner_size failed: {e}");
PhysicalSize::new(800, 600)
}); Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- [core:window] Failed to build window
- error while running lencx/ChatGPT application
- [view:download] Failed to get download directory
- [view:main] Failed to get webview window
- [view:titlebar] Failed to get webview window
AI-assisted analysis of lencx/ChatGPT@a6de9a8b61 (2026-08-16).
Data as JSON: /api/errors/d31db7e4104543b0.
Report an issue: GitHub.