-
Notifications
You must be signed in to change notification settings - Fork 274
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
Progress bar broken #1667
Comments
Actually, I was wrong. This change in phpApi.onDownloadProgress(function () {
console.log('progress', arguments);
})
const wpFrame = document.querySelector('#wp') as HTMLIFrameElement;
const webApi: WebClientMixin = {
async onDownloadProgress(fn) {
console.log("Registering progress 2")
phpApi.onDownloadProgress(function () {
console.log('progress2', arguments);
})
return phpApi.onDownloadProgress(fn);
}, That's likely related to the recent boot sequence updates, and perhaps to registering the service worker before the web worker. Edit: Actually, this is weird. I'm getting seemingly non-deterministic results. Sometimes it's this, sometimes I'm getting the events. |
@adamziel in my tests so far, I am seeing progress events in emscripten-download-monitor for the sqlite-database-integration and WP zips before any updates to the progress tracker. Here's the console log from one of my runs: |
When testing with the #1668 PR, I am seeing the same for the first load except now the empscripten-download-monitor logs include the php-wasm download. |
@adamziel I think this must be happening because the worker-thread API, which exposes the onDownloadProgress method, is not marked as ready until after the sqlite-database-integration and WP zip downloads have completed. How:
Consumers of the PlaygroundWorkerEndpoint API hook into |
Maybe we should:
As an aside, if we ever want to consider allowing PHP subrequests during WordPress install (see #1644), we could use a similar approach so PHP request routing can be set up before WP install. |
@brandonpayton wordpress-playground/packages/playground/client/src/index.ts Lines 180 to 181 in 51e5502
|
@adamziel Thank you for correcting my mental model. 🙇 Accepting that my previous understanding is incorrect, I still wonder why we are seeing progress events in the worker-thread while the progress tracker is not. When I'm back from AFK (and if this issue still exists), I should probably instrument the rest of the progress consumers and observe what is happening. There at least seems to be a break in the chain leading to the progress-tracker because emscripten-download-monitor in worker-thread is seeing steps of progress during download. |
Sorry, @adamziel. You have been saying this all along. I'm not sure why I didn't notice yesterday as I did read your comment. Probably good that I'm (mostly) take a break today. |
This has been a bit confusing as sometimes the progress bar seems to work fine, and other times it seems to stall for quite a while before finishing. I wonder if this is a problem with something else causing slow initialization or somehow blocking progress reporting. |
Update: The progress bar stays empty for a while, but then it starts gradually filling up. I don't believe it reflects the actual download progress, but at least it does something. Let's hold on with this work until #1731 lands as it profoundly changes the state management logic and I'd rather avoid fixing this issue twice. |
## Motivation for the change, related issues Prior to this change, the service worker was not making the response available to consumers until the response was placed in the offline cache. It looks like the entire response had to be buffered before consumers had a chance to observe response progress, and at that point, there was no progress to observe because the download was complete. Props to @adamziel for noticing this cause. Fixes #1667 ## Implementation details This updates service worker request caching so that responses are made available downstream before caching is complete. ## Testing Instructions (or ideally a Blueprint) - CI
This is a high priority issue.
The progress bar foes from 0% to 50% in one go without any visible increments. The problem seems to be with the requests routed through the service worker – the
fetch()
in web worker isn't getting any progress updates from the readable stream, as if the service worker was buffering the response body stream before passing the Response object to the app. This also means we're not stream-loading the PHP WASM file anymore.Here's one workaround I found on the internet:
https://github.com/anthumchris/fetch-progress-indicators/blob/master/sw-basic/sw-simple.js
I almost refuse to believe it's this complicated, though. Maybe we're missing something obvious around here:
wordpress-playground/packages/playground/remote/service-worker.ts
Lines 92 to 95 in 1f28d77
cc @bgrgicak @brandonpayton
The text was updated successfully, but these errors were encountered: