-
Notifications
You must be signed in to change notification settings - Fork 45
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
[native_assets_cli][native_assets_builder] Hot reload and hot restart #1207
Comments
Does is make sense to rebuild assets on hot reload? Some assets might take a long time to build or link... Should the user specify if an asset is |
I don't think this is an issue, because the building tool specifies which asset types are supported / should be built. So in
So the |
I believe the caching would not work in that case. The cached results of (Edit: Maybe that is not an issue. Flutter also prebuilds a kernel file as a copy... So maybe we can pre-populate the hot-reload assets as well.) |
Please clearify what you mean here. If we run |
As a side note: We should also ensure that dependencies (e.g. |
This is a conceptual issue: We report the dependencies of all assets together. If only a subset of assets is required for hot reload, we can't use the dependencies list for the full build to determine whether or not we need to re-invoke the hook or not. So the first build hook invocation on the first hot reload will always need to run (unless none of the dependencies changed, also of the assets that cannot be hot reloaded).
This, exactly. |
An alternative design suggested by @HosseinYousefi: Center the hook interaction around whether something is a hot-restart invocation or not.
In the style of #1375 option 1, we would run hot-restart hook invocations in the same directory as the cold start invocation. Hook writers can then simply re-output all assets that they don't want to rebuild and rebuild the assets that they want. This enables hook writers to decide per asset if they want it to be hot restarted (maybe some heavy to compile data asset should not be hot restarted). The caching in the native assets builder needs to slightly be changed:
@mosuem This is a solution for what we were talking about last week on whether the hot-restart build directory is shared with the cold-start build directory. WDYT? The main idea of this approach is to keep the concepts simpler:
|
Whether we have dependencies per asset (#1368) is connected to whether our protocol has a concept of dry run. (Thanks @mkustermann!)
Getting rid of dry run would simplify the abstractions for our users. Getting rid of dry run requires:
|
Write up of discussion with @mkustermann: hot-reload per-asset (not proposed)@HosseinYousefi's suggestion (#1207 (comment)) of making some assets hot restartable and others not, does not communicate to the hook that some asset types are not hot-restartable (e.g. code assets for example). hot-reload per-asset-type (proposed solution)
|
Can you elaborate? Imagine we have |
The hook doesn't know if the embedder (hook invoker) supports hot restart for a certain asset type unless we stick that info somewhere in the JSON. @mkustermann suggested that instead of having a separate |
Circling some conclusions from an offline conclusion back here: Protocol design
Design idea:
Hook-writers, and hook-helper-library-writers can choose to look at that config variable and decide to not report specific assets and their dependencies in an invocation. The The embedder/framework decides the semantics of their own custom config, and if hook-writers or hook-helper-library-writers use that custom config they need to respect those semantics. In this case, Performance / caching / impl detailsWe have three layers where caching happens
We'd like to avoid re-doing work (hashing file contents, or checking file timestamps) on the different layers.
Fast path in layer 1 on hot reload: None of the assets changed: the native assets builder doesn't need to be reinvoked on a hot restart. For v1.0The Thanks @mkustermann @HosseinYousefi @mosuem and @liamappelbe for the input! 👌 |
Whether hot reload and hot restart can be supported depends on the asset type.
Now this poses some questions for how the protocol should work:
If we blindly invoke the build and link hooks, we might get longer running builds for asset types that are not going to be hot-reload. E.g. hot reloading data assets should be fast especially if these assets are on disk already, but a locally built dynamic library will take considerably longer. We could add a BuildConfig / LinkConfig option with
filteredAssetTypes
.However, adding such configuration option would break caching between the full build and the for-hot-reload build. (For example the list of dependencies is combined for all assets.)
We could fix caching by splitting the initial invocation of build and link hooks into multiple invocations per asset type. Then rerunning for a specific asset type would work.
cc @mosuem @HosseinYousefi @liamappelbe @mkustermann
The text was updated successfully, but these errors were encountered: