Skip to content

ui: take the keyboard watcher's recognizer off the window in deinit too - #2404

Merged
ryanbr merged 1 commit into
mainfrom
2404-probe-deinit
Sep 23, 2026
Merged

ryanbr merged 1 commit into
mainfrom
2404-probe-deinit

Conversation

@ryanbr

@ryanbr ryanbr commented Sep 23, 2026

Copy link
Copy Markdown
Owner

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. 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: UIGestureRecognizer holds its target weakly, so nothing fires. But one accumulates per appearance, and once the Probe is 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.

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.
@ryanbr
ryanbr merged commit c9d928c into main Sep 23, 2026
4 checks passed
@ryanbr
ryanbr deleted the 2404-probe-deinit branch September 23, 2026 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant