Skip to content

Conversation

kjarosh
Copy link
Member

@kjarosh kjarosh commented Sep 10, 2025

This hopefully will improve loading time.

@kjarosh kjarosh added A-web Area: Web & Extensions extension Related to the Ruffle WebExtension T-perf Type: Performance Improvements labels Sep 10, 2025
@kjarosh kjarosh marked this pull request as draft September 10, 2025 18:18
This hopefully will improve loading time.
@kjarosh kjarosh force-pushed the extension-opts-perf branch from e44338d to 8425254 Compare September 10, 2025 18:22
const { swfTakeover } = await utils.getOptions();
if (swfTakeover) {
await enableSWFTakeover();
async function enable(opt: Options | null = null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this be equivalent (same for enableSWFTakeover)?

async function enable(opt?: Options) {

Copy link
Contributor

@danielhjacobs danielhjacobs left a comment

Choose a reason for hiding this comment

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

This works fine and I don't see a downside and it makes sense, but in testing it seems like the speed difference is negligible.

For testing, I built Ruffle with this commit and Ruffle without this commit (checking out the prior commit), and added some logging.

Namely, in both versions I added this to the start:

let startTime: number | null = null;

Added this inside the if in the IIFE:

startTime = performance.now();

And added this in the if (options.ruffleEnable)/if (ruffleEnable) in enableSWFTakeover:

            if (startTime !== null) {
                const elapsed = performance.now() - startTime;
                console.log(`[Perf] enableSWFTakeover reached ruffleEnable check in ${elapsed.toFixed(2)} ms`);
            }

Loading both into Chromium where header conditions are supported, I opened "service worker" in chrome://extensions/ for Ruffle. In the console log for background.js, the time it took to progress through those functions was within the margin of error between the two (toggling the extension on and then off then reopening the service worker log serves to give another data point, and what I mean is the time it took for one was between the min and max time it could take for the other).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-web Area: Web & Extensions extension Related to the Ruffle WebExtension T-perf Type: Performance Improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants