Repository navigation
Preload and keep alive Windows' context menu handlers - #19
Conversation
|
Thanks for this, @alchemyyy. It's a well put together change, and the timings in the docs are a nice touch. I'll build it and test it on my PC this weekend, probably on Sunday, and get back to you after that. A few things I noticed while reading it, in case you want to look at them before then:
None of this is urgent. I'll know more after testing it on Sunday. |
Most of the wait before the menu shows is Windows loading the handlers other apps add to it (7-Zip, Windows Terminal, WinMerge and so on). The first right-click after Explorer starts loads all of them, and handlers that run in their own process shut down soon after a menu closes, so the next right-click after a pause has to start them again. Two new settings, both off unless set; the app's Behavior page has a switch for each: - preload: shortly after Explorer starts, build Windows' menus for a file, a folder and the backgrounds in the background, without showing them. A preload that never finished (Explorer crashed or was closed during it) keeps later ones from running until the config changes, so a handler that crashes Explorer there doesn't do so at every start. - keepalive: keep a reference on handler DLLs and keep out-of-process handlers running between menus, and create those from the class factory each menu thread kept instead of asking RPCSS again. Turning it off lets all of it go at the next menu.
|
Thanks so much for the review. I did leave it a bit dirty. I've gone ahead and made the following changes:
I'm running the new build in Explorer now, and the preload runs normally. |
Some apps add menu items only for certain file types (photo viewers, Office, media players), so the menus the preload builds at Explorer start (a file, a folder and the backgrounds) don't load them, and the first right-click on such a file still waits for them.
- settings.preload.types: the extensions whose menus the preload builds too, from an empty file of each kept in a folder of the temp folder. A list (['jpg', 'pdf']) or one string ('jpg|pdf'), with or without dots; unset, jpg, png, pdf, docx, mp4, mkv, html and obj; '' builds none. shell.log names the types it built.
- preload is a block now, like tip: preload = true still works, as preload.enabled.
- The app's Behavior page lists the file types under the preload switch, with an Add box, a remove button on each and a Reset button at the right of the list's header.
In Explorer the preload built the eight default types in 750 ms at start, and the photo viewer, MP4, MKV and Cast to Device handlers were loaded before the first right-click.
|
Thanks for the quick turnaround, @alchemyyy. I went through the new commits and all three fixes check out:
Two smaller things, if you have time before Friday:
About the branch: no need to rebase. Targeting The plan: I'll do my best to release a beta with this PR and #20 merged on Friday night. If nobody reports bugs by Sunday, the new stable goes out Sunday night. So please hold off on bigger changes until Friday night; small fixes like the two above are welcome before then. |
083a623
into
Abdullah-Masood-05:prs/2.3.2
|
Merged, thank you @alchemyyy! This is a great contribution, and the quick turnaround on the review points made it easy to take in. It's in the 2.3.2 beta (v2.3.2-beta.1), which is building now and should be out in about 20 minutes. Both settings are off by default, with their switches on the Behavior page. If nothing turns up during the beta, it goes into the stable release on Sunday night. The two small follow-ups from my last comment (the lock around the settings and cleaning up the sample files) are still welcome as a new PR whenever you have time. |
Howdy! Thanks so much for the merge, and I'm glad you like the feature too. Apologies for missing the deadline on those two follow-up items. I try to avoid messing with code I'm going to put in a PR when I don't have a time stretch to really sit down with it. The follow-up PR is here: #22 Side note (just more performance related junk) - I did some additional digging around yesterday and found that there's a speckling of shell extensions which can contribute relatively significantly to context menu load times, and in many cases at least for me, are never used. It might a fun feature in the future to expand on the existing rule set remove feature with this in mind. |
|
Are you sure this feature works as expected? I tried v2.3.2 beta 3 and enabled both options but first right click after windows restart still takes longer. both on empty desktop space and on a file type that is set to preload. also waited 10s after windows boot before making the first right click to give time to preloading. but still first time takes longer. |
|
@vahid-code Thanks for testing it. The preload should be done well within 10 seconds, so something is getting in the way on your PC. Could you send me a few things?
With these I can tell whether the preload ran and missed something, or never got a chance to run. |
|
First of all I think I have found the problem. after testing the number 2, I noticed there was no nilesoft shell entry in that registry path. then checked my main pc and noticed that there is a nilesoft shell entry there. so I re registered nilesoft shell in the test system using the method I used in my main pc: removed NilesoftShellPro.exe file and ran the shell.exe that shows the original small window with 3 options to register or unregister and explorer restart when settings app is removed. registered the shell that way and the registry entry added and preload worked fine. then because I was testing in virtual machine I revetred to the snapshot before installing the nilesoft shell and did the installing one more time to make sure I did it right and this time also there was no entry added for nilesoft shell in that registry path when registered shell using settings app. in both tests I ran the settings app and shell.exe as administrator. also note that I used portable version. By the way this is the answer to your 3 questions (I wrote these before the top explanation): 1- The shell.log has the lines starting with preload. the last 3 of them is: 2- The output of powershell command: 3- The first right click takes more than 3 times the second one. also changes the mouse cursor to loading cursor while loading but the second right click does not change mouse cursor. I also waited more than 5 minutes and it was the same behavior. |
|
@vahid-code Thank you, that was a great find, and sorry for the slow reply. You were right. When Shell is registered from the settings app with Register for you, it registered only the menu itself. The other way of registering also adds an entry that makes File Explorer load Shell as soon as it starts. Without that entry, Shell only loaded on the first right-click, so the preload couldn't help that click. Your shell.log shows the preload did run, just too late. The fix is ready: Register for you now adds that entry too, still without needing administrator rights. It isn't in beta 5, which was already building, but it will be in 2.3.2 stable, which I'm releasing tomorrow. Until then, registering with shell.exe's own window, or with Register for all users in the app, works. Beta 5 is here if you'd like to check the rest before the release: https://github.com/Abdullah-Masood-05/Shell/releases/tag/v2.3.2-beta.5. If you find any other bug, please let me know so I can look into it before then. |
Most of the wait before the menu shows is Windows loading the handlers other apps add to it (7-Zip, Windows Terminal, WinMerge and so on). The first right-click after Explorer starts loads all of them, and handlers that run in their own process shut down soon after a menu closes, so the next right-click after a pause has to start them again.
Two new settings, off unless set (the shipped shell.nss turns both on):
The app's Behavior page has a switch for each.