fix(desktop): extend startup window-reveal timing fix to Linux#2657
Open
srirsiva wants to merge 1 commit into
Open
fix(desktop): extend startup window-reveal timing fix to Linux#2657srirsiva wants to merge 1 commit into
srirsiva wants to merge 1 commit into
Conversation
tauri_plugin_window_state restores saved window geometry asynchronously. The wait-for-stable-geometry + opaque-backing-color reveal sequence in on_webview_ready was gated to macOS only, so on Linux the main window called reveal_initial_window() immediately and raced the restore, landing at a transient/degenerate size (observed as a collapsed 10x10 or fully invisible window on GTK). Widens the existing timing logic (unchanged) to Linux by relaxing the cfg gates from target_os = "macos" to any(macos, linux). Windows is deliberately left on the immediate-reveal path: no reported bug there, and Win32's SetWindowPos/ShowWindow are believed to apply synchronously, unlike GTK's request/allocate-on-next-idle-iteration model. Verified via tao's platform_impl/linux/window.rs that window.set_background_color(...) sets a real GTK CSS background on the outer ApplicationWindow on Linux, not a macOS-only stub, so the same backing-color technique applies unchanged. Tested manually on Zorin OS (GNOME/X11): repeated launches previously collapsed the window intermittently; after this change, 0 occurrences across repeated launches with the properly built (pnpm tauri build) release binary.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Linux, the desktop app's main window sometimes opens as a collapsed
10x10 window or renders fully invisible/transparent, both on fresh launch
and intermittently after in-app navigation.
Root cause
desktop/src-tauri/src/lib.rscreates the main window hidden(
"visible": false) and pre-maximized ("maximized": true,"transparent": trueintauri.conf.json).tauri_plugin_window_staterestores the saved geometry asynchronously.The
initial-window-revealplugin is supposed to wait for that restore tosettle (via
wait_for_stable_initial_window_geometry+ an opaqueset_initial_window_backing/clear_initial_window_backingsequence)before calling
window.show()— but this entire wait/backing mechanism is#[cfg(target_os = "macos")]-gated only. On Linux,on_webview_readyjustcalls
reveal_initial_window()immediately, racing the window-staterestore and landing the window at a transient/degenerate size.
Fix
Widens the existing timing logic (unchanged — no behavioral changes to the
polling algorithm itself) from
#[cfg(target_os = "macos")]to#[cfg(any(target_os = "macos", target_os = "linux"))]:INITIAL_RENDER_READY_EVENTconst anduse tauri::Listener;importset_initial_window_backing/clear_initial_window_backingwait_for_stable_initial_window_geometryon_webview_readyWindows is deliberately excluded, left on today's immediate-reveal
path — there's no reported bug there, and Win32's
SetWindowPos/ShowWindoware believed to apply synchronously (unlike GTK'srequest/allocate-on-next-idle-iteration model), which is plausibly why
this race hasn't surfaced on that platform. Happy to revisit if a Windows
report ever comes in.
Verified
window.set_background_color(...)is a real, working call onLinux/GTK (traced through
tauri-runtime-wry→tao'splatform_impl/linux/window.rs, sets a real GTK CSS background on theouter
ApplicationWindow), not a macOS-only stub — same technique appliesunchanged.
Testing
just desktop-tauri-check,desktop-tauri-fmt-check,desktop-tauri-clippy(zero warnings),desktop-tauri-test— all pass.unpatched build intermittently collapsed the window; after this change,
0 occurrences across repeated launches, using a properly-built
(
pnpm tauri build) release binary.path is unchanged by this diff, and Windows is explicitly out of scope
per the reasoning above.
machine) — this change is scoped to
desktop/src-tauri/only, nomobile/web impact.
This overlaps with #2500 in problem space (both touch desktop rendering
reliability) but not in code — #2500 doesn't touch
desktop/src-tauri/src/lib.rs.