-
Notifications
You must be signed in to change notification settings - Fork 6k
Fixes hot restart correctly reset the browser history #24377
Conversation
lib/web_ui/lib/src/engine.dart
Outdated
@@ -203,6 +203,7 @@ void initializeEngine() { | |||
// This extension does not need to clean-up Dart statics. Those are cleaned | |||
// up by the compiler. | |||
developer.registerExtension('ext.flutter.disassemble', (_, __) { | |||
window.resetHistory(); |
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.
Hi @mdebbar is there a way to test this? I couldn't find an example to trigger hard reload during the test.
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 don't think there's a way to test hot restart yet. Maybe @yjbanov has some thoughts?
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.
Thanks for fixing this!
lib/web_ui/lib/src/engine.dart
Outdated
@@ -203,6 +203,7 @@ void initializeEngine() { | |||
// This extension does not need to clean-up Dart statics. Those are cleaned | |||
// up by the compiler. | |||
developer.registerExtension('ext.flutter.disassemble', (_, __) { | |||
window.resetHistory(); |
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 don't think there's a way to test hot restart yet. Maybe @yjbanov has some thoughts?
lib/web_ui/lib/src/engine.dart
Outdated
@@ -203,6 +203,7 @@ void initializeEngine() { | |||
// This extension does not need to clean-up Dart statics. Those are cleaned | |||
// up by the compiler. | |||
developer.registerExtension('ext.flutter.disassemble', (_, __) { | |||
window.resetHistory(); |
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.
The pattern that we use in the web engine is to call registerHotRestartListener
and pass a callback. The callback will be invoked when hot restart is requested.
So somewhere near the code that initializes the history, you could do:
registerHotRestartListener(() {
window.resetHistory();
});
Example:
engine/lib/web_ui/lib/src/engine/platform_dispatcher.dart
Lines 768 to 770 in 42019c8
registerHotRestartListener(() { | |
_removeBrightnessMediaQueryListener(); | |
}); |
web engine hot restart does not tear down the browser history. When the app restarted, it confused itself with the existing browser history, thus causes error in flutter/flutter#73793.
fixes flutter/flutter#73793
Pre-launch Checklist
writing and running engine tests.
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.