Skip to content

Fix stale eagerWinner reference in GestureArenaManager when rejected before arena close#187008

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
ishaq2321:fix/eagerWinner-stale-reference-clear
Jul 15, 2026
Merged

Fix stale eagerWinner reference in GestureArenaManager when rejected before arena close#187008
auto-submit[bot] merged 2 commits into
flutter:masterfrom
ishaq2321:fix/eagerWinner-stale-reference-clear

Conversation

@ishaq2321

@ishaq2321 ishaq2321 commented May 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a stale eagerWinner reference in GestureArenaManager. When a member accepts while the arena is open (becoming eagerWinner) and then rejects while still open, eagerWinner retained a dangling reference to the now-rejected member. When the arena later closed, it resolved in favor of the stale member, incorrectly rejecting all legitimate remaining members.

Fixes #187474

Changes

  • Clear state.eagerWinner when the rejected member matches the current eager winner in _resolve()
  • New test: Eager winner should be cleared when the eager winner rejects while arena is still open in arena_test.dart

Tests

All 345 gesture tests pass.

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. f: gestures flutter/packages/flutter/gestures repository. labels May 23, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates the GestureArenaManager in arena.dart to clear the eagerWinner reference if that member is rejected while the arena remains open. This change prevents potential issues where a stale eager winner could be incorrectly accepted after rejection. Additionally, a new test case in arena_test.dart verifies that the eager winner is correctly cleared and that subsequent arena resolution via sweep functions as expected. I have no feedback to provide.

@ishaq2321
ishaq2321 force-pushed the fix/eagerWinner-stale-reference-clear branch from 08cc142 to 400b8cc Compare May 23, 2026 15:08
@ishaq2321 ishaq2321 changed the title Fix stale eagerWinner reference in GestureArenaManager when rejected before arena close Fix stale _entries and pointer tracking in OneSequenceGestureRecognizer.rejectGesture May 23, 2026

@Piinks Piinks 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.

Hey @ishaq2321 thanks for contributing! Regarding "Fixes two related architectural issues in the gesture arena system:", can you please open issues for each of these in the repository? It's also best to have 1 PR fix 1 issue. Thanks!

@ishaq2321

Copy link
Copy Markdown
Contributor Author

Hey @Piinks, thanks for the review. Opened two issues as requested:

PR description updated to link both. All 345 gesture tests still green. Let me know if anything else is needed.

@Piinks Piinks 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.

Thanks for filing issues for these!

It's also best to have 1 PR fix 1 issue.

This is still relevant here. This should be split into two PRs, one for each issue. Thanks!

@ishaq2321

Copy link
Copy Markdown
Contributor Author

Split into two PRs as requested. This one now covers only the eagerWinner fix (#187474). The rejectGesture cleanup is now in #187515.

@ishaq2321 ishaq2321 changed the title Fix stale _entries and pointer tracking in OneSequenceGestureRecognizer.rejectGesture Fix stale eagerWinner reference in GestureArenaManager when rejected before arena close Jun 3, 2026
@ishaq2321
ishaq2321 force-pushed the fix/eagerWinner-stale-reference-clear branch from ecae7a8 to 89da8f5 Compare June 3, 2026 16:06
@Piinks
Piinks force-pushed the fix/eagerWinner-stale-reference-clear branch from 89da8f5 to c16cee1 Compare June 12, 2026 00:41
Piinks
Piinks previously approved these changes Jun 12, 2026

@Piinks Piinks 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.

This LGTM

@Piinks Piinks added the CICD Run CI/CD label Jun 12, 2026
@ishaq2321
ishaq2321 force-pushed the fix/eagerWinner-stale-reference-clear branch from c16cee1 to 9b804ef Compare June 12, 2026 23:53
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 12, 2026
@Piinks
Piinks requested a review from Renzo-Olivares June 23, 2026 22:16
@ishaq2321

Copy link
Copy Markdown
Contributor Author

Hi @Piinks @Renzo-Olivares,

Thank you for the approval on this PR! I noticed it hasn't been merged yet, and I was wondering if we could move forward with the final steps.

I am currently at my limit of 4 open PRs, which is preventing me from opening new ones. If there is anything else needed from my side to get this across the finish line, please let me know—I am happy to help. Otherwise, I would appreciate it if this could be merged so I can continue with my next contribution.

Thanks again!

@Piinks
Piinks force-pushed the fix/eagerWinner-stale-reference-clear branch from 9b804ef to f3d7f00 Compare July 7, 2026 15:18
@Piinks Piinks added the CICD Run CI/CD label Jul 7, 2026
@Piinks

Piinks commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

It looks like we still need a second approval here, it's almost ready to merge thanks for your patience and contributions!

@Piinks

Piinks commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

It looks like this is not targeting the right branch, can you update to target master, not main?

@ishaq2321
ishaq2321 changed the base branch from main to master July 7, 2026 15:24
@ishaq2321
ishaq2321 dismissed Piinks’s stale review July 7, 2026 15:24

The base branch was changed.

@ishaq2321

Copy link
Copy Markdown
Contributor Author

Done — updated to target master. Thanks for the heads up @Piinks!

@ishaq2321
ishaq2321 force-pushed the fix/eagerWinner-stale-reference-clear branch from f3d7f00 to b9774c0 Compare July 7, 2026 15:32
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Jul 7, 2026
@ishaq2321

Copy link
Copy Markdown
Contributor Author

@Piinks rebased onto latest master and target branch fixed. This was previously approved (LGTM) — the approval was reset when we changed the base from main to master. Ready for re-review when you get a chance. Thanks!

@Piinks Piinks added the CICD Run CI/CD label Jul 7, 2026
Piinks
Piinks previously approved these changes Jul 7, 2026

@Piinks Piinks 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.

LGTM

Renzo-Olivares
Renzo-Olivares previously approved these changes Jul 7, 2026

@Renzo-Olivares Renzo-Olivares 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.

LGTM, thank you for the contribution!

@Renzo-Olivares

Copy link
Copy Markdown
Contributor

@ishaq2321 the linux analyzer issues need to be resolved before landing this.

   info • Omit the type annotation on a local variable when the type is obvious. Try removing the type annotation • packages/flutter/test/gestures/arena_test.dart:175:11 • omit_obvious_local_variable_types
   info • Omit the type annotation on a local variable when the type is obvious. Try removing the type annotation • packages/flutter/test/gestures/arena_test.dart:176:11 • omit_obvious_local_variable_types
   info • Omit the type annotation on a local variable when the type is obvious. Try removing the type annotation • packages/flutter/test/gestures/arena_test.dart:177:11 • omit_obvious_local_variable_types
   info • Omit the type annotation on a local variable when the type is obvious. Try removing the type annotation • packages/flutter/test/gestures/arena_test.dart:178:11 • omit_obvious_local_variable_types
warning • The value of the local variable 'entryB' isn't used. Try removing the variable or using it • packages/flutter/test/gestures/arena_test.dart:181:29 • unused_local_variable
warning • The value of the local variable 'entryC' isn't used. Try removing the variable or using it • packages/flutter/test/gestures/arena_test.dart:182:29 • unused_local_variable

…before arena close

When a GestureArenaMember calls resolve(GestureDisposition.accepted)
while the arena is still open, it becomes the eagerWinner via
state.eagerWinner ??= member. If that same member subsequently calls
resolve(GestureDisposition.rejected) while the arena remains open,
the _resolve method removes the member from state.members but never
clears state.eagerWinner. This leaves a dangling pointer to an
already-rejected-and-removed member.

When the arena later closes, _tryToResolveArena checks
state.eagerWinner != null and delegates to _resolveInFavorOf with
the stale member. This causes:
  - The stale member to receive acceptGesture despite having already
    been rejected (assertion failure in debug mode via
    _CombiningGestureArenaMember._close)
  - All remaining legitimate members to be incorrectly rejected

Fix: Clear state.eagerWinner in the rejected case when the rejected
member matches the current eagerWinner.

Co-authored-by: Muhammad Ishaq Khan <[email protected]>
@ishaq2321
ishaq2321 dismissed stale reviews from Renzo-Olivares and Piinks via 3a7bb14 July 13, 2026 23:49
@ishaq2321
ishaq2321 force-pushed the fix/eagerWinner-stale-reference-clear branch from b9774c0 to 3a7bb14 Compare July 13, 2026 23:49
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Jul 13, 2026
@Renzo-Olivares Renzo-Olivares added the CICD Run CI/CD label Jul 14, 2026

@Renzo-Olivares Renzo-Olivares 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.

Re-LGTM

@Renzo-Olivares
Renzo-Olivares requested a review from Piinks July 14, 2026 21:14

@Piinks Piinks 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.

re-LGTM too!

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 14, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 14, 2026
@auto-submit

auto-submit Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/187008, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@justinmc

Copy link
Copy Markdown
Contributor

The Google tests failed. They don't usually flake but it looked like an infra flake to me, so I reran them.

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 14, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Jul 15, 2026
Merged via the queue into flutter:master with commit 8ff8b67 Jul 15, 2026
101 of 102 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 15, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jul 15, 2026
flutter/flutter@846664b...fc1ad95

2026-07-15 [email protected] [iOS] Migrate FlutterKeyboardInsetManager to Swift (flutter/flutter#189425)
2026-07-15 [email protected] Roll Dart SDK from 05bf153370c4 to 0c408ff6dce9 (4 revisions) (flutter/flutter#189487)
2026-07-15 [email protected] Implement UberSDF lines to replace LineContents-based AA lines (flutter/flutter#188514)
2026-07-15 [email protected] Fix stale eagerWinner reference in GestureArenaManager when rejected before arena close (flutter/flutter#187008)
2026-07-15 [email protected] Disable some Windows tests that are flaking on CI (flutter/flutter#189477)
2026-07-15 dmgr Added unified check-run user manual (flutter/flutter#189453)
2026-07-15 [email protected] Roll Skia from 88954ef8f36d to ab2410bc857c (9 revisions) (flutter/flutter#189474)
2026-07-14 [email protected] [agents] Refactor shepherd-prs skill into a pure Markdown runbook using native gh CLI (flutter/flutter#189095)
2026-07-14 [email protected] Add missing name to mirroring workflow (flutter/flutter#189439)
2026-07-14 [email protected] Add support for WASM deferred loading. (flutter/flutter#189308)
2026-07-14 [email protected] fix `templateDefaultGradleVersion` todo (flutter/flutter#189466)
2026-07-14 [email protected] Roll Fuchsia Linux SDK from oOETA0ISPouDt2xBo... to lLFbh5kFWbUGgC9Ek... (flutter/flutter#189469)
2026-07-14 [email protected] Use ServicesBinding.instance.exitApplication instead of exit(0) in multiple_windows example (flutter/flutter#189364)
2026-07-14 [email protected] Add CpuArch to the Device class (flutter/flutter#189207)
2026-07-14 [email protected] Fix space formatting in cherry-pick label for flutter_cp.dart (flutter/flutter#189463)
2026-07-14 [email protected] Roll pub packages (flutter/flutter#189454)
2026-07-14 [email protected] [flutter_tools] Format plugin example template to match dart format (flutter/flutter#188382)
2026-07-14 [email protected] Move renamed x64->ARM benchmarks out of bringup (flutter/flutter#189400)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD f: gestures flutter/packages/flutter/gestures repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Gestures] GestureArenaManager retains stale eagerWinner reference after member rejects while arena is open

4 participants