MobiFlight / MobiFlight-Connector

MobiFlight is an open source project that allows you to create your own home cockpit for your favorite flight simulator in a flexible, affordable and extremely user-friendly way.
https://mobiflight.com
MIT License
231 stars 102 forks source link

MobiFlightWwFcu.dll crash when waking PC up from sleep #1805

Closed leftos closed 1 month ago

leftos commented 1 month ago

Describe the bug If I put my Windows 11 PC to sleep while MF Connector is running with a WinWing FCU profile active, and then wake it back up, it crashes. This is 100% reproducible.

Steps To Reproduce

  1. Start MF Connector
  2. Load up a WinWing FCU profile (a few of these at flightsim.to) and pair it to the orphaned WinWing FCU device if necessary
  3. Put PC to sleep
  4. Wake PC up
  5. Notice crash report from Windows on MFConnector.exe

Expected behavior Shouldn't crash.

Actual behavior It does crash.

Details

Additional context Callstack:

>    HidSharp.dll!HidSharp.Platform.Windows.NativeMethods.OverlappedOperation(System.IntPtr ioHandle, System.IntPtr eventHandle, int eventTimeout, System.IntPtr closeEventHandle, bool overlapResult, System.Threading.NativeOverlapped* overlapped, out uint bytesTransferred) Line 903    C#
     HidSharp.dll!HidSharp.Platform.Windows.WinHidStream.Write(byte[] buffer, int offset, int count) Line 186    C#
     MobiFlightWwFcu.dll!MobiFlight.WinwingDisplayControl.‫‭‍‌‫‫‌‫‭‬‪​‏‫‪‏‪‌​‍(System.IO.Stream value, byte[] value, int value, int value)    Unknown
     MobiFlightWwFcu.dll!MobiFlight.WinwingDisplayControl.‭‫‪‬‌‏‎​‌‪‎‏‍‏‪‍‍‬‬‎‫(byte[] value, int value, int value)    Unknown
     MobiFlightWwFcu.dll!MobiFlight.WinwingDisplayControl.‍‏‭‫‬‬​‭‫‏‫‌‏​‍‬​‌()    Unknown
     mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state)    Unknown
     mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)    Unknown
     mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)    Unknown
     mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)    Unknown
     mscorlib.dll!System.Threading.ThreadHelper.ThreadStart()    Unknown 

Exception Info:

System.IO.IOException
  HResult=0x80131620
  Message=Operation failed early: The device is not connected
  Source=HidSharp
  StackTrace:
<Cannot evaluate the exception stack trace>

Inner Exception 1:
Win32Exception: The device is not connected

Full crashdump can be provided upon request.

neilenns commented 1 month ago

@Koseng can you take a look at this?

Koseng commented 1 month ago

@Koseng can you take a look at this?

Hi, yep I can check where to best catch that case.

Koseng commented 1 month ago

Crash will be fixed, but either way MobiFlight will need to be restarted, because Joystick reconnect is still not implemented.