Skip to content

Conversation

@reidbaker
Copy link
Contributor

@reidbaker reidbaker commented Feb 27, 2023

Takeover of /pull/117551
This fixes /issues/112403 and b/249091367

  • Avoid unnecessary unwrap of _lastPendingEventTimestamp which sometimes causes "Null check operator used on a null"
  • Fix formatting again
  • expose checkStart to tests and verify that null timestamp does not crash

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

@flutter-dashboard flutter-dashboard bot added f: gestures flutter/packages/flutter/gestures repository. framework flutter/packages/flutter repository. See also f: labels. c: contributor-productivity Team-specific productivity, code health, technical debt. labels Feb 27, 2023
@reidbaker reidbaker marked this pull request as ready for review February 27, 2023 22:38
Copy link
Contributor

@christopherfujino christopherfujino left a comment

Choose a reason for hiding this comment

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

I'll defer approval to @dkwingsmt; I have no idea how this code works, I just copy pasted from buganizer to a github issue :)

Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +452 to +454
// ignore: public_member_api_docs
//
// Exposed to test for null timestamp.
Copy link
Member

Choose a reason for hiding this comment

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

fly-by comment: please don't do this. Anything that is public needs docs.

Copy link
Member

Choose a reason for hiding this comment

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

(ideally, we would find a better way to test this without making it public, if we can't it needs real docs because dartdoc will process it and publish the method to our docs)


GestureBinding.instance.handleEvent(up90, HitTestEntry(MockHitTestTarget()));
GestureBinding.instance.handleEvent(up91, HitTestEntry(MockHitTestTarget()));

Copy link
Member

Choose a reason for hiding this comment

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

nit: remove one of the blank lines.

GestureBinding.instance.handleEvent(up91, HitTestEntry(MockHitTestTarget()));

// Regression test for https://github.com/flutter/flutter/issues/112403.
v.checkStart(null, down91.pointer);
Copy link
Member

Choose a reason for hiding this comment

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

Hm, I believe this isn't a full regression test. If someone where to accidentally add the exclamation mark back to line 366 in monodrag.dart (the root cause for the crash), this test would continue to pass?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just calling acceptGesture twice in a row would trigger this bug.

There seem to be several ways that the last event can get nulled out and not reset depending on which sequence of pointer events get submitted. I don't know which of those would be expected or not and which we should have better test coverage of.

Comment on lines +455 to +456
@visibleForTesting
void checkStart(Duration? timestamp, int pointer) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: indentation is off

GestureBinding.instance.handleEvent(up90, HitTestEntry(MockHitTestTarget()));
GestureBinding.instance.handleEvent(up91, HitTestEntry(MockHitTestTarget()));

// Regression test for https://github.com/flutter/flutter/issues/112403.
Copy link
Member

Choose a reason for hiding this comment

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

I believe we don't need tests like this for null safety, it's considered "code refactor with no semantic change".
#114111 (comment)

https://github.com/flutter/flutter/wiki/Tree-hygiene#tests

refactors with no semantic change (e.g. null safety migrations)

However I believe @dkwingsmt's point in the last PR was: do we understand why is this null #117551 (comment) ? If it's just a mistake from the null migration then this test can be removed. However if it's a legitimate state to be in, can we exercise that state in a unit test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No I do not understand why this is null. I responded to an internal request for a 1p customer who had their pr closed because of a lack of tests. When I saw the pr was a null check crash and they were seeing this happen in the field I thought that it was worth timeboxing writing a test that triggers a null check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Someone else is welcome to take this pr over if they would like.

@reidbaker
Copy link
Contributor Author

Closing this pr I allocated a small timebox and I am past the effort I decided to spend.

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

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. 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

7 participants