ui: take the keyboard watcher's recognizer off the window in deinit too - #2404
Merged
Merged
Conversation
The tap recognizer that decides whether a tap landed in a text field lives on the WINDOW, which outlives the view that added it, so it has to be removed by hand. dismantleUIView and didMoveToWindow cover the teardowns SwiftUI tells us about; nothing covered the ones it does not. A left-behind recognizer is quiet rather than harmful, since UIGestureRecognizer holds its target weakly and nothing fires. But one accumulates per appearance, and once the Probe is gone its delegate is nil, so the filter that makes the recognizer safe (ignore touches that land in a text input, ignore touches outside this screen's controller) is no longer applied to it. From reviewing #2403, which added the watcher.
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.
Found reviewing #2403, which added the watcher.
The tap recognizer that decides whether a tap landed in a text field lives on the WINDOW, which outlives the view that added it, so it has to be removed by hand.
dismantleUIViewanddidMoveToWindowcover the teardowns SwiftUI tells us about. Nothing covered the ones it does not.A left-behind recognizer is quiet rather than harmful:
UIGestureRecognizerholds its target weakly, so nothing fires. But one accumulates per appearance, and once theProbeis gone its delegate is nil too, so the filter that makes the recognizer safe in the first place (stand aside for touches in a text input, and for touches outside this screen's controller) is no longer being applied to it.One line, plus why.