Open milke opened 2 days ago
I'm having the same issue. Flutter web crashes on Safari and WKWebKit with 'WebAssembly.compileStreaming' is undefined.
You need to add if (WebAssembly.compileStreaming != null) {} before calling it.
Need a fix ASAP. My website is crashing for mac users.
Note that Flutter does not actually officially support Safari 14. See https://docs.flutter.dev/reference/supported-platforms for reference.
The particular issue can probably be easily fixed - you can rewrite bootstrapping code to use non-streaming WebAssembly.compile
instead of WebAssembly.compileStreaming
(which only became available in Safari 15).
But I find it hard to predict what else will break. cc @yjbanov
Labeling for team's tracking.
It's tricky to support browsers 3+ years old that are 4 versions behind.
I'd take a stab at @mraleph suggestion about changing the bootstrap logic.
I think you could only work on google chrome (that's the only full supported browser... in all the platform mac,win,linux), and also better sometimes in the canary version.
hope it help... :)
The thing is that we have chosen Flutter for our web apps, running inside a WKWebView (Apple's WebKit) window in macOS application, handling purchase, registration, activation etc… Things that can hardly be done inside a regular browser as the communication with other parts of the application is needed. Or it can, but it's far from being user friendly (using a web browser to activate completely separate application?). And now it appears problematic that we've chosen Flutter? At the time we made that decision, Flutter inside a WebView worked on every macOS version we supported.
if (WebAssembly.compileStreaming) {}
so it doesn't crash.so.... the first thing that I'll try is try to develop the flutter app on chrome. blink use a lot of webkit like code: as: "The major browser makers – Apple, Google, and Mozilla – each have their own browser rendering engines. Apple's Safari is based on WebKit; Google's Chrome and its open source Chromium foundation is based on Blink (forked from WebKit a decade ago)"
It's clear that you have to manage the code between the two situation:
But changes and update are in field everyday... you couldn't support old stuff in a log period....
Have a good luck :)
@codetotech can you stop posting irrelevant comments on the issue? Thanks.
no problem at all... why you think it's irrelevant...? try only to help. have a good day :)
- @mraleph, @kevmoo, I have no idea how the bootstrap code works. Could you help?
The code which is erroring is originally lives here, it gets compiled into flutter.js
which gets pulled into $flutter_sdk/bin/cache/flutter_web_sdk/flutter_js/flutter.js
ends up build/web/flutter_bootstrap.js
when you build your project.
I think the simplest way for you is to take build/web/flutter_bootstrap.js
after you build your project and edit it to avoid compileStreaming
... The simplest patch is something like this (flutter_bootstrap.js
is minified so I have formatted it first - the diff below is against formatted version):
--- build/web/flutter_bootstrap.orig.js 2024-11-05 11:37:40
+++ build/web/flutter_bootstrap.js 2024-11-05 11:42:30
@@ -185,6 +185,8 @@
}
};
var g = s => {
+ // Fallback to canvaskit.js own loading mechanism instead.
+ if (typeof WebAssembly.compileStreaming === 'undefined') return void 0;
let t = WebAssembly.compileStreaming(fetch(s));
return (i, r) => ((async () => {
let e = await t,
I live it to @yjbanov to make a call if we want to update bootstrapping code to support a browser version which is officially unsupported.
Steps to reproduce
I don't know if this fits the bug category, but not of the offered issue categories to choose don't fit better with the problem I'd like to report…
Flutter web crashes on Safari and WKWebKit with
WebAssembly.compileStreaming is undefined
The problem is that flutter web apps don't work on older versions of Safari and WebKit, which I still need to support. For example, I need to support Safari 14.1.3 on macOS 11.1.17 and flutter application stops working when sending request to www.gstatic.com and trying to load file
canvaskit.wasm
from there.Web console reports the following errors:
We use flutter on web both for our store, available on the web, but also in the WKWebView in one of our applications. Everything works fine in newer versions of Safari and WebKit, but fails on older versions. It used to work on older versions as well, but it stopped working after some flutter update (we regularly update our code with each new flutter release). I don't have clear track when it happened.
Some of the web app I refer to:
https://store.cocoatech.io https://deckr.surf
The current situation is that flutter apps on web are useless for anyone using older Mac/macOS and there still are many such people (and many in our user base).
I wonder if there's something we can do about it from our side? Any way we can modify or patch flutter default behaviour? I wonder if we could patch the javascript
if (wasmstuff exists) {}
(assuming that would solve the problem)?Thanks a lot for looking into this and for providing any explanation, insight and solution, as it's really very important to us, and it's pretty urgent.
Expected results
Please see the description of the problem above.
Actual results
Please see the description of the problem above.
Code sample
N/A
Screenshots or Video
N/A
Logs
N/A
Flutter Doctor output