-
Notifications
You must be signed in to change notification settings - Fork 82
[dwds] Implement hot reload and publish 24.3.4 #2583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Modifies the Chrome proxy service to call a callback that the injected client has setup in order to do a hot reload. - This callback forwards to the restarter. - This restarter reads from a path that Flutter tools sets up beforehand in order to fetch the changed sources and their associated libraries. - Issues a hot reload to DDC using that data. - Reassembles the Flutter engine to render a frame if the extension exists. - Returns a ReloadReport on whether or not this operation succeeded.
import 'dart:js_interop'; | ||
|
||
import 'restarter.dart'; | ||
|
||
@JS('dartDevEmbedder') | ||
external _DartDevEmbedder get _dartDevEmbedder; | ||
|
||
// Flutter tools should set this path up before a hot reload. | ||
@JS('\$reloadScriptsPath') | ||
external String get _reloadScriptsPath; |
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.
@nshahan I know we talked about potentially forwarding this to the strategy provider, but I think the plumbing may be uglier than this. It'll need to be passed to the injected client upon creation, and the injected client should know that this arg should only matter for the DDC library bundle restarter. It is doable though if we want to go down that route.
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.
Actually, I'm gonna reverse course a bit here: #2584.
It'll be a good amount of plumbing, but it's worth it to decouple IMO.
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, I'm pleasantly surprised that the changes were smaller than I expected.
_logger.info('\$dartHotReloadDwds request complete.'); | ||
} catch (e) { | ||
// TODO(srujzs): We should bubble up the error, but `ReloadReport` needs | ||
// more fields to capture that info. |
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.
Just FYI the VM does already encode the reason into the reload report payload. We extract it in our testing framework here:
https://github.com/dart-lang/sdk/blob/6e17841614ed095168314c48a60ebc0db1539aac/pkg/reload_test/lib/src/_vm_reload_utils.dart#L173-L189
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 ended up adding a subclass for ReloadReport
because it looks like we call toJson
, and the implementation in ReloadReport
only ever returns the type
and success
. Without this, it ended up erasing any of the notices we have to Flutter tools.
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 overall!
My only question is whether or not we should be explicitly referencing Flutter service extensions from DWDS instead of providing some sort of callback to the Flutter Tool so it can issue the service extension request itself.
Ideally we'd keep DWDS as target agnostic as possible and avoid adding Flutter specific logic (although I'm fairly certain we haven't been consistent on this front historically).
@@ -25,6 +34,30 @@ extension type _Debugger._(JSObject _) implements JSObject { | |||
await invokeExtension(method, '{}').toDart; | |||
} | |||
} | |||
|
|||
Future<void> maybeInvokeFlutterReassemble() 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.
Does this belong here or in the Flutter Tool?
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.
We do need to invoke the developer extension here, but which ones should be up to Flutter tools.
I filed #2584 to register developer extensions in the provider as well as register the reload sources path. I'll work on that after getting this and the hot reload PR in Flutter tools landed and release a new version afterwards to integrate with.
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 take it back! :)
I forgot we can invoke extensions directly within Flutter tools. #2585. I'll wait until this lands to publish.
The ReloadReport gets jsonified using `toJson` so we need a custom class to override it so that `toJson` includes all the things we need to transmit errors.
…eb_socket_channel, webdev, webdriver Revisions updated by `dart tools/rev_sdk_deps.dart`. core (https://github.com/dart-lang/core/compare/3b35aca..2458e1a): 2458e1aa 2025-01-28 Vladimir E. Koltunov [fix,async] exception in async _CancelOnErrorSubscriptionWrapper.onError (dart-lang/core#855) ecosystem (https://github.com/dart-lang/ecosystem/compare/c4a163a..5b0d815): 5b0d815 2025-02-03 dependabot[bot] Bump the github-actions group with 6 updates (dart-lang/ecosystem#340) http (https://github.com/dart-lang/http/compare/6d99ff5..c7cc4f8): c7cc4f8 2025-01-29 Brian Quinlan [ok_http] Add support for client certificates using Java `PrivateKey`s (dart-lang/http#1444) markdown (https://github.com/dart-lang/markdown/compare/19aaded..62f78c6): 62f78c6 2025-02-01 dependabot[bot] Bump actions/stale from 9.0.0 to 9.1.0 in the github-actions group (dart-archive/markdown#635) test (https://github.com/dart-lang/test/compare/92eed6c..2ccfc5c): 2ccfc5cd 2025-02-01 dependabot[bot] Bump the github-actions group with 3 updates (dart-lang/test#2455) d8ee364a 2025-01-28 Lasse R.H. Nielsen Release fake_async v1.3.3 (dart-lang/test#2453) 385c4f75 2025-01-28 Lasse R.H. Nielsen Remove "-wip" from CHANGELOG.md too. 82417ab3 2025-01-27 Lasse R.H. Nielsen Release fake_async v1.3.3 vector_math (https://github.com/google/vector_math.dart/compare/bd4b574..533c513): 533c513 2025-02-01 dependabot[bot] Bump the github-actions group with 2 updates (google/vector_math.dart#339) web (https://github.com/dart-lang/web/compare/fd3d988..c2d5f63): c2d5f63 2025-02-01 dependabot[bot] Bump actions/stale from 9.0.0 to 9.1.0 in the github-actions group (dart-lang/web#338) web_socket_channel (https://github.com/dart-lang/web_socket_channel/compare/a937243..f335e52): f335e52 2025-02-01 dependabot[bot] Bump actions/stale from 9.0.0 to 9.1.0 in the github-actions group (dart-archive/web_socket_channel#391) webdev (https://github.com/dart-lang/webdev/compare/5dc7950..616da45): 616da455 2025-01-30 Srujan Gaddam [dwds] Implement hot reload and publish 24.3.4 (dart-lang/webdev#2583) a7ea61ff 2025-01-28 Jessy Yameogo Added support for getModuleLibraries with the DDC library bundle format (dart-lang/webdev#2581) webdriver (https://github.com/google/webdriver.dart/compare/d83d6a3..e84e9cc): e84e9cc 2025-01-28 Ivan Inozemtsev Explicitly close http clients (google/webdriver.dart#311) Change-Id: I0c7fc6c3d0ae8f810c753babd9297d5f9565a0ee Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407940 Commit-Queue: Devon Carew <[email protected]> Reviewed-by: Kevin Moore <[email protected]>
cc @jyameo