fix: survive explorer.exe restarts (tray icon no longer disappears)#36
Open
amorel wants to merge 1 commit into
Open
fix: survive explorer.exe restarts (tray icon no longer disappears)#36amorel wants to merge 1 commit into
amorel wants to merge 1 commit into
Conversation
When explorer.exe restarts it destroys the taskbar, which destroys our embedded child window outright (IsWindow returns false) and leaves the UI thread parked in GetMessage with no window to recreate in place. The tray icon and widget vanish until the app is manually relaunched (see issue CodeZeno#34). A dedicated watchdog thread (independent of the now-dead message loop) polls the Shell_TrayWnd handle and, when it changes, relaunches the widget as a fresh process that re-embeds into the new taskbar. The relaunched child is flagged via an environment variable so it waits on the single-instance mutex until the previous instance exits, and a throttle backs off if explorer is crash-looping.
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.
Fixes #35 (and the symptom reported in #34).
Problem
When
explorer.exerestarts, it destroys the taskbar, which destroys our embedded child window outright (IsWindowreturnsfalse) and leaves the UI thread parked inGetMessageWwith no window to recreate in place. The tray icon and widget vanish until the app is manually relaunched. Full root-cause analysis in #35.Fix
A dedicated watchdog thread (independent of the now-dead message loop) polls the
Shell_TrayWndhandle and, when it changes, relaunches the widget as a fresh process that re-embeds into the new taskbar.CCUM_RELAUNCH) so it waits on the single-instance mutex until the previous instance exits — no double instance, no race.CCUM_LAST_RELAUNCH_UNIX+ backoff) prevents a relaunch storm if Explorer is crash-looping.In-process recovery isn't viable because the window is genuinely destroyed and can't be recreated from another thread; a clean relaunch is the robust path. Happy to switch to in-process recreation if you'd prefer that direction.
Testing
IsWindow == true,GetParent ==the newShell_TrayWnd).cargo build --release,cargo clippy(no new warnings from this change),cargo fmt --check(no changes to the touched code).Single commit, scoped to
src/window.rs.