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

Register service worker before spawning the worker thread #1606

Merged
merged 9 commits into from
Jul 15, 2024

Conversation

bgrgicak
Copy link
Collaborator

@bgrgicak bgrgicak commented Jul 12, 2024

Motivation for the change, related issues

For offline support we need to load the service worker as early as possible in the boot process.

Booting early will allow fetch caching to cache more files on the first making the backfill of assets simpler.

Read the full research recap here #1600 (review)

Implementation details

To move registerServiceWorker to the start of the boot process we had to generate the scope in bootPlaygroundRemote and pass it to the PHP worker thread together with other startup options.

The service worker had to be registered before spawning the PHP worker thread to ensure WP and PHP assets were cached. But the service worker also depends on the phpApi returned by spawnPHPWorkerThread.
We had to register the service worker first, after that, spawn the PHP worker thread, and then set the phpApi.

This PR also includes changes from #1574 because they allow us to pass the scope.

Testing Instructions (or ideally a Blueprint)

  • Ensure all tests pass

@bgrgicak bgrgicak self-assigned this Jul 12, 2024
@bgrgicak bgrgicak marked this pull request as ready for review July 12, 2024 09:13
@bgrgicak bgrgicak requested a review from a team July 12, 2024 09:15
@bgrgicak bgrgicak changed the title Register service worker before the Worker API Register service worker before the PHP API Jul 12, 2024
@bgrgicak bgrgicak changed the title Register service worker before the PHP API Register service worker before spawning the worker thread Jul 12, 2024
@bgrgicak bgrgicak requested a review from adamziel July 15, 2024 07:23
phpVersion: event.data.startupOptions.phpVersion,
storage: event.data.startupOptions.storage,
sapiName: event.data.startupOptions.sapiName,
phpExtensions: event.data.startupOptions['php-extension'],
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to make these names consistent one day

@adamziel adamziel merged commit b5eec74 into trunk Jul 15, 2024
5 checks passed
@adamziel adamziel deleted the update/register-sw-before-worker-thread branch July 15, 2024 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants