This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse the repository at this point in the history
JSON Parse error: Unrecognized token '<' on web.autocad.com
https://bugs.webkit.org/show_bug.cgi?id=243418 <rdar://96271134> Reviewed by Geoffrey Garen. There were two issues on web.autocad.com: 1. The service worker intercepts certain types of loads and the service worker is meant to respond to those loads with content that was previously sent to it via postMessage(). If, when a load request comes in, the service worker didn't previously receive the data for this load via postMessage(), it will do a setInterval(1) and keep checking if it received a postMessage for this load or not. In practice, we see that a postMessage() may not come for a long time (verified on Chrome too), leaving the load request hanging. Chrome seems to allow this but in WebKit, we have a timeout timer that fires after 70 seconds and kills the service worker due to "unresponsiveness". 2. Even though the loads are properly intercepted by the service worker the first time, it is no longer the case on reload. The reason for this is that those loads come from a dedicated worker and the second around, this dedicated worker script is fetched from the memory cache instead of going to the network process. As a result of this, the dedicated worker is not properly marked as controlled by the service worker and all future loads by this dedicated worker won't go through the service worker. This break autocad since they rely on those loads to be intercepted by the service worker to serve particular JSON content. By bypassing the service worker, the loads go to the network and don't get the JSON content they expect. To address issue 1, I am disabling the timeout timer for subresource loads and keeping it only for main resource navigations. This allows us to support the use case of autocad, while keeping a responsiveness check for navigations. To address issue 2, I am updating mustReloadFromServiceWorkerOptions() to return true for dedicated worker loads when there is an active service worker. This causes us to bypass the memory cache in this case, making sure the dedicated worker is marked as controlled by the service worker, even on reload. With those two fixes, I no longer see any `Unrecognized token '<'` errors on web.autocad.com. * LayoutTests/http/tests/workers/service/interception-from-dedicated-worker-on-reload-expected.txt: Added. * LayoutTests/http/tests/workers/service/interception-from-dedicated-worker-on-reload.html: Added. * LayoutTests/http/tests/workers/service/resources/foo.txt: Added. * LayoutTests/http/tests/workers/service/resources/interception-from-dedicated-worker-on-reload-cacheable-worker.py: Added. * LayoutTests/http/tests/workers/service/resources/interception-from-dedicated-worker-on-reload-iframe.html: Added. * LayoutTests/http/tests/workers/service/resources/interception-from-dedicated-worker-on-reload-sw.js: Added. (event.event.request.url.indexOf): * Source/WebCore/loader/cache/CachedResourceLoader.cpp: (WebCore::mustReloadFromServiceWorkerOptions): (WebCore::CachedResourceLoader::determineRevalidationPolicy const): * Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp: (WebKit::ServiceWorkerFetchTask::ServiceWorkerFetchTask): Canonical link: https://commits.webkit.org/253037@main
- Loading branch information
Showing 8 changed files with 105 additions and 4 deletions.