Skip to content

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

Description

@ishaq2321

Bug Description

When a GestureArenaMember calls resolve(GestureDisposition.accepted) while the arena is open, it becomes the eagerWinner via state.eagerWinner ??= member. If that same member subsequently calls resolve(GestureDisposition.rejected) while the arena is still open, _resolve removes the member from state.members but never clears state.eagerWinner. This leaves a dangling reference 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

Steps to Reproduce

  1. Add 3 members (A, B, C) to a gesture arena
  2. Member A calls resolve(accepted) → becomes eagerWinner
  3. Member A calls resolve(rejected) → removed from members, but eagerWinner still points to A
  4. Close the arena → stale eagerWinner (A) incorrectly wins, B and C are rejected

Expected Behavior

When a rejected member was the eagerWinner, eagerWinner should be cleared so the arena resolves normally among remaining members.

Fix

PR: #187008

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

case GestureDisposition.rejected:
  if (state.eagerWinner == member) {
    state.eagerWinner = null;
  }
  state.members.remove(member);

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listframeworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions