Skip to content

Cleanup of non-browser prefetch code #93

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

danleh
Copy link
Contributor

@danleh danleh commented Jul 14, 2025

@kmiller68 and @camillobruni Could you take a look?

There were several problems (see also #86):

  • The fileLoader singleton contained code for the browser, which was actually dead.
  • benchmark.fetchResources was called twice in the CLI, once in Driver.addBenchmark and once again in Driver.initialize
  • For several of the Benchmark.prefetch*/retryPrefetch*/fetchResources methods, it wasn't clear that they would only be called in the browser/non-browser setting, which also resulted in dead and unnecessarily complex code.

We can probably clean up more still, especially for the browser prefetching (see TODOs).

There were several problems (see also WebKit#86):
- The `fileLoader` singleton contained code for the browser, which was actually dead.
- `benchmark.fetchResources` was called twice in the CLI, once in `Driver.addBenchmark` and once again in `Driver.initialize`
- For several of the `Benchmark.prefetch*/retryPrefetch*/fetchResources` methods, it wasn't clear that they would only be called in the browser/non-browser setting, which also resulted in dead and unnecessarily complex code.

We can probably clean up more still, especially for the browser prefetching (see TODOs).
Copy link

netlify bot commented Jul 14, 2025

Deploy Preview for webkit-jetstream-preview ready!

Name Link
🔨 Latest commit 78070d5
🔍 Latest deploy log https://app.netlify.com/projects/webkit-jetstream-preview/deploys/687525126742be0008eb11d2
😎 Deploy Preview https://deploy-preview-93--webkit-jetstream-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.


let response;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These following lines were dead code, since fileLoader.load and thus _loadInternal were only called from non-browser code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, since the remaining non-browser only code doesn't use promises at all, this doesn't need to be async any longer. And this propagates further up the call chain.

Copy link
Contributor

Choose a reason for hiding this comment

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

ACK.

@@ -498,16 +481,6 @@ class Driver {
}

JetStream.loadCache = { }; // Done preloading all the files.
}

async fetchResources() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Merged with prefetchResourcesForBrowser into prefetchResources.

@@ -181,47 +181,27 @@ function uiFriendlyDuration(time) {
return `${time.toFixed(3)} ms`;
}

// TODO: Cleanup / remove / merge. This is only used for caching loads in the
// non-browser setting. In the browser we use exclusively `loadCache`,
// `loadBlob`, `doLoadBlob`, `prefetchResourcesForBrowser` etc., see below.
const fileLoader = (function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

future-nit: we could actually start using modules instead of these "hacky" IFEEs to hide the classes.

@camillobruni camillobruni requested a review from kmiller68 July 14, 2025 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants