-
Notifications
You must be signed in to change notification settings - Fork 339
Persistent Playground: Sync between MEMFS and OPFS #546
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
Merged
Conversation
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
This commit explores a custom OPFS filesystem backend for Playground to avoid losing changes after a page refresh. Status: Playground works in read-only mode. Writing and reading entire files and directories works, but there's something off with seeking. For example, inserting a post yields `General error: 10 disk I/O error.` I could not reproduce it with a simple fseek() call from PHP, unfortunately.
there is one last issue I may not be able to figure out before my Sabbatical (June 26th - Sep 26th). This PR attempts another approach of syncing MEMFS changes to OPFS and restoring them after a page refresh. The main idea is: 1. Compare last modified time 2. Copy MEMFS files to OPFS if they were updated more recently The current implementation is quite slow as everything happens synchronously and frequently, but it can be significantly improved.
…l implementation fails to persist the SQLite file
0082512
to
d4ce206
Compare
There is no noticeable difference, let's roll back.
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.
Description
#544 explores a full Emscripten OPFS filesystem backend, but
there is one last issue I may not be able to figure out before my
Sabbatical (June 26th - Sep 26th).
This PR attempts another approach I should be able to ship. Namely,
it synchronizes MEMFS changes to OPFS and restores them after a
page refresh.
The main idea is:
OPFS is only supported in Chrome-based browsers at the moment like Edge, Android browser. Safari and Firefox users won't be able to benefit from this feature yet
Performance
Other explored approaches
This approach failed:
mtime
doesn't bubble up through directories and comparing all files is too slow.Screenshots
CleanShot.2023-06-13.at.10.47.30.1.mp4
Remaining work
@wp-playground/remote
packageFollow-up work
cc @eliot-akira @dmsnell