⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 244812 in webkit


Ignore:
Timestamp:
Apr 30, 2019, 4:56:05 PM (7 years ago)
Author:
Chris Dumez
Message:

Unreviewed, rolling out r244802.

Caused an API test failure

Reverted changeset:

"Regression(PSON) URL scheme handlers can no longer respond
asynchronously"
https://bugs.webkit.org/show_bug.cgi?id=197426
https://trac.webkit.org/changeset/244802

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r244802 r244812  
     12019-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
    1142019-04-30  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r244802 r244812  
    67426742    }
    67436743
    6744     stopAllURLSchemeTasks(m_process.ptr());
     6744    stopAllURLSchemeTasks();
    67456745}
    67466746
     
    68026802}
    68036803
    6804 void WebPageProxy::stopAllURLSchemeTasks(WebProcessProxy* process)
     6804void WebPageProxy::stopAllURLSchemeTasks()
    68056805{
    68066806    HashSet<WebURLSchemeHandler*> handlers;
     
    68096809
    68106810    for (auto* handler : handlers)
    6811         handler->stopAllTasksForPage(*this, process);
     6811        handler->stopAllTasksForPage(*this);
    68126812}
    68136813
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r244802 r244812  
    20022002    void viewIsBecomingVisible();
    20032003
    2004     void stopAllURLSchemeTasks(WebProcessProxy* = nullptr);
     2004    void stopAllURLSchemeTasks();
    20052005
    20062006    void clearInspectorTargets();
  • trunk/Source/WebKit/UIProcess/WebURLSchemeHandler.cpp

    r244802 r244812  
    6161}
    6262
    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)
     63void WebURLSchemeHandler::stopAllTasksForPage(WebPageProxy& page)
    7264{
    7365    auto iterator = m_tasksByPageIdentifier.find(page.pageID());
     
    7668
    7769    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());
    8472
    85     for (auto& taskIdentifier : taskIdentifiersToStop)
    86         stopTask(page, taskIdentifier);
    87 
     73    ASSERT(m_tasksByPageIdentifier.find(page.pageID()) == m_tasksByPageIdentifier.end());
    8874}
    8975
  • trunk/Source/WebKit/UIProcess/WebURLSchemeHandler.h

    r244802 r244812  
    5656    void startTask(WebPageProxy&, WebProcessProxy&, uint64_t taskIdentifier, WebCore::ResourceRequest&&, SyncLoadCompletionHandler&&);
    5757    void stopTask(WebPageProxy&, uint64_t taskIdentifier);
    58     void stopAllTasksForPage(WebPageProxy&, WebProcessProxy*);
     58    void stopAllTasksForPage(WebPageProxy&);
    5959    void taskCompleted(WebURLSchemeTask&);
    6060
     
    6868
    6969    void removeTaskFromPageMap(uint64_t pageID, uint64_t taskID);
    70     WebProcessProxy* processForTaskIdentifier(uint64_t) const;
    7170
    7271    uint64_t m_identifier;
  • trunk/Source/WebKit/UIProcess/WebURLSchemeTask.h

    r244802 r244812  
    5959    uint64_t identifier() const { return m_identifier; }
    6060    uint64_t pageID() const { return m_pageIdentifier; }
    61     WebProcessProxy* process() const { return m_process.get(); }
    6261
    6362    const WebCore::ResourceRequest& request() const { return m_request; }
  • trunk/Tools/ChangeLog

    r244802 r244812  
     12019-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
    1142019-04-30  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm

    r244802 r244812  
    4949#import <WebKit/_WKWebsiteDataStoreConfiguration.h>
    5050#import <WebKit/_WKWebsitePolicies.h>
    51 #import <wtf/BlockPtr.h>
    5251#import <wtf/Deque.h>
    5352#import <wtf/HashMap.h>
     
    240239    HashMap<String, String> _redirects;
    241240    HashMap<String, RetainPtr<NSData>> _dataMappings;
    242     HashSet<id <WKURLSchemeTask>> _runningTasks;
    243     bool _shouldRespondAsynchronously;
    244241}
    245242- (instancetype)initWithBytes:(const char*)bytes;
     
    267264}
    268265
    269 - (void)setShouldRespondAsynchronously:(BOOL)value
    270 {
    271     _shouldRespondAsynchronously = value;
    272 }
    273 
    274266- (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)task
    275267{
     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
    276279    if ([(id<WKURLSchemeTaskPrivate>)task _requestOnlyIfCached]) {
    277280        [task didFailWithError:[NSError errorWithDomain:@"TestWebKitAPI" code:1 userInfo:nil]];
     
    279282    }
    280283
    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];
    322296}
    323297
    324298- (void)webView:(WKWebView *)webView stopURLSchemeTask:(id <WKURLSchemeTask>)task
    325299{
    326     _runningTasks.remove(task);
    327300}
    328301
     
    499472}
    500473
    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)];
     474TEST(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]);
    511482    [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"];
    512483
     
    544515    // 3 loads, 3 decidePolicy calls (e.g. the load that did perform a process swap should not have generated an additional decidePolicy call)
    545516    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);
    556517}
    557518
Note: See TracChangeset for help on using the changeset viewer.