Improve support for SharedArrayBuffer in Webviews#3927
Conversation
|
I've tested this on macOS, Windows, GTK, and iOS, and it works. It's still failing on Android - both because of dialogs, and because it's not detecting cross-origin isolation. |
|
@freakboy3742 this is awesome, thank you! Just to be sure we are aligned:
|
|
forgot to mention ... we might also not need specific headers (although that's likely better) if the ServiceWorker approach can actually run ... we can use this file (has to be loaded locally as Service Worker cannot be hosted anywhere else) https://github.com/WebReflection/mini-coi/blob/main/mini-coi-fd.js and on the page, as first thing on the <script src="./mini-coi-fd.js"></script>notes
Of course native support is preferable, but maybe this option makes sense for Android WebView in case all other attempts failed. I hope any of this will help solving the feature all over the place + with SharedArrayBuffer in place we won't need |
Understood - the underlying problem here is that Toga doesn't have the analog of
Toga's WebView uses the native platform web view, which isn't Chromium by default on Android... but android.webview.WebView is... feature poor, shall we say :-) . The story for sharedArrayBuffer specificall doesn't look promising. I don't know what other options exist on Android that are exposed as a widget that is ready to use; if we need to deploy to Android, then we might need to do some research.
Understood - but in this case, it's more about a single source base targeting multiple platforms. |
Understood - but I think that fits in the category of things that would be added to the project manually after the stub has been generated. The current intention is that Positron is a "generate once and then modify" bootstrapping wizard, rather than a standalone "generate complete app from configuration" tool. That said, it's not out of the question to turn it into a "complete app" tool, if that's a use case that is warranted. |
|
FYI I've commented in there: https://issues.chromium.org/issues/40914606#comment16 we have a workaround to make PyScript work out of the blue even on Android WebViews so it feels like a matter of using the right template after |
SharedArrayBuffer is needed to support running PyScript in a webview; but it is disabled by default by WebKit for security reasons.
This PR enables SharedArrayBuffer support by:
It also adds handlers for Cocoa and iOS webviews to support displaying dialogs. This isn't needed for SharedArrayBuffer itself - but it was needed to test SharedArrayBuffer support.
There's no new unit tests for this because it depends on Pos
To test - generate a "static" Positron app with the following static content:
On startup, this should:
PR Checklist: