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: Throw an error when reference types are unsupported #18838

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

danielhjacobs
Copy link
Contributor

@danielhjacobs danielhjacobs commented Dec 2, 2024

This is somewhat the antithesis of #18528. That PR keeps Ruffle running on browsers without reference types support. This instead forces an error on those browsers.

Merging #18399 will break Ruffle on Safari versions below 15 and Pale Moon. We can keep Ruffle working on those browsers, or we can officially designate them to be unsupported.

@danielhjacobs danielhjacobs force-pushed the throw-direct-error-when-reference-types-unsupported branch from c5b9550 to fec7b36 Compare December 2, 2024 20:56
@danielhjacobs danielhjacobs added A-web Area: Web & Extensions T-fix Type: Bug fix (in something that's supposed to work already) labels Dec 2, 2024
// 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) {
Copy link
Contributor Author

@danielhjacobs danielhjacobs Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Right here, it would be possible by exporting isFlashEnabledBrowser from the polyfills file and importing it here to add this code:

                if ("url" in options && isFlashEnabledBrowser()) {
                    const flashEmbed = Object.assign(document.createElement('embed'), {
                        src: new URL(options.url, document.baseURI).href,
                        width: "100%",
                        height: "100%",
                    });
                    this.container.textContent = "";
                    this.container.appendChild(flashEmbed);
                    return;
                }

That would create a Flash embed on Flash-enabled browsers which do not have reference-types support when using the Ruffle API with a URL (rather than a data buffer). It ignores any configuration options in favor of simplicity, though we can be less simple by doing this: https://github.com/ruffle-rs/ruffle/pull/16523/files#diff-467a580c71d4e3b96032b54a2a292d485f3b83f87ba2478daf693bac6d532965R1019-R1041

That said, it may not be desired as noted in #16523

Copy link
Contributor Author

@danielhjacobs danielhjacobs Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

danielhjacobs/ruffle@throw-direct-error-when-reference-types-unsupported...danielhjacobs:ruffle:make-embed-if-flash-supported-ruffle-not

This would create Flash embeds if reference-types is unsupported but Flash is supported. I mainly just wrote it for fun, as it was interesting to try to let DataLoadOptions work too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-web Area: Web & Extensions T-fix Type: Bug fix (in something that's supposed to work already)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant