Skip to content

Commit fede393

Browse files
committed
web: Throw an error when reference types are unsupported
1 parent a466802 commit fede393

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

@@ -855,6 +856,16 @@ export class InnerPlayer {
855856
this.loadedConfig.backgroundColor;
856857
}
857858

859+
// 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
860+
// but this is the only extension I know completely breaks our WASM module if unsupported
861+
const necessaryExtensionsSupported: boolean = await referenceTypes();
862+
if (!necessaryExtensionsSupported) {
863+
const baseError = new Error("Necessary WebAssembly extensions unsupported");
864+
const loadError = new LoadRuffleWasmError(baseError);
865+
this.panic(loadError);
866+
return;
867+
}
868+
858869
await this.ensureFreshInstance();
859870

860871
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)