Skip to content

Conversation

@dnfield
Copy link
Contributor

@dnfield dnfield commented Feb 28, 2023

Re-attempts #121553, which itself was another attempt at #117551

Fixes #112403 and b/249091367

I am not super familiar with our gesture recognizer API, so I tried to tag some people here who are probably more familiar and can help me out if my unit test is doing something super weird. My main goal here was just to have a test that covers the bad behavior. Unfortunately, reporters of this bug don't have clear repros, they just have bug reports from the field about null checks going wrong.

@reidbaker FYI - this is a slightly different take on the PR you opened yesterday.
@jmagman FYI as well since youc ommented on the PR yesterday.

@flutter-dashboard flutter-dashboard bot added f: gestures flutter/packages/flutter/gestures repository. framework flutter/packages/flutter repository. See also f: labels. labels Feb 28, 2023
Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

final DragGestureRecognizer recognizer = VerticalDragGestureRecognizer();
const PointerDownEvent event = PointerDownEvent(timeStamp: Duration(days: 10));

expect(recognizer.debugLastPendingEventTimestamp, null);
Copy link
Member

Choose a reason for hiding this comment

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

In theory, this test would work without exposing (and checking) debugLastPendingEventTimestamp. If the bug were to be re-introduced, it would still crash on line 34, no?

I think I would prefer that over exposing the debug field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would crash, but it wouldn't actually be asserting anything besides that methods can be called.

My main concern over not exposing the field is that someone would be able to easily refactor the internals of the class and the test would still pass but they'd re-introduce the failure case. This actually asserts that acceptGesture can tolerate that field being null.

Comment on lines +32 to +33
// Not entirely clear how this can happen, but the bugs mentioned above show
// we can end up in this state empircally.
Copy link
Member

Choose a reason for hiding this comment

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

This would really be interesting to figure out... Wondering if that's a bug somewhere in the framework in how we use the gesture detector, or in user code, or do the embedders send bogus events??

(Not actionable for this PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I suspect there's something off here but I don't know that subsystem well enough to know. I'm half hoping one of the people I tagged on this PR will know :)

@dnfield dnfield added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 28, 2023
@auto-submit auto-submit bot merged commit c8aa37d into flutter:master Feb 28, 2023
@dnfield dnfield deleted the nnbd_monodrag branch February 28, 2023 23:09
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 1, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 1, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 1, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 1, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 1, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 1, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 1, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 3, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 3, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App 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.

DragGestureRecognizer.acceptGesture null check operator used on a null value

2 participants