-
Notifications
You must be signed in to change notification settings - Fork 275
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
Early draft of storing temp sites in OPFS #1838
Conversation
Some things left to do:
|
Added one more item to the above list:
I also took a look at making sure opfs-temporary sites actually had OPFS mounts, but when I did so, WordPress installation failed because the site's directory already existed with a |
Also changed
to
|
I took some time and added a few things. There is now a If a |
Oh no! Saving fresh sites to OPFS takes a considerable amount of time, like 12 seconds. Such a long waiting time is quite a bad first user experience. Remembering my explorations around zip streaming and OPFS, here's a breakdown of the things that require significant processing time:
Perhaps we could start with a simple MEMFS site and then run a non-blocking synchronization in the background while somehow The risk there would be the user closing their browser tab before the sync is complete – we'd need to add an |
Aha, but WordPress is not present in OPFS yet during the very first site boot, therefore we don't have to block loading the site for the 12 seconds it takes to synchronize MEMFS to OPFS – there are no files to synchronize yet. |
I've just pushed archived sites management and the code to write new temp-opfs sites to OPFS. We'll still need to retain the "in-memory" storage for, e.g., Safari in private mode. |
The experience I went for is this:
I'm having second thoughts. I wonder how will that feel for the user – sometimes a site disappears, sometimes it doesn't. Also, we'll eventually need something to prevent conflicting writes to the same OPFS site from multiple Playground instances. Alternatively, we could always run those sites in a SharedWorker and avoid any synchronization. That wouldn't work in Safari today, but maybe that's okay. |
Would unarchiving on request be sufficient for reducing user confusion if we wait a week before deleting archived sites? How practical this is may depend on device storage quotas and availability. But if we run into limits, maybe we could clean up archived sites earlier, starting with the once loaded longest ago. |
@adamziel and I spoke a bit about this, and it might make sense for us to maintain some of this app-specific state separately from the We could have a file like
|
Thanks for working on these things, @bgrgicak. Agreed about renaming later if there's no benefit. |
Next up:
I'm hoping to make good progress on these yet today, but please feel free to take any of these if you agree with the direction when you pick up this PR. 🙇 |
We are discussing backing off of this approach as it is making temporary sites less temporary. Instead, we need to find a way to coordinate app updates with users. Let's pause this until we decide what to do. |
680cd19
to
2e376d2
Compare
Let's discontinue this work:
This reveals a larger, strategic point: The Playground webapp may never have advanced site management features such as:
Building these features is definitely possible, but it requires spending significant amount of time and effort from building the platform to building a user-facing product. Let's leave that to app authors. |
…first strategy (#1849) ## Motivation for the change, related issues Related to #1821 Changes the webapp upgrade protocol proposed in #1822 to avoid forcibly refreshing the browser tabs with unsaved changes in them. ## Technical implementation **Before this PR**, the new service worker would clear the offline cache, claim all the active clients, and forcibly refresh them to ensure the latest Playground version is loaded everywhere. This worked, but every webapp upgrade would destroy any work the user may have done in their temporary Playground. We've explored [storing temporary Playgrounds in OPFS](#1838), but backtracked because 1) it created an uncanny amount of complexity, and 2) some browsers (e.g. Safari in private mode) don't support OPFS and must rely on a temporary in-memory site. **After this PR**, the service worker clears the offline cache, claims all the active clients, but it doesn't forcibly refresh them. Instead, it uses the network-first strategy for the `remote.html` route and the `/` route. All the other files are still loaded using the cache-first strategy. Every Playground that's already open, either temporary or stored, will remain functional. The heavy, asynchronously loaded resources such as PHP.wasm and WordPress.zip were already processed – there's no user flow that could lead to `import()`-ing a non-existing `php.js` file. Every newly opened Playground will be loaded using a freshly downloaded `remote.html` file containing references to freshly deployed Playground assets. Thus ## Other changes This PR inlines the reusable service worker utilities from `packages/php-wasm/web/src/lib/register-service-worker.ts` into `@wp-playground` packages. It turns out, they weren't as reusable and keeping them separate was annoying. I'm now convinced the service worker bits are application specific and splitting them between multiple packages just isn't useful. ## Testing instructions Review the app deployment E2E tests check what we need to check, and them confirm they are green in the CI.
Motivation for the change, related issues
After #1822, Playground forcibly refreshes all the browser tabs after deploying a new webapp version. This fixes version upgrades, but it also causes data loss in the temporary Playgrounds running in those refreshed tabs. Let's explore storing all that temporary data in OPFS so we can restore it after a page refresh.