Hot restart problems on pause
Hot restart is not working properly if the flutter app is paused when the hot restart is initiated.
Repro steps:
- Open flutter
hello_worldproject in VSCode - Add a breakpoint on the line that calls
runMain - Hot restart
Observe the breakpoint not hitting.
Notes To perform the hot restart we need the app to be running, so we remove all the breakpoints, resume the app, then hot restart, and re-establish breakpoints after the main is reloaded. This seems to be too late for the breakpoints to hit.
Suggestion Break hot restart into two steps - running the bootstrap and running main (flutter engine main in that case). Then re-establishing the breakpoints can be done in between the two.
Some issues we are encountering currently with this suggestion
-
Race condition between the engine initialization and hot restart. The previous isolate's engine initialization sometimes is delayed and executes in the middle of hot restart, so the engine cleanup is not performed correctly.
-
Hello world app is using an old bootstrap strategy: https://github.com/flutter/flutter/blob/57c7aa53c178f722aec19a76a60552e78ad09997/examples/hello_world/web/index.html#L5
-
After replacing it with a new one,
<html>
<head>
<head>
<title>Hello, World</title>
</head>
<script src="flutter.js" defer></script>
</head>
<body>
<script>
window.addEventListener('load', function (ev) {
// Download main.dart.js
_flutter.loader.loadEntrypoint({
onEntrypointLoaded: async function(engineInitializer) {
// Immediately run the app
await engineInitializer.autoStart();
}
});
});
</script>
</body>
</html>
I am hitting the following: https://github.com/flutter/flutter/issues/121905. Currently blocked on this, will continue the investigation after it is fixed.
FYI, I just merged https://github.com/flutter/engine/pull/40154 which fixes the hot restart issue you referenced (https://github.com/flutter/flutter/issues/121905).
Any suggestion when it will be available on flutter beta channel ?
For us it is a showstopper at the moment w/o doing roll-back changes from v3.9(beta) back to 3.7.7 (stable)...
Still an issue with following version
Flutter is already up to date on channel beta
Flutter 3.9.0-0.2.pre • channel beta • https://github.com/flutter/flutter.git
Framework • revision 0df8557c56 (5 days ago) • 2023-03-23 22:02:01 -0500
Engine • revision 1cc4b2d280
Tools • Dart 3.0.0 (build 3.0.0-290.3.beta) • DevTools 2.22.2
@RoarGronmo you can check when this lands by looking at the tags in the roll commit from flutter/engine to flutter/flutter that contains this feature, in this case:
https://github.com/flutter/flutter/commit/7003bfab316a9e1f02221e50b935fa53be63088f
It seems the earliest tag associated with the commit is: 3.9.0-9.0.pre, which seems slightly newer than the beta channel.
(The fix is currently available on master, of course.)
@jyameo is going to see if he can reproduce this still.
I was not able to reproduce this issue on Flutter 3.24.3 (Dart 3.5.3, DevTools 2.37.3), so it appears to be resolved.