Skip to content

Conversation

@SamBent
Copy link
Contributor

@SamBent SamBent commented Aug 3, 2021

Addresses Issue #4982. This is a port from a servicing fix in .NET 4.7-4.8.

Description

HwndSource shuts down its stylus stack when it receives WM_DESTROY. In the repro it doesn't receive WM_DESTROY, and therefore leaks many resources associated with stylus/touch including the HwndSource object itself, but most notably the handles used for communication with WISP.

More precisely, the logic for WM_DESTROY lives in the PublicHooks message filter, which is only called if public hooks have been added to the HwndSource. All the places where WPF itself creates the HwndSource add hooks - the chief examples are Window and Popup - so "normal" apps don't leak. But the repro creates HwndSource directly and doesn't add hooks, hence it leaks.

Fixed by adding WM_DESTROY logic to the Input message filter, which is always called (unless a public hook handles the WM_DESTROY message).

Customer Impact

App eventually crashes when it runs out of handles.

Regression

Introduced in 4.7.

Testing

Ad-hoc around customer scenario.
Standard regression testing

Risk

Low. Port of a .NETFx servicing fix released earlier this year.

@SamBent SamBent requested a review from a team as a code owner August 3, 2021 00:16
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label Aug 3, 2021
@ghost ghost requested review from fabiant3 and ryalanms August 3, 2021 00:16
@SamBent SamBent merged commit bef41b2 into dotnet:main Aug 17, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Apr 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

PR metadata: Label to tag PRs, to facilitate with triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants