microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
111.81k stars 6.58k forks source link

[PT Run > Window Walker] System.InvalidOperationException when searching #27963

Closed htcfreek closed 1 year ago

htcfreek commented 1 year ago

Microsoft PowerToys version

0.73.0-Dev

Installation method

Dev build in Visual Studio

Running as admin

None

Area(s) with issue?

PowerToys Run

Steps to reproduce

[2023-08-13 18:59:51.2217] [ERROR] [D:\AppDev\Github\htcfreek\PT_PluginGpo\src\modules\launcher\PowerLauncher\Plugin\PluginManager.cs::225]
-------------------------- Begin exception --------------------------
Message: Exception for plugin <Window Walker> when query <<iii>

Exception full name  : System.InvalidOperationException
Exception message    : Collection was modified; enumeration operation may not execute.
Exception stack trace:
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at Microsoft.Plugin.WindowWalker.Components.SearchController.FuzzySearchOpenWindows(List`1 openWindows) in D:\AppDev\Github\htcfreek\PT_PluginGpo\src\modules\launcher\Plugins\Microsoft.Plugin.WindowWalker\Components\SearchController.cs:line 122
   at Microsoft.Plugin.WindowWalker.Components.SearchController.SyncOpenWindowsWithModel() in D:\AppDev\Github\htcfreek\PT_PluginGpo\src\modules\launcher\Plugins\Microsoft.Plugin.WindowWalker\Components\SearchController.cs:line 108
   at Microsoft.Plugin.WindowWalker.Components.SearchController.UpdateSearchText(String searchText) in D:\AppDev\Github\htcfreek\PT_PluginGpo\src\modules\launcher\Plugins\Microsoft.Plugin.WindowWalker\Components\SearchController.cs:line 90
   at Microsoft.Plugin.WindowWalker.Main.Query(Query query) in D:\AppDev\Github\htcfreek\PT_PluginGpo\src\modules\launcher\Plugins\Microsoft.Plugin.WindowWalker\Main.cs:line 49
   at PowerLauncher.Plugin.PluginManager.<>c__DisplayClass22_1.<QueryForPlugin>b__0() in D:\AppDev\Github\htcfreek\PT_PluginGpo\src\modules\launcher\PowerLauncher\Plugin\PluginManager.cs:line 195
   at Wox.Infrastructure.Stopwatch.Debug(String message, Action action) in D:\AppDev\Github\htcfreek\PT_PluginGpo\src\modules\launcher\Wox.Infrastructure\Stopwatch.cs:line 29
   at PowerLauncher.Plugin.PluginManager.QueryForPlugin(PluginPair pair, Query query, Boolean delayedExecution) in D:\AppDev\Github\htcfreek\PT_PluginGpo\src\modules\launcher\PowerLauncher\Plugin\PluginManager.cs:line 187
Exception source     : System.Private.CoreLib
Exception target site: Void ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion()
Exception HResult    : -2146233079
-------------------------- End exception --------------------------

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

Other Software

No response

htcfreek commented 1 year ago

This issue seems to be new and might be caused by the changes made by @davidegiacometti in PR #27490. As search results are shown for the plugin this is not function breaking. But it is spamming the log file.

davidegiacometti commented 1 year ago

Nice catch!

99% sure that reverting this https://github.com/microsoft/PowerToys/blob/a1f21fd6f3b51c3afea47b71d2e19e08d219c27f/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/OpenWindows.cs#L43

to

https://github.com/microsoft/PowerToys/blob/8ccbb694dd3c00b5d28132620a47b0e9a3a975c7/src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/OpenWindows.cs#L38

Would solve it.

Now I get why Window is always reinitialized. This happen when a new search is started at the same time that the previous search results are returned.

jaimecbernardo commented 1 year ago

This issue has been worked on and released during the 0.73 Release project. Please update PowerToys to the latest. 😉