Changeset 244812 in webkit
- Timestamp:
- Apr 30, 2019, 4:56:05 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/WebPageProxy.cpp (modified) (3 diffs)
-
Source/WebKit/UIProcess/WebPageProxy.h (modified) (1 diff)
-
Source/WebKit/UIProcess/WebURLSchemeHandler.cpp (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebURLSchemeHandler.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebURLSchemeTask.h (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r244802 r244812 1 2019-04-30 Chris Dumez <cdumez@apple.com> 2 3 Unreviewed, rolling out r244802. 4 5 Caused an API test failure 6 7 Reverted changeset: 8 9 "Regression(PSON) URL scheme handlers can no longer respond 10 asynchronously" 11 https://bugs.webkit.org/show_bug.cgi?id=197426 12 https://trac.webkit.org/changeset/244802 13 1 14 2019-04-30 Chris Dumez <cdumez@apple.com> 2 15 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r244802 r244812 6742 6742 } 6743 6743 6744 stopAllURLSchemeTasks( m_process.ptr());6744 stopAllURLSchemeTasks(); 6745 6745 } 6746 6746 … … 6802 6802 } 6803 6803 6804 void WebPageProxy::stopAllURLSchemeTasks( WebProcessProxy* process)6804 void WebPageProxy::stopAllURLSchemeTasks() 6805 6805 { 6806 6806 HashSet<WebURLSchemeHandler*> handlers; … … 6809 6809 6810 6810 for (auto* handler : handlers) 6811 handler->stopAllTasksForPage(*this , process);6811 handler->stopAllTasksForPage(*this); 6812 6812 } 6813 6813 -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r244802 r244812 2002 2002 void viewIsBecomingVisible(); 2003 2003 2004 void stopAllURLSchemeTasks( WebProcessProxy* = nullptr);2004 void stopAllURLSchemeTasks(); 2005 2005 2006 2006 void clearInspectorTargets(); -
trunk/Source/WebKit/UIProcess/WebURLSchemeHandler.cpp
r244802 r244812 61 61 } 62 62 63 WebProcessProxy* WebURLSchemeHandler::processForTaskIdentifier(uint64_t taskIdentifier) const 64 { 65 auto iterator = m_tasks.find(taskIdentifier); 66 if (iterator == m_tasks.end()) 67 return nullptr; 68 return iterator->value->process(); 69 } 70 71 void WebURLSchemeHandler::stopAllTasksForPage(WebPageProxy& page, WebProcessProxy* process) 63 void WebURLSchemeHandler::stopAllTasksForPage(WebPageProxy& page) 72 64 { 73 65 auto iterator = m_tasksByPageIdentifier.find(page.pageID()); … … 76 68 77 69 auto& tasksByPage = iterator->value; 78 Vector<uint64_t> taskIdentifiersToStop; 79 taskIdentifiersToStop.reserveInitialCapacity(tasksByPage.size()); 80 for (auto taskIdentifier : tasksByPage) { 81 if (!process || processForTaskIdentifier(taskIdentifier) == process) 82 taskIdentifiersToStop.uncheckedAppend(taskIdentifier); 83 } 70 while (!tasksByPage.isEmpty()) 71 stopTask(page, *tasksByPage.begin()); 84 72 85 for (auto& taskIdentifier : taskIdentifiersToStop) 86 stopTask(page, taskIdentifier); 87 73 ASSERT(m_tasksByPageIdentifier.find(page.pageID()) == m_tasksByPageIdentifier.end()); 88 74 } 89 75 -
trunk/Source/WebKit/UIProcess/WebURLSchemeHandler.h
r244802 r244812 56 56 void startTask(WebPageProxy&, WebProcessProxy&, uint64_t taskIdentifier, WebCore::ResourceRequest&&, SyncLoadCompletionHandler&&); 57 57 void stopTask(WebPageProxy&, uint64_t taskIdentifier); 58 void stopAllTasksForPage(WebPageProxy& , WebProcessProxy*);58 void stopAllTasksForPage(WebPageProxy&); 59 59 void taskCompleted(WebURLSchemeTask&); 60 60 … … 68 68 69 69 void removeTaskFromPageMap(uint64_t pageID, uint64_t taskID); 70 WebProcessProxy* processForTaskIdentifier(uint64_t) const;71 70 72 71 uint64_t m_identifier; -
trunk/Source/WebKit/UIProcess/WebURLSchemeTask.h
r244802 r244812 59 59 uint64_t identifier() const { return m_identifier; } 60 60 uint64_t pageID() const { return m_pageIdentifier; } 61 WebProcessProxy* process() const { return m_process.get(); }62 61 63 62 const WebCore::ResourceRequest& request() const { return m_request; } -
trunk/Tools/ChangeLog
r244802 r244812 1 2019-04-30 Chris Dumez <cdumez@apple.com> 2 3 Unreviewed, rolling out r244802. 4 5 Caused an API test failure 6 7 Reverted changeset: 8 9 "Regression(PSON) URL scheme handlers can no longer respond 10 asynchronously" 11 https://bugs.webkit.org/show_bug.cgi?id=197426 12 https://trac.webkit.org/changeset/244802 13 1 14 2019-04-30 Chris Dumez <cdumez@apple.com> 2 15 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm
r244802 r244812 49 49 #import <WebKit/_WKWebsiteDataStoreConfiguration.h> 50 50 #import <WebKit/_WKWebsitePolicies.h> 51 #import <wtf/BlockPtr.h>52 51 #import <wtf/Deque.h> 53 52 #import <wtf/HashMap.h> … … 240 239 HashMap<String, String> _redirects; 241 240 HashMap<String, RetainPtr<NSData>> _dataMappings; 242 HashSet<id <WKURLSchemeTask>> _runningTasks;243 bool _shouldRespondAsynchronously;244 241 } 245 242 - (instancetype)initWithBytes:(const char*)bytes; … … 267 264 } 268 265 269 - (void)setShouldRespondAsynchronously:(BOOL)value270 {271 _shouldRespondAsynchronously = value;272 }273 274 266 - (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)task 275 267 { 268 NSURL *finalURL = task.request.URL; 269 auto target = _redirects.get(task.request.URL.absoluteString); 270 if (!target.isEmpty()) { 271 auto redirectResponse = adoptNS([[NSURLResponse alloc] initWithURL:task.request.URL MIMEType:nil expectedContentLength:0 textEncodingName:nil]); 272 273 finalURL = [NSURL URLWithString:(NSString *)target]; 274 auto request = adoptNS([[NSURLRequest alloc] initWithURL:finalURL]); 275 276 [(id<WKURLSchemeTaskPrivate>)task _didPerformRedirection:redirectResponse.get() newRequest:request.get()]; 277 } 278 276 279 if ([(id<WKURLSchemeTaskPrivate>)task _requestOnlyIfCached]) { 277 280 [task didFailWithError:[NSError errorWithDomain:@"TestWebKitAPI" code:1 userInfo:nil]]; … … 279 282 } 280 283 281 _runningTasks.add(task); 282 283 auto doAsynchronouslyIfNecessary = [self, strongSelf = retainPtr(self), task = retainPtr(task)](Function<void(id <WKURLSchemeTask>)>&& f, double delay) { 284 if (!_shouldRespondAsynchronously) 285 return f(task.get()); 286 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC), dispatch_get_main_queue(), makeBlockPtr([self, strongSelf, task, f = WTFMove(f)] { 287 if (_runningTasks.contains(task.get())) 288 f(task.get()); 289 }).get()); 290 }; 291 292 NSURL *finalURL = task.request.URL; 293 auto target = _redirects.get(task.request.URL.absoluteString); 294 if (!target.isEmpty()) { 295 auto redirectResponse = adoptNS([[NSURLResponse alloc] initWithURL:task.request.URL MIMEType:nil expectedContentLength:0 textEncodingName:nil]); 296 297 finalURL = [NSURL URLWithString:(NSString *)target]; 298 auto request = adoptNS([[NSURLRequest alloc] initWithURL:finalURL]); 299 300 [(id<WKURLSchemeTaskPrivate>)task _didPerformRedirection:redirectResponse.get() newRequest:request.get()]; 301 } 302 303 doAsynchronouslyIfNecessary([finalURL = retainPtr(finalURL)](id <WKURLSchemeTask> task) { 304 RetainPtr<NSURLResponse> response = adoptNS([[NSURLResponse alloc] initWithURL:finalURL.get() MIMEType:@"text/html" expectedContentLength:1 textEncodingName:nil]); 305 [task didReceiveResponse:response.get()]; 306 }, 0.1); 307 308 doAsynchronouslyIfNecessary([self, finalURL = retainPtr(finalURL)](id <WKURLSchemeTask> task) { 309 if (auto data = _dataMappings.get([finalURL absoluteString])) 310 [task didReceiveData:data.get()]; 311 else if (_bytes) { 312 RetainPtr<NSData> data = adoptNS([[NSData alloc] initWithBytesNoCopy:(void *)_bytes length:strlen(_bytes) freeWhenDone:NO]); 313 [task didReceiveData:data.get()]; 314 } else 315 [task didReceiveData:[@"Hello" dataUsingEncoding:NSUTF8StringEncoding]]; 316 }, 0.2); 317 318 doAsynchronouslyIfNecessary([self](id <WKURLSchemeTask> task) { 319 [task didFinish]; 320 _runningTasks.remove(task); 321 }, 0.3); 284 RetainPtr<NSURLResponse> response = adoptNS([[NSURLResponse alloc] initWithURL:finalURL MIMEType:@"text/html" expectedContentLength:1 textEncodingName:nil]); 285 [task didReceiveResponse:response.get()]; 286 287 if (auto data = _dataMappings.get([finalURL absoluteString])) 288 [task didReceiveData:data.get()]; 289 else if (_bytes) { 290 RetainPtr<NSData> data = adoptNS([[NSData alloc] initWithBytesNoCopy:(void *)_bytes length:strlen(_bytes) freeWhenDone:NO]); 291 [task didReceiveData:data.get()]; 292 } else 293 [task didReceiveData:[@"Hello" dataUsingEncoding:NSUTF8StringEncoding]]; 294 295 [task didFinish]; 322 296 } 323 297 324 298 - (void)webView:(WKWebView *)webView stopURLSchemeTask:(id <WKURLSchemeTask>)task 325 299 { 326 _runningTasks.remove(task);327 300 } 328 301 … … 499 472 } 500 473 501 enum class SchemeHandlerShouldBeAsync { No, Yes }; 502 static void runBasicTest(SchemeHandlerShouldBeAsync schemeHandlerShouldBeAsync) 503 { 504 auto processPoolConfiguration = psonProcessPoolConfiguration(); 505 auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]); 506 507 auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]); 508 [webViewConfiguration setProcessPool:processPool.get()]; 509 auto handler = adoptNS([[PSONScheme alloc] init]); 510 [handler setShouldRespondAsynchronously:(schemeHandlerShouldBeAsync == SchemeHandlerShouldBeAsync::Yes)]; 474 TEST(ProcessSwap, Basic) 475 { 476 auto processPoolConfiguration = psonProcessPoolConfiguration(); 477 auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]); 478 479 auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]); 480 [webViewConfiguration setProcessPool:processPool.get()]; 481 auto handler = adoptNS([[PSONScheme alloc] init]); 511 482 [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"]; 512 483 … … 544 515 // 3 loads, 3 decidePolicy calls (e.g. the load that did perform a process swap should not have generated an additional decidePolicy call) 545 516 EXPECT_EQ(numberOfDecidePolicyCalls, 3); 546 }547 548 TEST(ProcessSwap, Basic)549 {550 runBasicTest(SchemeHandlerShouldBeAsync::No);551 }552 553 TEST(ProcessSwap, BasicWithAsyncSchemeHandler)554 {555 runBasicTest(SchemeHandlerShouldBeAsync::Yes);556 517 } 557 518
Note:
See TracChangeset
for help on using the changeset viewer.