Cleanup of non-browser prefetch code#93
Merged
danleh merged 2 commits intoWebKit:mainfrom Jul 23, 2025
Merged
Conversation
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).
✅ Deploy Preview for webkit-jetstream-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
danleh
commented
Jul 14, 2025
| load(url) { | ||
| assert(!isInBrowser); | ||
|
|
||
| let response; |
Contributor
Author
There was a problem hiding this comment.
These following lines were dead code, since fileLoader.load and thus _loadInternal were only called from non-browser code.
Contributor
Author
There was a problem hiding this comment.
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.
danleh
commented
Jul 14, 2025
| JetStream.loadCache = { }; // Done preloading all the files. | ||
| } | ||
|
|
||
| async fetchResources() { |
Contributor
Author
There was a problem hiding this comment.
Merged with prefetchResourcesForBrowser into prefetchResources.
danleh
commented
Jul 14, 2025
| // 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() { |
Contributor
There was a problem hiding this comment.
future-nit: we could actually start using modules instead of these "hacky" IFEEs to hide the classes.
camillobruni
approved these changes
Jul 14, 2025
kmiller68
approved these changes
Jul 17, 2025
Contributor
|
@danleh Should we merge this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@kmiller68 and @camillobruni Could you take a look?
There were several problems (see also #86):
fileLoadersingleton contained code for the browser, which was actually dead.benchmark.fetchResourceswas called twice in the CLI, once inDriver.addBenchmarkand once again inDriver.initializeBenchmark.prefetch*/retryPrefetch*/fetchResourcesmethods, 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).