Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@mdebbar
Copy link
Contributor

@mdebbar mdebbar commented Sep 22, 2021

If we don't dispose of BrowserHistory instances, they keep listening to popstate events even after a hot restart. So we end up with duplicate listeners.

In this PR, we make sure to always dispose of BrowserHistory instance but without resetting the browser history entries (to keep the effect of this PR).

Fixes flutter/flutter#90031
Fixes flutter/flutter#83864

@mdebbar mdebbar added the platform-web Code specifically for the web engine label Sep 22, 2021
@mdebbar mdebbar requested a review from chunhtai September 22, 2021 18:39
@google-cla google-cla bot added the cla: yes label Sep 22, 2021
Copy link
Contributor

@chunhtai chunhtai left a 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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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 {
Copy link
Contributor

Choose a reason for hiding this comment

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

duplicate code?

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah gotcha

@mdebbar mdebbar requested a review from chunhtai September 22, 2021 19:57
Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM

@cdprete
Copy link

cdprete commented Dec 5, 2021

Hi.
I'm actually experiencing the issue fixed here with Flutter 2.5.3.
Flutter doctor output is at #94675

@mdebbar mdebbar deleted the fix_history_assertion branch January 17, 2023 18:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes platform-web Code specifically for the web engine

Projects

None yet

3 participants