Skip to content
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

Use the default Flutter service worker instead of our custom service worker #5331

Merged
merged 10 commits into from
Mar 3, 2023

Conversation

elliette
Copy link
Member

@elliette elliette commented Mar 1, 2023

Work towards #3896, #4658

Use the default Flutter service worker generated by Flutter Web instead of our own.

  • Changes to index.html were copied from the default index.html generated by Flutter when you run flutter create
  • pwa-strategy changed from none to offline-first so that Flutter generates a service worker

Confirmed that the new service worker works by running dart run tool/build_e2e.dart. Need to also update the copybara script before submitting.

@elliette elliette requested review from CoderDake and a team as code owners March 1, 2023 01:22
@@ -403,8 +403,7 @@ class FakeVmServiceWrapper extends Fake implements VmServiceWrapper {
) async {
final httpProfile = await getHttpProfile(isolateId);
return Future.value(
httpProfile.requests
.firstWhereOrNull((request) => request.id == id),
httpProfile.requests.firstWhereOrNull((request) => request.id == id),
Copy link
Member Author

Choose a reason for hiding this comment

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

This change was due to running dart format from the root

Comment on lines 67 to 70
onEntrypointLoaded: function(engineInitializer) {
engineInitializer.initializeEngine().then(function(appRunner) {
appRunner.runApp();
});
Copy link
Member

Choose a reason for hiding this comment

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

can you set the config to use canvas kit here now that we are using the default service worker?
https://docs.flutter.dev/development/platform-integration/web/renderers#runtime-configuration.

This would also allow us to remove --dart-define=FLUTTER_WEB_CANVASKIT_URL=canvaskit/ \ from build_release.sh below.

Here is the devtools issue for that: #5148

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

onEntrypointLoaded: function(engineInitializer) {
engineInitializer.initializeEngine({
renderer: 'canvaskit',
canvasKitBaseUrl: 'canvaskit'
Copy link
Member

Choose a reason for hiding this comment

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

curious, does the call to initializeEngine work without setting the base url? In the example on the flutter website, I only saw "renderer" specified, so I'm wondering why we need this too

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, looks like this is required otherwise it tries to download canvaskit from the CDN, which is surprising. Opened flutter/flutter#121743 in Flutter

Copy link
Member

@kenzieschmoll kenzieschmoll left a comment

Choose a reason for hiding this comment

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

LGTM

Just making sure - have we verified that canvas kit is properly loaded with the new changes?

@kenzieschmoll
Copy link
Member

Fixes #5148

@kenzieschmoll kenzieschmoll linked an issue Mar 1, 2023 that may be closed by this pull request
@elliette
Copy link
Member Author

elliette commented Mar 1, 2023

LGTM

Just making sure - have we verified that canvas kit is properly loaded with the new changes?

Yep, all is working (even with no internet connection)

@elliette elliette merged commit d2b90ee into flutter:master Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants