From 90d83e37a6278cf4ae5dbcb1636630e66343be00 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Wed, 23 Sep 2020 18:58:05 -0700 Subject: [PATCH] [flutter_tools] register service worker after first frame event (#66082) Registering the service worker immediately after the documented has loaded may cause SW initialization to compete with framework initialization. It was recommended to us that we defer the service worker setup until after the framework is done with setup, which should be sometime after the first frame. To implement this, I augmented the binding setup to dispatch an event on the document after the binding has initialized. I don't see any obvious risks with this setup. Fixes #66066 --- .../flutter_gallery/web/index.html | 2 +- .../flutter/lib/src/rendering/binding.dart | 9 +++++ .../test/rendering/first_frame_test.dart | 38 +++++++++++++++++++ .../rendering/mouse_tracking_test_utils.dart | 2 +- .../templates/app/web/index.html.tmpl | 2 +- 5 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 packages/flutter/test/rendering/first_frame_test.dart diff --git a/dev/integration_tests/flutter_gallery/web/index.html b/dev/integration_tests/flutter_gallery/web/index.html index 23bcf28fda..3bc6123c71 100644 --- a/dev/integration_tests/flutter_gallery/web/index.html +++ b/dev/integration_tests/flutter_gallery/web/index.html @@ -24,7 +24,7 @@ found in the LICENSE file. --> https://developers.google.com/web/fundamentals/primers/service-workers -->