3324 - Resolve deadlocking on async operations - #3328
Open
ColinM9991 wants to merge 2 commits into
Open
Conversation
|
Build for this pull request: |
Contributor
There was a problem hiding this comment.
Pull request overview
Addresses reported startup hangs/deadlocks (#3324) by adjusting async continuations—primarily adding ConfigureAwait(false) to avoid resuming on the UI synchronization context—across several background/IO paths (device enumeration, delays, update checking, firmware update flow).
Changes:
- Added
ConfigureAwait(false)to multiple awaited operations (Task.Run,Task.Delay,Task.WhenAny) to reduce UI-thread continuation pressure. - Updated joystick enumeration to run asynchronously rather than blocking the UI path.
- Extended similar continuation behavior to related background components (USB monitor, WASM updater retry delay, script runner polling).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/MobiFlightUnitTests/mock/MobiFlight/MobiFlightCacheMock.cs | Adds ConfigureAwait(false) to async mock module retrieval. |
| src/MobiFlightConnector/UI/Forms/FirmwareUpdateProcess.cs | Applies ConfigureAwait(false) to firmware timeout WhenAny await. |
| src/MobiFlightConnector/SimConnectMSFS/WasmModuleUpdater.cs | Adds ConfigureAwait(false) to retry delay. |
| src/MobiFlightConnector/MobiFlight/Scripts/ScriptRunner.cs | Adds ConfigureAwait(false) to startup/polling delays. |
| src/MobiFlightConnector/MobiFlight/Monitors/UsbDeviceMonitor.cs | Adds ConfigureAwait(false) to readiness timeout WhenAny await. |
| src/MobiFlightConnector/MobiFlight/Monitors/DeviceMonitor.cs | Adds ConfigureAwait(false) to delayed scan kickoff chain. |
| src/MobiFlightConnector/MobiFlight/MobiFlightCache.cs | Uses ConfigureAwait(false) around background module connection detection and delayed lookup completion. |
| src/MobiFlightConnector/MobiFlight/Joysticks/JoystickManager.cs | Adds ConfigureAwait(false) after background device enumeration. |
| src/MobiFlightConnector/Base/AutoUpdateChecker.cs | Adds ConfigureAwait(false) after installer check execution. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| try | ||
| { | ||
| (output, error) = await Task.Run(() => RunInstallerCheck(CommandToSend)); | ||
| (output, error) = await Task.Run(() => RunInstallerCheck(CommandToSend)).ConfigureAwait(false); |
|
|
||
| // Currently thread change necessary, otherwise exception in board reset process. | ||
| await Task.Delay(50).ContinueWith(_ => Scan()); | ||
| await Task.Delay(50).ContinueWith(_ => Scan()).ConfigureAwait(false); |
Comment on lines
+198
to
+199
| var devices = await Task.Run(() => di.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly).ToList()) | ||
| .ConfigureAwait(false); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Build for this pull request: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This resolves a deadlocking issue in JoystickManager where
Task.Runis used without scheduling the operation to continue on a background thread. The UI thread is busy doing other workso the application hangs until it is able to continue again. This manifested itself on lower end hardware, though that isn't conclusive yet.Many other files have been updated to append
ConfigureAwait(false)where a task is awaited.Related issues
fixes #3324
Out-of-scope