From 7af4d6bf90834b3d66f1fc7abe40fab8286905a9 Mon Sep 17 00:00:00 2001 From: Daniel Jacobs Date: Fri, 3 Jan 2025 10:58:33 -0500 Subject: [PATCH] web: Check error message on browsers without reference types support --- .../core/src/internal/player/inner.tsx | 11 -------- web/packages/core/src/internal/ui/panic.tsx | 26 +++++++++---------- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/web/packages/core/src/internal/player/inner.tsx b/web/packages/core/src/internal/player/inner.tsx index ea305e4c6e93c..d8af904f19b85 100644 --- a/web/packages/core/src/internal/player/inner.tsx +++ b/web/packages/core/src/internal/player/inner.tsx @@ -26,7 +26,6 @@ import { showPanicScreen } from "../ui/panic"; import { createRuffleBuilder } from "../../load-ruffle"; import { lookupElement } from "../register-element"; import { configureBuilder } from "../builder"; -import { referenceTypes } from "wasm-feature-detect"; const DIMENSION_REGEX = /^\s*(\d+(\.\d+)?(%)?)/; @@ -856,16 +855,6 @@ export class InnerPlayer { this.loadedConfig.backgroundColor; } - // 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 - // but this is the only extension I know completely breaks our WASM module if unsupported - const necessaryExtensionsSupported: boolean = await referenceTypes(); - if (!necessaryExtensionsSupported) { - const baseError = new Error("Necessary WebAssembly extensions unsupported"); - const loadError = new LoadRuffleWasmError(baseError); - this.panic(loadError); - return; - } - await this.ensureFreshInstance(); if ("url" in options) { diff --git a/web/packages/core/src/internal/ui/panic.tsx b/web/packages/core/src/internal/ui/panic.tsx index 75cfbae494519..c8893fc397d28 100644 --- a/web/packages/core/src/internal/ui/panic.tsx +++ b/web/packages/core/src/internal/ui/panic.tsx @@ -246,6 +246,19 @@ function createPanicError(error: Error | null): { }; } + if (error.cause.name === "CompileError" && message.includes("bad type")) { + // Self hosted: User has a browser without support for necessary WebAssembly extensions + return { + body: textAsParagraphs("error-wasm-unsupported-browser"), + actions: [ + CommonActions.openWiki( + "#web", + ), + CommonActions.ShowDetails, + ], + }; + } + if (error.cause.name === "CompileError") { // Self hosted: Cannot load `.wasm` file - incorrect configuration or missing files return { @@ -308,19 +321,6 @@ function createPanicError(error: Error | null): { }; } - if (message === "necessary webassembly extensions unsupported") { - // Self hosted: User has a browser without support for necessary WebAssembly extensions - return { - body: textAsParagraphs("error-wasm-unsupported-browser"), - actions: [ - CommonActions.openWiki( - "#web", - ), - CommonActions.ShowDetails, - ], - }; - } - // Self hosted: Cannot load `.wasm` file - file not found return { body: textAsParagraphs("error-wasm-not-found"),