Skip to content

Proposal: Use web worker to run wasm binaries #612

Closed
@bummoblizard

Description

@bummoblizard

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.

Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions