Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

ditman
Copy link
Member

@ditman ditman commented Mar 14, 2022

This PR adds the new ui.webOnlyWarmupEngine that creates a JS-interop layer so methods from the engine can be called directly from Apps, and the initialization can be controlled by the user.

See flutter/flutter#100177 to see how the framework would use this new API.

Demo

The new API above allows users to write their own (informative) splash screens, for example:

  • https://dit-bootstrap-tests.web.app (red circles should turn green as the app loads. The button only becomes enabled once the app is ready to start. The app only starts when the button is pressed).

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@ditman ditman force-pushed the web-js-interop-init branch from a2dd269 to 0a770b0 Compare March 24, 2022 01:06
@ditman ditman force-pushed the web-js-interop-init branch from e1a63a8 to 9db5e50 Compare March 28, 2022 19:48
@ditman ditman requested a review from yjbanov March 28, 2022 21:40
@ditman
Copy link
Member Author

ditman commented Mar 28, 2022

Let's publish the review while I write the test for the new webOnlyWarmupEngine method.

@ditman ditman marked this pull request as ready for review March 28, 2022 21:40
import 'package:js/js.dart';

/// Type-safe JS Promises
@JS('Promise')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if any other code writes this same JS-interop @js('Promise')?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, there's at least this:

ditman added 4 commits March 29, 2022 11:37
* Add unit tests for the ui.webOnlyWarmupEngine method.
* Rename AppCleaner to FlutterApp, and remove the cleanApp method.
  FlutterApp API will be added later.
* Consistently name 'autoStart' everywhere in the public API.
* Remove stray 'Custom' from method name.
* Move initialization steps around so:
  * webOnlyWarmupEngine only prepares and returns the AppBootstrap
    object(s)
  * initEngine -> initializes engine services
  * runApp -> registers plugins, inits engine UI, runs app
Copy link
Contributor

@yjbanov yjbanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@yjbanov yjbanov added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Mar 30, 2022
@ditman
Copy link
Member Author

ditman commented Mar 30, 2022

Rebased with main, just in case.

@fluttergithubbot fluttergithubbot merged commit cb9232b into flutter:main Mar 30, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 30, 2022
zanderso pushed a commit to flutter/flutter that referenced this pull request Mar 31, 2022
* cb9232b [web] webOnlyWarmupEngine + js-interop APIs (flutter/engine#32017)

* 88b7f72 [macOS] Generate gen_snapshot_$arch by default (flutter/engine#32326)

* 6dd43e6 Add support for images in display lists. (flutter/engine#32268)

* a1106da [web] Make "felt build" wait for both engine and canvaskit builds (flutter/engine#32308)
@ditman ditman deleted the web-js-interop-init branch March 31, 2022 06:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform-web Code specifically for the web engine waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants