Skip to content

[release/10.0.1xx] [UIKit] Fix UIScreenEdgePanGestureRecognizer(Action<UIScreenEdgePanGestureRecognizer>) constructor. Fixes #27066 - #27391

Open
rolfbjarne wants to merge 1 commit into
release/10.0.1xxfrom
dev/rolf/backport-pr-27079-release/10.0.1xx-2026-11-19
Open

rolfbjarne wants to merge 1 commit into
release/10.0.1xxfrom
dev/rolf/backport-pr-27079-release/10.0.1xx-2026-11-19

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

UIPanGestureRecognizer's internal constructor (IntPtr sel, Token token) was
passing (token, sel) to its base constructor instead of (sel, token), resolving
to UIGestureRecognizer(NSObject, IntPtr) instead of UIGestureRecognizer(IntPtr, Token).
As a result, the callback token for UIScreenEdgePanGestureRecognizer(Action<T>)
was never stored in the recognizers dictionary or marked dirty, allowing it to
be garbage collected before the gesture action could be invoked.

Fixes #27066

🤖 Pull request created by Copilot


Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com
Co-authored-by: Rolf Bjarne Kvinge rokvin@microsoft.com

Backport of #27079.

…estureRecognizer>)` constructor. Fixes #27066 (#27079)

`UIPanGestureRecognizer`'s internal constructor (IntPtr sel, Token token) was
passing (token, sel) to its base constructor instead of (sel, token), resolving
to `UIGestureRecognizer(NSObject, IntPtr)` instead of `UIGestureRecognizer(IntPtr, Token)`.
As a result, the callback token for `UIScreenEdgePanGestureRecognizer(Action<T>)`
was never stored in the recognizers dictionary or marked dirty, allowing it to
be garbage collected before the gesture action could be invoked.

Fixes #27066

🤖 Pull request created by Copilot

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Rolf Bjarne Kvinge <rokvin@microsoft.com>
@rolfbjarne rolfbjarne added backported ready-to-review This PR is ready to review/merge. labels Nov 19, 2026
Copilot AI balanced review requested due to automatic review settings November 19, 2026 09:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test keeps the recognizer strongly referenced, so it cannot detect a missing MarkDirty() call that could leave the managed peer and callback collectible; it should also assert the registered-toggle-reference flag.

1 open issue
What changed in this PR

Backports #27079 to release/10.0.1xx, fixing lost UIScreenEdgePanGestureRecognizer constructor callbacks in the UIKit bindings (#27066).

Changes:

  • Corrects constructor argument order so callback tokens are retained and MarkDirty() is called.
  • Adds a non-tvOS regression test for target registration and callback delivery after garbage collection.
File Description
tests/​monotouch-test/​UIKit/​GestureRecognizerTest.cs Adds screen-edge pan callback regression coverage.
src/​UIKit/​UIGestureRecognizer.cs Routes the internal pan constructor through the token-tracking base overload.

Review effort: Balanced

};

using var recognizer = new UIScreenEdgePanGestureRecognizer (callback);
Assert.That (recognizer.GetTargets (), Is.Not.Empty, "GetTargets");

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backported ready-to-review This PR is ready to review/merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants