Closed denlukia closed 1 year ago
Feature-detection rather than UA sniffing would be ideal, yeah, though the docs aren't quite clear on how to do the feature detection (the 'such as' makes me nervous):
I've opened a request for a) boot()
to throw in unsupported environments and/or b) the ability to know ahead of time if the environment is supported: https://github.com/stackblitz/webcontainer-core/issues/1021
Great, thank you for opening that request! Should I close then this one and watch there or leave this as is for now?
Let's leave this open, as we'll still need to do some work on our end if/when they make any changes on theirs
For those who really wants to learn.svelte.dev in Safari even before this resolves:
WebContainers team choose now to enable demo on their landing page for Safari by default. Here's the check they used in code. Maybe it's good enough for learn too?
According to this document, older Safari does not support Atomics.waitAsync
and therefore cannot run Webcontainer.
https://webcontainers.io/guides/browser-support#safari
According to caniuse.com, I see that Safari has supported Atomics.waitAsync
since 16.4, so this could be used to check for Webcontainer support, as a temporary workaround.
https://caniuse.com/mdn-javascript_builtins_atomics_waitasync.
@thedenoff Thanks for the information! That code is actually used on top-page of the webcontainers.io, which means production-ready. It looks like we should borrow it.
I have tried learn.svelte.dev on iPhone XS MAX and iPhone 13 Pro and it crashes. (On iPad Air (4th gen), it crashes rarely, but shows 'OUT OF MEMORY').
So again, I read the code in the docs of webcontainers.io and found that for mobile Safari, it is hidden by CSS.
Stackblitz shows the following for mobile Safari:
...then if you click the Run this project
button on the iPhone XS MAX and iPhone 13 Pro, it crashes.
So I will improve the check logic to make it unavailable for Safari on iOS.
I have tried learn.svelte.dev on several actual ipad devices (9th gen, 10th gen) and the behavior is flaky. For example, it works fine the first time but goes Out of memory the second time or crashes and reloads.
Therefore, I feel it would be better to let the user know about it and give them the option to run it or not, similar to Stackblitz.
Recent macOS update (13.3) bumped Safari to 16.4 which on WebContainers Browser Support page isn't described as lacking some features anymore but now as "in beta".
WebContainer's landing page demo now successfully runs on Safari with
webcontainer_any_ua
in LocalStorage being set to any non-empty valueI haven't though tested "learn"s code with removed user-agent matching codepath. Maybe there are some parts of WebContainers functionality which "learn" uses and which still don't work. If there are, maybe it would be smart to change check from user-agent to these specific function(s). At least we're getting close