Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes an issue that can cause Avalonia-based Windows applications to crash on termination #17190

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

ryannewington
Copy link
Contributor

What does the pull request do?

The GetMessage call in RunLoop() of WinUiCompositorConnection.cs has been updated to process the result of GetMessage, and terminate the message loop if a WM_QUIT message is received on the pump.

What is the current behavior?

Presently the WM_QUIT message is ignored and the loop re-enters the GetMessage call, causing an unmanaged exception and process crash.

What is the updated/expected behavior with this PR?

The loop terminates without throwing an error when windows is signalling the message pump to stop.

How was the solution implemented (if it's not obvious)?

The logic was copied from the Avalonia dispatcher implementation here, which correctly processes the result of GetMessage

Checklist

  • Added unit tests (if possible)? - Not sure how to UT this one
  • Added XML documentation to any related classes? - Not applicable as its a private method implementation change
  • Consider submitting a PR to https://github.com/AvaloniaUI/avalonia-docs with user documentation - Not applicable

Breaking changes

None

Obsoletions / Deprecations

An optional consideration is to remove the hook to AppDomain.CurrentDomain.ProcessExit that was added as part of PR #9000 / Issue #8261 which is probably redundant now, but doesn't cause any harm having it there

Fixed issues

Fixes #17188
Fixes #8261 (for real this time)

…he GetMessage call in RunLoop() of WinUiCompositorConnection.cs has been updated to process the result of GetMessage, and terminate the message loop if a WM_QUIT message is received on the pump.

Presently the WM_QUIT message is ignored and the loop re-enters the GetMessage call, causing an unmanaged exception and process crash.

AvaloniaUI#17188
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0052387-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@cla-avalonia
Copy link
Collaborator

cla-avalonia commented Oct 4, 2024

  • All contributors have signed the CLA.

@ryannewington
Copy link
Contributor Author

@cla-avalonia agree

Copy link
Member

@MrJul MrJul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change makes perfect sense, we shouldn't ignore WM_QUIT.

LGTM, thank you!

@MrJul MrJul added the backport-candidate-11.2.x Consider this PR for backporting to 11.2 branch label Oct 4, 2024
@MrJul MrJul added this pull request to the merge queue Oct 4, 2024
Merged via the queue into AvaloniaUI:master with commit aabd038 Oct 4, 2024
11 checks passed
maxkatz6 pushed a commit that referenced this pull request Oct 27, 2024
…he GetMessage call in RunLoop() of WinUiCompositorConnection.cs has been updated to process the result of GetMessage, and terminate the message loop if a WM_QUIT message is received on the pump. (#17190)

Presently the WM_QUIT message is ignored and the loop re-enters the GetMessage call, causing an unmanaged exception and process crash.

#17188
@maxkatz6 maxkatz6 added backported-11.2.x and removed backport-candidate-11.2.x Consider this PR for backporting to 11.2 branch labels Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

App crashing on exit on Windows 11 24H2 [.NET Framework] Windows app crashes when closing
5 participants