-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Explorer.exe monitoring feature. #945
Conversation
Btw: |
I think I can fix the diff to show only your changes here (you may be using CRLF instead of LF). |
Thanks :) Please do! |
I'm not sure this is quite right--there could be several explorer.exe processes, how do we know we are looking at the current user's shell process and not, say, a file explorer window process? |
True. What if we check that the process exe is located at "windows/explorer.exe"? The explorer processes are stored on array so we could do foreach on them maybe? (But this would not cover custom shells, but maybe expand to customs later if even needed) |
Or get the current shell exe path and name from registry, and compare process paths to that? Then explorer.exe can be located on any path and using any exe name |
Hmm also the explorer.exe shell that runs desktop etc usually has longests start time, so this could narrow it down even more. And the desktop shell usually does not have a parent process so that can be used as a filter too. |
-Added ability to detect the main shell process so we dont accidentally target File Explorers or such -Added suport for custom shells -Some other minor tweaks
@dremin I updated the pull request files. now it detects the proper shell\explorer process. There is also some other minor tweaks and a support for custom shells. Let me know what you think. |
I'd like to try avoiding crashing Explorer altogether if possible. This commit prevents the crash for me: cairoshell/ManagedShell@33dc8a3 |
Even with the Explorer crash fixed, we may still want something like what is in this PR so that we can restore the AppBar state and workarea after Explorer restarts. Without the Explorer crash, we can simplify things by listening for the |
Your fix for the crash is much better, thanks for taking a look at this. :) Should I close this PR now that the issue is solved? You can take/modify anything on the code of this PR if you want to play around with the TaskbarCreated, or I can try to modify it to use TaskbarCreated if you want? How should we proceed? EDIT: |
@dremin I implemented the TaskbarCreated event monitor, and also rewrote the description etc of this pull request. I used a form to create the monitor, it is more efficient than the other thread version I made. Also your ManagedShell PR did fix the crashes 100%, it is good now. :) |
These were the last commits from me for now. Waiting for review. Feel free to change\remove anything on the code. :) |
Nice! A few comments:
|
Done. I tried with both restarting and just reopening taskbars, here are the results: For some reason if i dont restart completely, the desktop is not resized. I left the ReopenTaskbars code as commented-out to the code, maybe I use it wrong or something? |
ok i used ReopenTaskbars wrong, I needed to pass the WindowManager as a reference... I will make a commit in few minutes. |
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
When |
Hm, it's definitely possible. How are you creating the crash at login with the current build? |
@xoascf I noticed a potential race. Could you see if it is fixed with the |
Would it be possible to get the data from windows event viewer>windows logs>application>crash? Interested in how it is crashing on logon. On my system retrobar has a delay on startup, few seconds, it is never launch before explorer.exe. retrobar is set to autostart on registry hkcu/run (default behaviour when autostart is enabled on retrobar). Do you have it set to start on hkcu/run, or somewhere else? (I am trying to reproduce the crash). |
and the delay in launching programs listed under the HKCU\Software\Microsoft\Windows\CurrentVersion\Run registry key occurs because these entries are executed after explorer.exe initializes. On Windows 11, this behavior ensures the shell environment is fully loaded before user-specific applications are started, leading to a smoother logon experience. To launch RetroBar immediately at logon without delay: Use a Scheduled Task (Immediate Logon Execution)
In the General tab: In the Triggers tab: In the Actions tab: In the Conditions tab: In the Settings tab: Check Allow task to be run on demand. Then do the same for the explorer.exe crasher and there you go, 2 taskbars (not on every logon for some reason?) |
@MKKNinetyTwo does it still happen if you move |
no, it does not happen. simplest way to simulate the race is to replace the more accurate way to simulate is the explorer crasher. |
And yeah, now the code basically says: If explorermonitorstart is moved after opentaskbars, then it is: So move that 1 line to make the logic correct and fix the bug. |
And what is the trigger for the bug: If crash happens just at the right moment, just after when line 29 has executed, and before opentaskbars is called, we get 2 taskbars. So it is a race between reopentasbars called by explorermonitor and windowmanager opentaskbars(). |
It should now be fixed by #951. |
Thanks, I happened to reproduce the crash twice, didn't have time to test and report back, that and |
Does this consistently reproduce that way? Does it happen before this PR? |
No, it only happens just |
@xoascf On my system, changing the monitor scale triggers the TaskbarCreated message, but it doesn't give me the double taskbars. If you change your monitor scale only, does that trigger the issue? |
@xoascf Okay cool, so I think this is just another race with |
Still the same issue. Maybe irrelevant now, but just a heads upBy the way, just after re-enabling Game Mode (after having set it to Portrait mode before), the taskbar shrinks to half of the screen (and positions in half for all edges) for the commit prior to this PR (3be4280). After trying commit 1733883 of branch |
@xoascf Could you please enable debug logging, then reproduce the double taskbar issue, and provide the logs? |
@dremin, here is the log file when reproducing that issue for commit 1733883: 2024-11-20_020735924.log |
@xoascf Thanks! I just pushed another commit to the fix-reopen-race branch. Could you please try it? |
@dremin That worked! |
Description:
Implement Explorer.exe monitoring feature using TaskbarCreated event.
What it does?
If we detect that Explorer.exe has restarted we will call ReopenTaskbars.
Why?
This will ensure that when Explorer is restarted, RetroBar is also re-initialized.
This will fix stuff like wrong desktop size etc that would happen if we did not re-initialize RetroBar.
Tests performed:
Lots and lots of testing, on Windows 11 systems.
What issues this should fix?
@dremin PR cairoshell/ManagedShell#113 fixed all of these:
#942
#938
#927
#648
#476
#457
so this PR is just a follow up now, this will fix some bugs like the desktop is not resized properly after Explorer is restarted etc.