Avoid unnecessarty unwwrap of _lastPendingEventTimestamp#121553
Avoid unnecessarty unwwrap of _lastPendingEventTimestamp#121553reidbaker wants to merge 6 commits intoflutter:masterfrom reidbaker:npe
Conversation
christopherfujino
left a comment
There was a problem hiding this comment.
I'll defer approval to @dkwingsmt; I have no idea how this code works, I just copy pasted from buganizer to a github issue :)
| // ignore: public_member_api_docs | ||
| // | ||
| // Exposed to test for null timestamp. |
There was a problem hiding this comment.
fly-by comment: please don't do this. Anything that is public needs docs.
There was a problem hiding this comment.
(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())); | ||
|
|
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
| @visibleForTesting | ||
| void checkStart(Duration? timestamp, int pointer) { |
| GestureBinding.instance.handleEvent(up90, HitTestEntry(MockHitTestTarget())); | ||
| GestureBinding.instance.handleEvent(up91, HitTestEntry(MockHitTestTarget())); | ||
|
|
||
| // Regression test for https://github.com/flutter/flutter/issues/112403. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Someone else is welcome to take this pr over if they would like.
|
Closing this pr I allocated a small timebox and I am past the effort I decided to spend. |
Takeover of /pull/117551
This fixes /issues/112403 and b/249091367
_lastPendingEventTimestampwhich sometimes causes "Null check operator used on a null"Pre-launch Checklist
///).