fix(hot-reload): drive Flutter Tools' reloadSources/hotRestart VM services so hot_reload/hot_restart actually apply changes - #58
Merged
charliewwdev merged 1 commit intoAug 21, 2026
Conversation
…vices
hot_reload called the VM's raw reloadSources RPC. A Flutter app embeds no
kernel compiler, so the VM answers success:false ("Error while starting
Kernel isolate task"); the report was ignored and the tool reported success
while nothing recompiled. hot_restart was the same call (or threw).
The flutter run process registers reloadSources/hotRestart as VM services
(alias "Flutter Tools") - what DevTools and IDEs call. The driver now
tracks registrations from the Service stream and invokes sN.reloadSources /
sN.hotRestart; without an attached tool it checks the ReloadReport and
surfaces a clear error instead of a fake success.
Also:
- re-bind to the new main isolate after a restart (old id -> Sentinel
Collected on every later call) and self-heal on stale isolates
- wait for ext.flutter.didSendFirstFrameEvent so the tree is populated
- on Windows, hold until the wall-clock second rolls over: Dart truncates
mtimes to seconds there, so the tool ignores edits made in the same
second as its last compile ("0 updated files")
- report what happened: "Hot reload performed by Flutter Tools (330ms)"
Contributor
Author
|
The Windows mtime-granularity behaviour that motivates the |
Contributor
Author
|
Follow-up: #59 (synthetic input engine — single tap activation, timestamped pointer events, drag hold, |
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
hot_reload/hot_restartreport success but never apply source changes.FlutterSkillClient.hotReload()calls the VM's rawreloadSources(isolateId).A Flutter app embeds no kernel compiler, so the VM answers
ReloadReport{success:false, notices:["Error while starting Kernel isolate task"]};the report is ignored and the tool returns "Hot reload triggered" while nothing
recompiled.
hotRestart()is the same call (or throwsUnsupportedErrorclaiming the VM Service cannot restart — it can, see below).
Fix
The
flutter runprocess that launched the app owns the incremental compiler andregisters VM services
reloadSourcesandhotRestart(alias "Flutter Tools",callable as
sN.reloadSources/sN.hotRestart, advertised on theServicestream — the VM replays existing registrations on
streamListen). That is exactlywhat DevTools and the IDE plugins call.
FlutterSkillClienttracks those registrations (connect + reconnect) andhotReload/hotRestartinvoke them → real recompile + reload + reassemble.hotReloadfalls back to the raw RPC and checks the report, surfacing aclear "launch the app with
flutter run" error;hotRestartexplains it needsthe tool.
(id must differ — the old one may still be listed), then wait for
ext.flutter.didSendFirstFrameEventso the widget tree is populated for thecaller's next call. (
didSendFirstFrameRasterizedEventnever flips on Windowsdesktop; the value is a JSON bool.)
_callalso self-heals on a stale isolate(
Sentinel: Collected), so a restart done from the terminal no longer breaksthe session.
truncates file mtimes to whole seconds there, so
flutter_tools'ProjectFileInvalidatorignores edits made in the same second as its lastcompile ("Compiling dart to kernel with 0 updated files"). Agents edit and
reload back-to-back, so this hit every second call. (Reported upstream to
Flutter separately.)
Hot reload performed by Flutter Tools (330ms).Verification
Minimal app showing a
MARKER_Vnconstant, launched withflutter run -d windows(Flutter 3.44.9, Windows 10). Script drives the server over MCP stdio:
connect → edit →
hot_reload→get_text_content→ edit →hot_restart→get_text_content.flutter runlogs nothingReloaded 1 of 756 libraries/Restarted application, every compile "1 updated files"dart analyzeclean on the touched files; no existing tests reference the old behaviour.