Skip to content

Commit c5b9550

Browse files
committed
web: Throw an error when reference types are unsupported
1 parent 9e51cc4 commit c5b9550

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

web/packages/core/src/internal/player/inner.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { showPanicScreen } from "../ui/panic";
2626
import { createRuffleBuilder } from "../../load-ruffle";
2727
import { lookupElement } from "../register-element";
2828
import { configureBuilder } from "../builder";
29+
import { referenceTypes } from "wasm-feature-detect";
2930

3031
const DIMENSION_REGEX = /^\s*(\d+(\.\d+)?(%)?)/;
3132

@@ -844,6 +845,16 @@ export class InnerPlayer {
844845
this.loadedConfig.backgroundColor;
845846
}
846847

848+
// We may theoretically need to check everything listed on https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/wasm32-unknown-unknown.md#enabled-webassembly-features
849+
// but this is the only extension I know completely breaks our WASM module if unsupported
850+
const necessaryExtensionsSupported: boolean = await referenceTypes();
851+
if (!necessaryExtensionsSupported) {
852+
const baseError = new Error("Necessary WebAssembly extensions unsupported");
853+
const loadError = new LoadRuffleWasmError(baseError);
854+
this.panic(loadError);
855+
return;
856+
}
857+
847858
await this.ensureFreshInstance();
848859

849860
if ("url" in options) {

web/packages/core/src/internal/ui/panic.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,19 @@ function createPanicError(error: Error | null): {
308308
};
309309
}
310310

311+
if (message === "necessary webassembly extensions unsupported") {
312+
// Self hosted: User has a browser without support for necessary WebAssembly extensions
313+
return {
314+
body: textAsParagraphs("error-wasm-unsupported-browser"),
315+
actions: [
316+
CommonActions.openWiki(
317+
"#web",
318+
),
319+
CommonActions.ShowDetails,
320+
],
321+
};
322+
}
323+
311324
// Self hosted: Cannot load `.wasm` file - file not found
312325
return {
313326
body: textAsParagraphs("error-wasm-not-found"),

web/packages/core/texts/en-US/messages.ftl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ error-wasm-disabled-on-edge =
6868
To fix this, try opening your browser's settings, clicking "Privacy, search, and services", scrolling down, and turning off "Enhance your security on the web".
6969
This will allow your browser to load the required ".wasm" files.
7070
If the issue persists, you might have to use a different browser.
71+
error-wasm-unsupported-browser =
72+
The browser you are using does not support the WebAssembly extensions Ruffle requires to run.
73+
Please switch to a supported browser.
74+
You can find a list of supported browsers on the Wiki.
7175
error-javascript-conflict =
7276
Ruffle has encountered a major issue whilst trying to initialize.
7377
It seems like this page uses JavaScript code that conflicts with Ruffle.

0 commit comments

Comments
 (0)