Repository navigation
Fix ArgumentNullException in chrome hit test after window close - #22409
Merged
Merged
Conversation
Member
|
@cla-avalonia come on, say something |
Collaborator
|
Contributor
Author
|
@cla-avalonia agree |
NuGet packagesThe packages for this pull request have been published (workflow run):
|
Member
|
Meanwhile, this PR is a good fix. |
MrJul
pushed a commit
that referenced
this pull request
Oct 9, 2026
* Add failing test for chrome hit test on a closed window * Return null from chrome hit test once the root visual is cleared
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.
What does the pull request do?
Makes
PresentationSource.HitTestChromeElementreturnnullonceRootVisualhas been cleared byTopLevel.HandleClosed().What is the current behavior?
A closed window with an extended client area can still receive
WM_NCHITTESTand other non-client messages.WindowImpl.HitTestVisualpasses them toHitTestChromeElement, which dereferences the nullRootVisualand throwsArgumentNullExceptioninside the window procedure, so the process terminates.What is the updated/expected behavior with this PR?
A closed window reports no chrome element and the non-client hit test falls back to the regular result.
How was the solution implemented (if it's not obvious)?
The check is in
PresentationSourcerather than in the Win32WindowImpl, so the X11 and Wayland callers are covered too. Both already treatnullas "no chrome element".I ran the repro from the issue on Windows 11 with each
WindowDecorationsvalue, closing the window both withClose()and withSC_CLOSE. Before the change every window with an extended client area crashed the process (0xC000041D); after it the non-client messages are handled normally. Hit-test results on open windows are the same before and after.Checklist
Breaking changes
None.
Fixed issues
Fixes #22324