-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ios/catalyst] fix memory leak in gestures (#21887)
* [ios/catalyst] fix memory leak in gestures Related: #21089 Context: jonathanpeppers/iOSMauiCollectionView@547b7fa Doing something like this and running on iOS or Catalyst: <CollectionView.ItemTemplate> <DataTemplate> <Label Text="{Binding Name}"> <Label.GestureRecognizers> <TapGestureRecognizer Command="{Binding BindingContext.Command}" /> </Label.GestureRecognizers> </Label> </DataTemplate> </CollectionView.ItemTemplate> Causes a memory leak. I could reproduce this in a test that is a bit more elaborate than #21089, showing issues for different types of gestures: * Usage of `ShouldReceiveTouch` creates a cycle: * `GesturePlatformManager` -> `UIGestureRecognizer.ShouldReceiveTouch` -> `GesturePlatformManager` * We can move `ShouldReceiveTouch` to a "proxy" class, and avoid the cycle. * `PanGestureRecognizer` has closures that cause the same cycle: * `this.PlatformView` -> `eventTracker?.PlatformView` * `panRecognizer` -> `((PanGestureRecognizer)panGestureRecognizer)` * These already had a `WeakReference` to use instead, but we could just make use of them. There *may* be a general problem with `CollectionView` in how it doesn't tear down `GesturePlatformManager` in the same way for children. But in either case, the problems above are cycles that should be broken. * Fix test on Windows
- Loading branch information
1 parent
b0e562e
commit be17057
Showing
2 changed files
with
97 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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