-
Notifications
You must be signed in to change notification settings - Fork 29.8k
[web] Fix potential race condition in ClickDebouncer #173294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
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 addresses a potential race condition in the ClickDebouncer. The fix is straightforward and correct: it adds a check to ensure that debouncing has not been cancelled before proceeding with setting the debouncer state. The newly added test case is comprehensive and accurately simulates the race condition, confirming the effectiveness of the fix. The changes are well-implemented and improve the robustness of the pointer event handling.
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
| /// | ||
| /// This method is called asynchronously from [_maybeStartDebouncing]. | ||
| void _doStartDebouncing(DomEvent event, List<ui.PointerData> data) { | ||
| // It's possible that debouncing was cancelled between the pointerdown event and the execution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nit: "canceled" with one "l" is the American spellling, see https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md#spell-words-in-identifiers-and-comments-correctly.
Based on Gemini's comment: flutter#173072 (comment)
Based on Gemini's comment: flutter#173072 (comment)
Based on Gemini's comment: flutter#173072 (comment)
Based on Gemini's comment: flutter#173072 (comment)
Based on Gemini's comment: flutter#173072 (comment)
Based on Gemini's comment: #173072 (comment)