Search code examples
c#visual-studiomonogame

.NET framework application takes 1m30s to start on a specific machine


I have a MonoGame application that runs fine on most machine, however on my main PC it takes 1 minute and 30 seconds to start.

While debugging it hangs just before

'ZodFortressMono3.8.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ZodFortressMono3.8.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Users\urato\source\repos\ZodFortressMono3.8\ZodFortressMono3.8\bin\Debug\net472\ZodFortressMono3.8.exe'. Symbols loaded.
'ZodFortressMono3.8.exe' (CLR v4.0.30319: ZodFortressMono3.8.exe): Loaded 'C:\Users\urato\source\repos\ZodFortressMono3.8\ZodFortressMono3.8\bin\Debug\net472\MonoGame.Framework.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ZodFortressMono3.8.exe' (CLR v4.0.30319: ZodFortressMono3.8.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ZodFortressMono3.8.exe' (CLR v4.0.30319: ZodFortressMono3.8.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ZodFortressMono3.8.exe' (CLR v4.0.30319: ZodFortressMono3.8.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ZodFortressMono3.8.exe' (CLR v4.0.30319: ZodFortressMono3.8.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
33

hangs

on the output console.

No matter the build configuration or if I start it in the IDE, or I manually start a release build or if I build on another machine and start the executable on my main PC, the problem persists.

I am using Visual Studio 2022, I have tried to update graphic card drivers, reinstalled Visual Studio.

I have no idea how to diagnose this and have looked everywhere.

The previous machine was a Windows Surface tablet (Windows 10) and the main PC is a gaming PC with better hardware (I7, 3080).

On my other machine it starts in less than 1 second.

EDIT: Using procom.exe, I have checked event logs in both of the PC filtered for my application: enter image description here (Watch the axis, they are on different scale on each graphs).

Most of the operations are opening registry key. By looking at the events from procom.exe, I can see that most of them are looking at input/joysticks: enter image description here

It seems that on the bad (slow) pc, the application checks a lot of regkey at once, then it checks some more slowly, repeats two more time, then spreads out the operation over the next 45 seconds before loading.

On the good pc, it seems to do so asap then finishes loading in less than 5 seconds.

The bad pc also does a lot more event than the good pc.

I cannot figure out what could even cause this.

I am trying to port a project from one PC to another.


Solution

  • The problem is a bug with SDL2, which hangs on certain devices, the Corsair keyboard used on the slow PC being one of them.

    The solution is to either migrate to a newer version of SDL which has several hardware check on blacklisted devices or unplug the device during startup.