-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Use web worker to run wasm binaries #612
Comments
I would... But I don't know Swift |
This is mainly a JavaScript implementation. |
Oh, well, I know JS, so I'll see how much I can help out. |
The app is an iOS app, therefore, it does require Swift, not JS to add. You can’t make an iOS/iPadOS app effectively, unless it’s a PWA.
|
Well then, maybe I can't help much. |
You could still help. This issue is about using a JS WebWorker and a JS SharedArrayBuffer to move WebAssembly into another thread, as I understand, and the only Swift code required is to move everything to a web server instead of just serving a local file. |
Alternative way to terminate a running wasm: https://github.com/ewasm/wasm-metering |
While working on adding stdc++.h, I noticed this in signal.h:
TODO: Investigate if emulated signal can be used to terminate programs. |
Background
Currently there is no way to terminate a running C / C++ program in WKWebView as wasm in web is single-threaded and blocking. Calling
WKWebView.reload()
or releasing the reference to the existing web view doesn't do anything.Proposal
I propose to run binaries in web workers and use SharedArrayBuffer and
worker.postMessage()
to facilitate sync / async communication between native code and the web worker.Caveat
Due to a security requirement for using SharedArrayBuffer, the following headers from the web server are required to use the API. As we are currently loading the resources using
WKWebView.loadFileURL
, there doesn't seem to be a way to set custom headers. From what I've tested, the api is blocked by default when loading a local file. We probably need to serve the files with a local web server (GCDWebServer) instead.The text was updated successfully, but these errors were encountered: