Skip to content

Conversation

@eyebrowsoffire
Copy link
Contributor

@eyebrowsoffire eyebrowsoffire commented Mar 7, 2024

This updates the documentation to be in line with the new changes to bootstrapping that are coming in this PR: flutter/flutter#144434

@flutter-website-bot
Copy link
Collaborator

flutter-website-bot commented Mar 7, 2024

Visit the preview URL for this PR (updated for commit 2b47b70):

https://flutter-docs-prod--pr10256-flutter-bootstrap-documenta-b12b9apw.web.app

produced by the build step, you can place a `flutter_bootstrap.js` file in the
`web` subdirectory of your project, which will be copied over and used in lieu
of the default script produced by the build. This file is also templated, and
you can insert several special tokens which the build step will substitute at
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it "can" or "should"? Can one write a working flutter_bootstrap.js script without including of tokens at all? Or are some of them required?

Copy link
Member

Choose a reason for hiding this comment

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

You potentially can add the tokens to the flutter_bootstrap.js, or inline in the index.html.

|`serviceWorkerVersion`| Pass *the `serviceWorkerVersion` variable* set by the build process in your **`index.html`** file. |`String`|
|`timeoutMillis`| The timeout value for the service worker load. Defaults to `4000`. |`Number`|
|`config`| The user configuration of your Flutter app. |`Object`|
|`onEntrypointLoaded`| The function called when the engine is ready to be initialized. Receives an `engineInitializer` object as its only parameter. |`Function`|
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be useful to explain why this function exists. IIRC, it's so you can be notified when engine resources are fetched over the network, but the engine is not yet rendering anything. The function can be used to kick off pre-caching of resources while the user is interacting with the landing page, but delay engine initialization until the user asks to start the app.

Your Flutter app should target an HTML element with `id="flutter_app"` and
use the `canvaskit` renderer. The resulting JavaScript code would resemble
the following:
In some cases, one might want to allow the user to force the use of the
Copy link
Contributor

Choose a reason for hiding this comment

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

Summoning my inner @sfshaza2: I'd remove "In some cases, one might want to" and shorten the text. For example: "Here's an example of a custom flutter_bootstrap.js script that allows the user to force the CanvasKit renderer by providing ..."

## The `onEntrypointLoaded` callback

#### Skipping this step
You can also pass an `onEntrypointLoaded` callback into the `load` API in order
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider removing "You can also" and start with "Pass an..."

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes.

@johnpryan
Copy link
Contributor

/gcbrun

@kevmoo
Copy link
Contributor

kevmoo commented Apr 22, 2024

Just some notes on the column sizes, otherwise LGTM!

@eyebrowsoffire eyebrowsoffire marked this pull request as ready for review May 2, 2024 18:33
Copy link
Contributor

@sfshaza2 sfshaza2 left a comment

Choose a reason for hiding this comment

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

@eyebrowsoffire, thanks for this thorough PR!

I'm wondering... maybe we should add this page to the sidenav? Currently the sidebar lists, under Platform integration -> Web only the older version of this doc. Now, it's true that the early in the page that it suggests they click over if they are using 3.21 or later, but we could put both in the sidenav. Like. "Custom app initialization (before 3.22)" and "Flutter app initialization (3.22 or later)".

ALSO, this sounds like a breaking change. We usually provide a page under breaking changes. In this case, perhaps you could create a very basic breaking change page that then links to THIS page.

Thoughts?

@eyebrowsoffire
Copy link
Contributor Author

@sfshaza2 Thanks for the review!

I'm wondering... maybe we should add this page to the sidenav? Currently the sidebar lists, under Platform integration -> Web only the older version of this doc. Now, it's true that the early in the page that it suggests they click over if they are using 3.21 or later, but we could put both in the sidenav. Like. "Custom app initialization (before 3.22)" and "Flutter app initialization (3.22 or later)".

Currently the wasm page is also not listed in the side-nav. I figured maybe we should leave this off the sidebar until it lands in stable, then we can remove the old page and replace it with this one (which will be linked in the sidebar). I'm open to other ideas, but having more than one sidebar option for "web app initialization" seemed a bit more confusing, so I figured it might make more sense to just let people come to the existing page, and click through to the new page based on the note at the top.

ALSO, this sounds like a breaking change. We usually provide a page under breaking changes. In this case, perhaps you could create a very basic breaking change page that then links to THIS page.

This is actually not a breaking change. The old APIs (loadEntrypoint, etc) will still work, but they will be deprecated, they won't get the performance benefits of the new bootstrapping, and they aren't compatible with a dual-compiled wasm build.

eyebrowsoffire and others added 3 commits May 2, 2024 12:51
Co-authored-by: Shams Zakhour (ignore Sfshaza) <44418985+sfshaza2@users.noreply.github.com>
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

Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for documenting this!

@kevmoo
Copy link
Contributor

kevmoo commented May 6, 2024

Are we ready to land this?

@parlough parlough requested a review from sfshaza2 May 6, 2024 23:11
Copy link
Contributor

@sfshaza2 sfshaza2 left a comment

Choose a reason for hiding this comment

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

Thanks for fixing the tables! This looks great! lgtm

Copy link
Contributor

@sfshaza2 sfshaza2 left a comment

Choose a reason for hiding this comment

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

lgm!

@sfshaza2 sfshaza2 merged commit f9f0982 into flutter:main May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants