Changeset 250985 in webkit
- Timestamp:
- Oct 10, 2019 12:52:04 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r250983 r250985 1 2019-10-10 Youenn Fablet <youenn@apple.com> 2 3 Do not timeout a load intercepted by service worker that receives a response 4 https://bugs.webkit.org/show_bug.cgi?id=202787 5 6 Reviewed by Chris Dumez. 7 8 * http/wpt/service-workers/fetch-timeout-worker.js: Added. 9 (async.doTest): 10 * http/wpt/service-workers/fetch-timeout.https-expected.txt: Added. 11 * http/wpt/service-workers/fetch-timeout.https.html: Added. 12 * http/wpt/service-workers/resources/lengthy-pass.py: 13 (main): 14 1 15 2019-10-10 Myles C. Maxfield <mmaxfield@apple.com> 2 16 -
trunk/LayoutTests/http/wpt/service-workers/resources/lengthy-pass.py
r249096 r250985 3 3 def main(request, response): 4 4 delay = 0.05 5 headers = [] 6 if "delay" in request.GET: 7 delay = float(request.GET.first("delay")) 5 8 response.headers.set("Content-type", "text/javascript") 6 9 response.headers.append("Access-Control-Allow-Origin", "*") -
trunk/Source/WebKit/ChangeLog
r250974 r250985 1 2019-10-10 Youenn Fablet <youenn@apple.com> 2 3 Do not timeout a load intercepted by service worker that receives a response 4 https://bugs.webkit.org/show_bug.cgi?id=202787 5 6 Reviewed by Chris Dumez. 7 8 Stop making ServiceWorkerFetchTask ref counted since it is not needed and 9 can potentially make ServiceWorkerFetchTask oulive its WebSWServerToContextConnection member. 10 11 Stop the ServiceWorkerFetchTask timeout timer whenever receiving a response so that the load will not timeout in that case. 12 This ensures that a load that is starting in a service worker will not be failing. 13 Instead the load will go to network process. 14 15 Removed m_didReachTerminalState which is not needed as WebSWServerToContextConnection unregisters the ServiceWorkerFetchTask 16 as an IPC listener for all terminating messages. 17 18 * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp: 19 (WebKit::ServiceWorkerFetchTask::didReceiveRedirectResponse): 20 (WebKit::ServiceWorkerFetchTask::didReceiveResponse): 21 (WebKit::ServiceWorkerFetchTask::didReceiveData): 22 (WebKit::ServiceWorkerFetchTask::didReceiveFormData): 23 (WebKit::ServiceWorkerFetchTask::didFinish): 24 (WebKit::ServiceWorkerFetchTask::didFail): 25 (WebKit::ServiceWorkerFetchTask::didNotHandle): 26 (WebKit::ServiceWorkerFetchTask::timeoutTimerFired): 27 * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.h: 28 * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp: 29 (WebKit::WebSWServerToContextConnection::startFetch): 30 (WebKit::WebSWServerToContextConnection::fetchTaskTimedOut): 31 Use a Vector instead of a HasSet for performance reasons. 32 Update according fetch map using unique_ptr instead of Ref<>. 33 * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h: 34 1 35 2019-10-10 Rob Buis <rbuis@igalia.com> 2 36 -
trunk/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp
r250852 r250985 60 60 { 61 61 RELEASE_LOG_IF_ALLOWED("didReceiveRedirectResponse: %s", m_identifier.fetchIdentifier.loggingString().utf8().data()); 62 m_timeoutTimer.stop(); 62 63 m_wasHandled = true; 63 64 if (m_connection) … … 68 69 { 69 70 RELEASE_LOG_IF_ALLOWED("didReceiveResponse: %s", m_identifier.fetchIdentifier.loggingString().utf8().data()); 71 m_timeoutTimer.stop(); 70 72 m_wasHandled = true; 71 73 if (m_connection) … … 75 77 void ServiceWorkerFetchTask::didReceiveData(const IPC::DataReference& data, int64_t encodedDataLength) 76 78 { 79 ASSERT(!m_timeoutTimer.isActive()); 77 80 if (m_connection) 78 81 m_connection->send(Messages::ServiceWorkerClientFetch::DidReceiveData { data, encodedDataLength }, m_identifier.fetchIdentifier); … … 81 84 void ServiceWorkerFetchTask::didReceiveFormData(const IPC::FormDataReference& formData) 82 85 { 86 ASSERT(!m_timeoutTimer.isActive()); 83 87 if (m_connection) 84 88 m_connection->send(Messages::ServiceWorkerClientFetch::DidReceiveFormData { formData }, m_identifier.fetchIdentifier); … … 87 91 void ServiceWorkerFetchTask::didFinish() 88 92 { 93 ASSERT(!m_timeoutTimer.isActive()); 89 94 RELEASE_LOG_IF_ALLOWED("didFinishFetch: fetchIdentifier: %s", m_identifier.fetchIdentifier.loggingString().utf8().data()); 90 95 m_timeoutTimer.stop(); 91 if ( !m_didReachTerminalState &&m_connection)96 if (m_connection) 92 97 m_connection->send(Messages::ServiceWorkerClientFetch::DidFinish { }, m_identifier.fetchIdentifier); 93 m_didReachTerminalState = true;94 98 } 95 99 … … 98 102 RELEASE_LOG_ERROR_IF_ALLOWED("didFailFetch: fetchIdentifier: %s", m_identifier.fetchIdentifier.loggingString().utf8().data()); 99 103 m_timeoutTimer.stop(); 100 if ( !m_didReachTerminalState &&m_connection)104 if (m_connection) 101 105 m_connection->send(Messages::ServiceWorkerClientFetch::DidFail { error }, m_identifier.fetchIdentifier); 102 m_didReachTerminalState = true;103 106 } 104 107 … … 107 110 RELEASE_LOG_IF_ALLOWED("didNotHandleFetch: fetchIdentifier: %s", m_identifier.fetchIdentifier.loggingString().utf8().data()); 108 111 m_timeoutTimer.stop(); 109 if ( !m_didReachTerminalState &&m_connection)112 if (m_connection) 110 113 m_connection->send(Messages::ServiceWorkerClientFetch::DidNotHandle { }, m_identifier.fetchIdentifier); 111 m_didReachTerminalState = true;112 114 } 113 115 … … 115 117 { 116 118 RELEASE_LOG_IF_ALLOWED("timeoutTimerFired: fetchIdentifier: %s", m_identifier.fetchIdentifier.loggingString().utf8().data()); 117 if (!m_wasHandled) 118 didNotHandle(); 119 else 120 didFail({ errorDomainWebKitInternal, 0, { }, "Service Worker fetch timed out"_s }); 121 119 didNotHandle(); 122 120 m_contextConnection.fetchTaskTimedOut(*this); 123 121 } -
trunk/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.h
r250852 r250985 32 32 #include <WebCore/Timer.h> 33 33 #include <pal/SessionID.h> 34 #include <wtf/RefCounted.h>35 34 36 35 namespace WebCore { … … 51 50 class WebSWServerToContextConnection; 52 51 53 class ServiceWorkerFetchTask : public RefCounted<ServiceWorkerFetchTask> { 52 class ServiceWorkerFetchTask { 53 WTF_MAKE_FAST_ALLOCATED; 54 54 public: 55 template<typename... Args> static Ref<ServiceWorkerFetchTask> create(Args&&... args) 56 { 57 return adoptRef(*new ServiceWorkerFetchTask(std::forward<Args>(args)...)); 58 } 55 ServiceWorkerFetchTask(PAL::SessionID, WebSWServerConnection&, WebSWServerToContextConnection&, WebCore::FetchIdentifier, WebCore::ServiceWorkerIdentifier, Seconds timeout); 59 56 60 57 void didNotHandle(); … … 80 77 81 78 private: 82 ServiceWorkerFetchTask(PAL::SessionID, WebSWServerConnection&, WebSWServerToContextConnection&, WebCore::FetchIdentifier, WebCore::ServiceWorkerIdentifier, Seconds timeout);83 84 79 void didReceiveRedirectResponse(const WebCore::ResourceResponse&); 85 80 void didReceiveResponse(const WebCore::ResourceResponse&, bool needsContinueDidReceiveResponseMessage); … … 98 93 WebCore::Timer m_timeoutTimer; 99 94 bool m_wasHandled { false }; 100 bool m_didReachTerminalState { false };101 95 }; 102 96 -
trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp
r250852 r250985 158 158 auto fetchIdentifier = FetchIdentifier::generate(); 159 159 160 auto result = m_ongoingFetches.add(fetchIdentifier, ServiceWorkerFetchTask::create(sessionID, contentConnection, *this, contentFetchIdentifier, serviceWorkerIdentifier, m_networkProcess->serviceWorkerFetchTimeout()));160 auto result = m_ongoingFetches.add(fetchIdentifier, makeUnique<ServiceWorkerFetchTask>(sessionID, contentConnection, *this, contentFetchIdentifier, serviceWorkerIdentifier, m_networkProcess->serviceWorkerFetchTimeout())); 161 161 162 162 ASSERT(!m_ongoingFetchIdentifiers.contains({ serverConnectionIdentifier, contentFetchIdentifier })); … … 216 216 auto takenTask = m_ongoingFetches.take(takenIdentifier); 217 217 ASSERT(takenTask); 218 ASSERT(takenTask ->ptr() == &task);218 ASSERT(takenTask.get() == &task); 219 219 220 220 // Gather all other fetches in this service worker 221 HashSet<Ref<ServiceWorkerFetchTask>> otherFetches;221 Vector<ServiceWorkerFetchTask*> otherFetches; 222 222 for (auto& fetchTask : m_ongoingFetches.values()) { 223 223 if (fetchTask->serviceWorkerIdentifier() == task.serviceWorkerIdentifier()) 224 otherFetches.a dd(fetchTask.copyRef());224 otherFetches.append(fetchTask.get()); 225 225 } 226 226 227 227 // Signal load failure for them 228 for (auto &fetchTask : otherFetches) {228 for (auto* fetchTask : otherFetches) { 229 229 if (fetchTask->wasHandled()) 230 230 fetchTask->fail({ errorDomainWebKitInternal, 0, { }, "Service Worker context closed"_s }); -
trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h
r250852 r250985 104 104 105 105 HashMap<ServiceWorkerFetchTask::Identifier, WebCore::FetchIdentifier> m_ongoingFetchIdentifiers; 106 HashMap<WebCore::FetchIdentifier, Ref<ServiceWorkerFetchTask>> m_ongoingFetches;106 HashMap<WebCore::FetchIdentifier, std::unique_ptr<ServiceWorkerFetchTask>> m_ongoingFetches; 107 107 bool m_isThrottleable { true }; 108 108 }; // class WebSWServerToContextConnection
Note: See TracChangeset
for help on using the changeset viewer.