Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 9baf1695f93dd8f0e7abb02a6b0f9076dcdd8323
https://github.com/WebKit/WebKit/commit/9baf1695f93dd8f0e7abb02a6b0f9076dcdd8323
Author: Youenn Fablet <[email protected]>
Date: 2026-07-31 (Fri, 31 Jul 2026)
Changed paths:
M LayoutTests/http/wpt/service-workers/upload-stream-backpressure-worker.js
M
LayoutTests/http/wpt/service-workers/upload-stream-backpressure.https-expected.txt
M LayoutTests/http/wpt/service-workers/upload-stream-backpressure.https.html
M Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp
M Source/WebCore/Modules/fetch/FetchBodySource.cpp
M Source/WebCore/Modules/fetch/FetchBodySource.h
M Source/WebCore/Modules/fetch/FormDataConsumer.cpp
M Source/WebCore/Modules/fetch/FormDataConsumer.h
M
Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp
M
Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h
M
Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.messages.in
M Source/WebKit/WebProcess/Network/WebResourceLoader.cpp
M Source/WebKit/WebProcess/Network/WebResourceLoader.h
M Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp
Log Message:
-----------
Support stream upload back pressure in case of service worker reading the
upload data
rdar://183529369
https://bugs.webkit.org/show_bug.cgi?id=320562
Reviewed by Alex Christensen.
Before this PR, whenever the service worker was starting to read the upload
body, we would send upload data as fast as possible to the service worker.
WebResourceLoader is now sending only a first burst of data (64ko) and waits
for the service worker to acknowledge that it has received this data.
Service worker is registering a drained handler on the service worker stream
upload.
Whenever the web page reads enough data to trigger the drained handler, the
service worker will send IPC to network process,
that will forward the IPC to WebResourceLoader, which will send another burst
of data (64ko) before waiting for a new message from service worker.
We need to tie the fetch body stream backpressure mechanism to the
PendingStreamState backpressure.
To do so, we make FormDataConsumer wait for a signal from FetchBodySource to
actually draing the PendingStreamState.
We introduce FormDataConsumer::resume, which takes the pull promise.
The pull promise gets resolved when some chunks are pushed in the fetch body
stream.
Once the JS reads sufficient data, FetchBodySource::pull will be called again,
which will resume FormDataConsumer.
Covered by updated test.
* LayoutTests/http/wpt/service-workers/upload-stream-backpressure-worker.js:
(event.event.respondWith.async await):
(event.event.respondWith):
(event.url.searchParams): Deleted.
*
LayoutTests/http/wpt/service-workers/upload-stream-backpressure.https-expected.txt:
* LayoutTests/http/wpt/service-workers/upload-stream-backpressure.https.html:
* Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp:
(WebCore::FetchBodyConsumer::consumeFormDataAsStream):
* Source/WebCore/Modules/fetch/FetchBodySource.cpp:
(WebCore::FetchBodySource::pull):
(WebCore::FetchBodySource::setFormDataConsumer):
(WebCore::FetchBodySource::isPulling const):
(WebCore::FetchBodySource::resolvePullPromise):
* Source/WebCore/Modules/fetch/FetchBodySource.h:
* Source/WebCore/Modules/fetch/FormDataConsumer.cpp:
(WebCore::FormDataConsumer::consumePendingStream):
(WebCore::FormDataConsumer::drainPendingStream):
(WebCore::FormDataConsumer::resume):
* Source/WebCore/Modules/fetch/FormDataConsumer.h:
(WebCore::FormDataConsumer::hasPendingPull const):
* Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp:
(WebKit::WebSWServerToContextConnection::pendingStreamUploadNeedData):
* Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h:
*
Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.messages.in:
* Source/WebKit/WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::drainPendingStreamIfPossible):
(WebKit::WebResourceLoader::serviceWorkerPendingStreamForwardingNeedData):
* Source/WebKit/WebProcess/Network/WebResourceLoader.h:
* Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::startFetch):
Canonical link: https://commits.webkit.org/318346@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications