-
Notifications
You must be signed in to change notification settings - Fork 6k
[web] Fix disposal of browser history on hot restart #28805
Conversation
chunhtai
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, with some comments
|
|
||
| @override | ||
| Future<void> tearDown() async { | ||
| if (_isDisposed || urlStrategy == null) { |
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.
I am not sure whether this will be a problem or not. If the browserhistory is disposed, it can't be teardown because this check.
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.
Nice catch! Let me use a separate boolean _isTornDown.
| // TODO(mdebbar): https://github.com/flutter/flutter/issues/50836 | ||
| skip: browserEngine == BrowserEngine.edge); | ||
|
|
||
| test('disposes of its listener without touching history', () async { |
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.
duplicate code?
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.
They are slightly different. One for single entry and one for multi entry.
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.
ah gotcha
chunhtai
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
|
Hi. |
If we don't dispose of
BrowserHistoryinstances, they keep listening topopstateevents even after a hot restart. So we end up with duplicate listeners.In this PR, we make sure to always dispose of
BrowserHistoryinstance but without resetting the browser history entries (to keep the effect of this PR).Fixes flutter/flutter#90031
Fixes flutter/flutter#83864