[web] flutter.js initialization with ui.webOnlyWarmupEngine#100177
[web] flutter.js initialization with ui.webOnlyWarmupEngine#100177fluttergithubbot merged 7 commits intoflutter:masterfrom ditman:web-js-interop-init
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
packages/flutter_tools/templates/app_shared/web/flutter.js.tmpl
Outdated
Show resolved
Hide resolved
packages/flutter_tools/templates/app_shared/web/index.html.tmpl
Outdated
Show resolved
Hide resolved
packages/flutter_tools/templates/app_shared/web/index.html.tmpl
Outdated
Show resolved
Hide resolved
packages/flutter_tools/templates/app_shared/web/index.html.tmpl
Outdated
Show resolved
Hide resolved
|
Until the engine PR lands and rolls to flutter (and this branch is updated), these failures will happen: Potential other failures may happen even after the update, even though the changes should be fully backwards-compatible. |
There was a problem hiding this comment.
TODO: Export this to a different lib/src/web/web_entrypoint.dart file, so code is shared between the flutter build and run commands.
|
Applied engine roll manually to see what breaks in this branch. |
|
Removed manual roll, and rebased with proper master. |
|
delete Platform.isAndroid |
|
@fangkyi03 this has been closed for >1 year, please open a new issue explaining in detail what you need :) |

This PR changes the initialization of a flutter web app to use the
ui.webOnlyWarmupEngineAPI introduced here:in order to yield full control to the programmer over the initialization of a Flutter Web app.
Currently, Flutter Web apps start as soon as possible, and take over the whole screen. With this change, the startup of an App can be split in three stages (four, if we count the cleanup stage too):
To achieve this, some JS-interop and Promise-wrangling is needed. The new workflow is as follows:
_flutter.loader.loadMainDartJs_flutter.loader.didLoadMainDartJscallback. (This callback must be in a hardcoded location, so Flutter loaded from a script knows where to call)If the callback is not present (old index.html, not using flutter.js):
If the callback is present:
EngineInitializerobject that can be used by the programmer.loadMainDartJsin step 1.Demo
The new API above allows users to write their own (informative) splash screens, for example:
Backwards compatibility
This is currently backwards compatible with old versions of index.html. If the flutter init script calls
ui.webOnlyWarmUpEngine, it checks if the flutter loader callback is setup or not.Testing
Waiting to update this branch with the latest from the engine, to detect potential failures in integration tests between the engine and the framework, even though the engine change should be fully backwards-compatible.
Manual testing
Clone this PR into your flutter/engine fork, and build it.
Clone this PR into your flutter/flutter fork, and ensure that your
flutterbinary is the one coming from your Github checkout.With the new version of flutter on your box, you'll be able to create a new app normally by using
flutter create. That should come with the new flutter.js and index.html templates.In order for the flutter_tool to rebuild, you'll need to delete its cache; you can do it with:
Once the engine and the tools are rebuilt, you can just do something similar to: