Skip to content
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

web: Enable the bulk-memory WebAssembly extension #5225

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[target.wasm32-unknown-unknown]
rustflags=["--cfg=web_sys_unstable_apis"]
rustflags=["--cfg=web_sys_unstable_apis", "-C", "target-feature=+bulk-memory"]

# on Windows, in release builds, link to CRT statically
[target.'cfg(all(windows, not(debug_assertions)))']
rustflags = ["-C", "target-feature=+crt-static"]
4 changes: 0 additions & 4 deletions .github/workflows/release_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,10 @@ jobs:
- build_name: windows-x86_32
os: windows-latest
target: i686-pc-windows-msvc
RUSTFLAGS: -Ctarget-feature=+crt-static

- build_name: windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
RUSTFLAGS: -Ctarget-feature=+crt-static

env:
PACKAGE_FILE: ${{ needs.create-nightly-release.outputs.package_prefix }}-${{ matrix.build_name }}.${{ startsWith(matrix.build_name, 'win') && 'zip' || 'tar.gz' }}
Expand Down Expand Up @@ -137,8 +135,6 @@ jobs:
with:
command: build
args: --package ruffle_desktop --release ${{ matrix.target && '--target' }} ${{ matrix.target }}
env:
RUSTFLAGS: ${{ matrix.RUSTFLAGS }}

- name: Package common
run: |
Expand Down
20 changes: 20 additions & 0 deletions web/packages/core/src/ruffle-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const enum PanicError {
Unknown,
CSPConflict,
FileProtocol,
NoWasmBulkMemory,
InvalidWasm,
JavascriptConfiguration,
JavascriptConflict,
Expand Down Expand Up @@ -398,6 +399,13 @@ export class RufflePlayer extends HTMLElement {
e.ruffleIndexError = PanicError.WasmCors;
} else if (message.includes("disallowed by embedder")) {
e.ruffleIndexError = PanicError.CSPConflict;
} else if (
message.includes("doesn't parse") &&
message.includes("references are not enabled")
) {
// The "reference-types" extension is now based on the "bulk-memory" one,
// hence the misleading error message from Safari.
e.ruffleIndexError = PanicError.NoWasmBulkMemory;
} else if (e.name === "CompileError") {
e.ruffleIndexError = PanicError.InvalidWasm;
} else if (
Expand Down Expand Up @@ -1155,6 +1163,18 @@ export class RufflePlayer extends HTMLElement {
<li><a href="#" id="panic-view-details">View Error Details</a></li>
`;
break;
case PanicError.NoWasmBulkMemory:
// The browser does not support WebAssembly bulk memory, most likely Safari <15
errorBody = `
<p>It seems like your browser has no support for the "Bulk Memory Operations" WebAssembly extension.</p>
<p>This is required for Ruffle to work efficiently, so please update your browser.</p>
<p>See the Ruffle wiki for the list of supported browsers and their minimum versions.</p>
`;
errorFooter = `
<li><a target="_top" href="https://github.com/ruffle-rs/ruffle/wiki#web">View Ruffle Wiki</a></li>
<li><a href="#" id="panic-view-details">View Error Details</a></li>
`;
break;
case PanicError.InvalidWasm:
// Self hosted: Cannot load `.wasm` file - incorrect configuration or missing files
errorBody = `
Expand Down
2 changes: 1 addition & 1 deletion web/packages/extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ It automatically negotiates with websites that do have Ruffle installed, to ensu

## Using ruffle-extension

The browser extension works in Chrome, Firefox, and Safari 14+.
The browser extension works in Chrome, Firefox, and Safari 15+.

Before you can install the extension, you must either download the [latest release](https://github.com/ruffle-rs/ruffle/releases) or [build it yourself](../../README.md).

Expand Down