-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[dev_compiler] Add hot reload ability to dartdevc #46958
Comments
@vsmenon I have opened an issue here. |
Off the top of my head, the current support for hot restart essentially:
I'd like to understand more about your idea. The code in to be replaced should already be part of the modules that get reloaded. Are you trying to reduce the amount of code that gets recompiled and loaded by the compiler when there during the hot reload? It's not clear to me that is an immediate issue. When I think about supporting hot reload in DDC I find the largest hurdle will be identifying the values in the dart runtime library that need to be reset or updated. These are the values used to provide the dart language semantics and performance improvements while running in Javascript (Dart type representations, values in caches, etc.) Some of these values are captured by closures so they are very hard to invalidate or update without restarting the application. We need to restructure the representation so it can easily be updated or invalidated for a hot reload. If stale values are lingering around after a hot reload the code could be incorrect and lead to very confusing errors. This is already true for the hot restart support. Some examples of confusing bugs we have fixed: One of the first steps I'd like to take is to identify the cases we should be supporting. I believe there are some existing tests for hot reload already. We should build some infrastructure to start running them with an application compiled by DDC to help guide our work. |
@nshahan My idea is to basicaly implement the way that hot reloading works in Dart VM (https://github.com/dart-lang/sdk/wiki/Hot-reload), by replacing the javascript functions in runtime. I believe variables do not have to be modified right? |
OK as I understand you would like to replace methods, either top level or attached to the prototypes of classes. If that is all we do I think it might be possible to avoid the problems that appear when we replace the entire classes. To give you some background, there are two code paths in dev_compiler.
Both take a Component from the Common Front End (CFE) as the input for compilation. This is Dart source code that has already been built into a tree where each node represents some part of the original Dart program. I'd imagine that we would want to create something similar to the |
Flutter request for stateful hot reload: flutter/flutter#53041 |
@michaellee8 @nshahan any update or progress on this?? |
Sorry I missed this issue in the issue tracker. It's part of the Dart web team plans to dive into hot reload support this year. It's a long road ahead and we are just getting started, so we don't have much to share at this time. We're be tracking our efforts in #54934. Given the overlap, I'll close this issue as a duplicate |
Currently, it is not possible to perform hot reloading when development flutter web apps. My idea is to implement the Dart VM's method replacing based hot reload by modifying dartdevc to generate one-off javascript patches that will inject the new methods using the prototype chain. It has been discussed a litle bit in flutter/flutter#53041 (comment). I plan to contribute it but currently I am not sure about the internals of dev_compiler so I will need some guidance.
The text was updated successfully, but these errors were encountered: