Closed johnpryan closed 3 years ago
Hi @johnpryan can you expand on this? I'm not seeing canvaskit anywhere in our codebase:
dart-pad$ git grep -i canvaskit
dart-pad$
Oops you assigned to yourself, likely nevermind!
Flutter web apps request CanvasKit at startup. @hterkelsen is there a way to disable this so we can load these files once?
@srawlins when we reload the iframe, does that trigger another request to fetch the Firebase JavaScript files?
Yes, we can detect if there is an already-initialized CanvasKit object and use that rather than loading CanvasKit again. Can you tell me a little more about how you use Flutter web in DartPad? If I set e.g. window._flutterCanvasKit = ...
will that value still be there in the next run?
We usually keep the same <iframe>
element (https://github.com/dart-lang/dart-pad/issues/1817) and send it messages with the new javascript, html, and css from the parent document. Then we have a script, frame.js, running in the iframe that listens to those messages and updates the script tag containing the app's compiled javascript.
When the new script runs, a new <script>
tag for canvaskit.js
is added to the page, so we end up getting duplicates. JavaScript variables are kept around across runs, since it's the same iframe.
Each time the user re-compiles their code, the app makes unnecessary requests to fetch
canvaskit.js
andcanvaskit.wasm
:Latest master also reloads the fonts and icons:
This might be because we are replacing the HTML (https://github.com/dart-lang/dart-pad/pull/1838)