Repository navigation
fix(input): Drop a released pointer's gesture recognizers (backport #25589) - #25681
Merged
Merged
Conversation
Press and release the mouse on an element with a ManipulationMode, remove it from the tree, and check that the input manager does not keep it alive. The test moves the mouse before collecting so that PointerRoutedEventArgs.LastPointerEvent no longer points at it. (cherry picked from commit 986d906)
When a manipulation starts, the element's GestureRecognizer is queued in the input manager for its pointer type, and the queue is removed on release or cancel. PointerTypePseudoDictionary.Remove only cleared the presence flag, though, and left the queue in its slot. The element that last started a manipulation with a given pointer type therefore stayed reachable from the input manager, with its visual tree and DataContext, until another manipulation with that pointer type replaced the queue, which might never happen. Remove now clears the stored value too. Fixes #25588 (cherry picked from commit d412796)
2 of 5 tasks
Contributor
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
Contributor
|
|
ajpinedam
approved these changes
Oct 25, 2026
2 of 5 tasks
Member
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
agneszitte
approved these changes
Nov 3, 2026
Merged
1 task done
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.
GitHub Issue: closes #25588
PR Type:
🐞 Bugfix
What changed? 🚀
When a manipulation starts on a UIElement, the input manager queues that element's gesture recognizer for the pointer type, and it removes the queue when the pointer is released or cancelled.
PointerTypePseudoDictionary.Removeonly cleared the presence flag and left the queue in its slot. So the element that last started a manipulation with a given pointer type stayed reachable from the input manager, with its visual tree andDataContext, until another manipulation with that pointer type replaced the queue. That may never happen.In a WebAssembly app, a CommunityToolkit
DataGridscrolled with the mouse kept its page alive this way after the user navigated away: 80 MB of a 282 MB managed heap (see the issue for the heap dump path).Removenow clears the stored value too, asClearForFataErroralready did.Tests
Given_InputManager.When_ManipulableElementReleasedAndRemoved_Then_Collected:BorderwithManipulationMode = All, presses and releases the mouse on it, and checks thatManipulationStartingfired, so the recognizer really was registered.PointerRoutedEventArgs.LastPointerEvent, which holds the last event's source until the next pointer event, and doesn't start a manipulation.Results on Skia desktop:
Given_InputManager: 24 passed, 10 skipped.Given_ScrollViewer: 77 passed.Given_ScrollViewer_Zoom: 15 passed.Given_GestureRecognizer: 2 passed.Given_ManipulationExtensions: 3 passed.Given_UIElement: 543 passed and 3 failed. The failures areWhen_Child_ActualOffset,When_Nested_Child_ActualOffsetandWhen_Root_Margin_ActualOffset, which also fail on master with the same values on this machine (display scaling).Not changed
These were found while checking what else holds a released element. Each one is replaced or cleared by the next pointer event or press, so none of them is a lasting leak:
PointerRoutedEventArgs.LastPointerEvent, and its copy inCoreWindow.LastPointerEvent: until the next pointer event.DirectManipulationCollectionuntilScavenge()runs on the next pointer enter or press._pendingDirectManipulationCancelRequester: until the next press.PR Checklist ✅
Screenshots Compare Test Runresults.This is an automatic backport of pull request #25589 done by [Mergify](https://mergify.com).