Changeset 224687 in webkit


Ignore:
Timestamp:
Nov 10, 2017 9:30:59 AM (6 years ago)
Author:
achristensen@apple.com
Message:

REGRESSION(r224267): WebViews scheduled with custom run loop modes don't load
https://bugs.webkit.org/show_bug.cgi?id=179515
Source/WebCore:

<rdar://problem/35445245>

Reviewed by Andy Estes.

Covered by a new API test which would have timed out without this change.

  • platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:

(schedulePairHashSet):
Collect run loop modes from the NetworkingContext similarly to how we did before https://trac.webkit.org/changeset/224267/webkit#file40
(-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]):
(-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveAuthenticationChallenge:]):
(-[WebCoreResourceHandleAsOperationQueueDelegate connection:canAuthenticateAgainstProtectionSpace:]):
(-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]):
(-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveData:lengthReceived:]):
(-[WebCoreResourceHandleAsOperationQueueDelegate connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:]):
(-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]):
(-[WebCoreResourceHandleAsOperationQueueDelegate connection:didFailWithError:]):
(-[WebCoreResourceHandleAsOperationQueueDelegate connection:willCacheResponse:]):

Source/WTF:

<rdar://problem/35445245>

Reviewed by Andy Estes.

  • wtf/MainThread.cpp:

(WTF::callOnMainThread):

  • wtf/MainThread.h:

(WTF::callOnMainThread):
(WTF::scheduleDispatchFunctionsOnMainThread):

  • wtf/generic/MainThreadGeneric.cpp:

(WTF::scheduleDispatchFunctionsOnMainThread):

  • wtf/mac/MainThreadMac.mm:

(WTF::scheduleDispatchFunctionsOnMainThread):

  • wtf/win/MainThreadWin.cpp:

(WTF::scheduleDispatchFunctionsOnMainThread):
Add an optional parameter which is an array of run loop mode names to pass to performSelectorOnMainThread.

Tools:

Reviewed by Andy Estes.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/mac/WebViewScheduleInRunLoop.mm: Added.

(-[ScheduleInRunLoopDelegate webView:didFinishLoadForFrame:]):
(TestWebKitAPI::TEST):

Location:
trunk
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r224681 r224687  
     12017-11-10  Alex Christensen  <achristensen@webkit.org>
     2
     3        REGRESSION(r224267): WebViews scheduled with custom run loop modes don't load
     4        https://bugs.webkit.org/show_bug.cgi?id=179515
     5        <rdar://problem/35445245>
     6
     7        Reviewed by Andy Estes.
     8
     9        * wtf/MainThread.cpp:
     10        (WTF::callOnMainThread):
     11        * wtf/MainThread.h:
     12        (WTF::callOnMainThread):
     13        (WTF::scheduleDispatchFunctionsOnMainThread):
     14        * wtf/generic/MainThreadGeneric.cpp:
     15        (WTF::scheduleDispatchFunctionsOnMainThread):
     16        * wtf/mac/MainThreadMac.mm:
     17        (WTF::scheduleDispatchFunctionsOnMainThread):
     18        * wtf/win/MainThreadWin.cpp:
     19        (WTF::scheduleDispatchFunctionsOnMainThread):
     20        Add an optional parameter which is an array of run loop mode names to pass to performSelectorOnMainThread.
     21
    1222017-11-10  Ms2ger  <Ms2ger@igalia.com>
    223
  • trunk/Source/WTF/wtf/MainThread.cpp

    r219763 r224687  
    143143}
    144144
    145 void callOnMainThread(Function<void ()>&& function)
     145void callOnMainThread(Function<void()>&& function, SchedulePairHashSet* pairs)
    146146{
    147147    ASSERT(function);
     
    156156
    157157    if (needToSchedule)
    158         scheduleDispatchFunctionsOnMainThread();
     158        scheduleDispatchFunctionsOnMainThread(pairs);
    159159}
    160160
  • trunk/Source/WTF/wtf/MainThread.h

    r220186 r224687  
    3232
    3333#include <stdint.h>
     34#include <wtf/Forward.h>
    3435#include <wtf/Function.h>
    3536#include <wtf/Optional.h>
     
    3940
    4041class PrintStream;
     42class SchedulePair;
     43struct SchedulePairHash;
     44typedef HashSet<RefPtr<SchedulePair>, SchedulePairHash> SchedulePairHashSet;
    4145
    4246// Must be called from the main thread.
    4347WTF_EXPORT_PRIVATE void initializeMainThread();
    4448
    45 WTF_EXPORT_PRIVATE void callOnMainThread(Function<void ()>&&);
     49WTF_EXPORT_PRIVATE void callOnMainThread(Function<void()>&&, SchedulePairHashSet* = nullptr);
    4650
    4751#if PLATFORM(COCOA)
     
    8286// NOTE: these functions are internal to the callOnMainThread implementation.
    8387void initializeMainThreadPlatform();
    84 void scheduleDispatchFunctionsOnMainThread();
     88void scheduleDispatchFunctionsOnMainThread(SchedulePairHashSet* = nullptr);
    8589void dispatchFunctionsFromMainThread();
    8690
  • trunk/Source/WTF/wtf/generic/MainThreadGeneric.cpp

    r216274 r224687  
    6868}
    6969
    70 void scheduleDispatchFunctionsOnMainThread()
     70void scheduleDispatchFunctionsOnMainThread(SchedulePairHashSet*)
    7171{
    7272    // Use a RunLoop::Timer instead of RunLoop::dispatch() to be able to use a different priority and
  • trunk/Source/WTF/wtf/mac/MainThreadMac.mm

    r212878 r224687  
    3636#import <wtf/Assertions.h>
    3737#import <wtf/HashSet.h>
     38#import <wtf/RetainPtr.h>
     39#import <wtf/SchedulePair.h>
    3840#import <wtf/Threading.h>
    3941
     
    121123}
    122124
    123 void scheduleDispatchFunctionsOnMainThread()
     125void scheduleDispatchFunctionsOnMainThread(SchedulePairHashSet* pairs)
    124126{
    125127    ASSERT(staticMainThreadCaller);
     
    130132    }
    131133
     134    RetainPtr<NSArray<NSString *>> modes;
     135    if (pairs) {
     136        modes = adoptNS([[NSMutableArray alloc] initWithCapacity:pairs->size()]);
     137        for (auto& pair : *pairs)
     138            [(NSMutableArray *)modes.get() addObject:(NSString *)pair->mode()];
     139    } else
     140        modes = @[(NSString *)kCFRunLoopCommonModes];
     141   
    132142    if (mainThreadEstablishedAsPthreadMain) {
    133143        ASSERT(!mainThreadNSThread);
    134         [staticMainThreadCaller performSelectorOnMainThread:@selector(call) withObject:nil waitUntilDone:NO];
     144        [staticMainThreadCaller performSelectorOnMainThread:@selector(call) withObject:nil waitUntilDone:NO modes:modes.get()];
    135145        return;
    136146    }
    137147
    138148    ASSERT(mainThreadNSThread);
    139     [staticMainThreadCaller performSelector:@selector(call) onThread:mainThreadNSThread withObject:nil waitUntilDone:NO];
     149    [staticMainThreadCaller performSelector:@selector(call) onThread:mainThreadNSThread withObject:nil waitUntilDone:NO modes:modes.get()];
    140150}
    141151
  • trunk/Source/WTF/wtf/win/MainThreadWin.cpp

    r219994 r224687  
    6868}
    6969
    70 void scheduleDispatchFunctionsOnMainThread()
     70void scheduleDispatchFunctionsOnMainThread(SchedulePairHashSet*)
    7171{
    7272    ASSERT(threadingWindowHandle);
  • trunk/Source/WebCore/ChangeLog

    r224686 r224687  
     12017-11-10  Alex Christensen  <achristensen@webkit.org>
     2
     3        REGRESSION(r224267): WebViews scheduled with custom run loop modes don't load
     4        https://bugs.webkit.org/show_bug.cgi?id=179515
     5        <rdar://problem/35445245>
     6
     7        Reviewed by Andy Estes.
     8
     9        Covered by a new API test which would have timed out without this change.
     10
     11        * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:
     12        (schedulePairHashSet):
     13        Collect run loop modes from the NetworkingContext similarly to how we did before https://trac.webkit.org/changeset/224267/webkit#file40
     14        (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willSendRequest:redirectResponse:]):
     15        (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveAuthenticationChallenge:]):
     16        (-[WebCoreResourceHandleAsOperationQueueDelegate connection:canAuthenticateAgainstProtectionSpace:]):
     17        (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveResponse:]):
     18        (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didReceiveData:lengthReceived:]):
     19        (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:]):
     20        (-[WebCoreResourceHandleAsOperationQueueDelegate connectionDidFinishLoading:]):
     21        (-[WebCoreResourceHandleAsOperationQueueDelegate connection:didFailWithError:]):
     22        (-[WebCoreResourceHandleAsOperationQueueDelegate connection:willCacheResponse:]):
     23
    1242017-11-10  Chris Dumez  <cdumez@apple.com>
    225
  • trunk/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm

    r224522 r224687  
    4444using namespace WebCore;
    4545
     46static SchedulePairHashSet* scheduledRunLoopPairs(ResourceHandle* handle)
     47{
     48    if (!handle)
     49        return nullptr;
     50    if (!handle->context())
     51        return nullptr;
     52    return handle->context()->scheduledRunLoopPairs();
     53}
     54
    4655@implementation WebCoreResourceHandleAsOperationQueueDelegate
    4756
     
    126135        m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    127136    else
    128         callOnMainThread(WTFMove(work));
     137        callOnMainThread(WTFMove(work), scheduledRunLoopPairs(m_handle));
    129138
    130139    dispatch_semaphore_wait(m_semaphore, DISPATCH_TIME_FOREVER);
     
    150159        m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    151160    else
    152         callOnMainThread(WTFMove(work));
     161        callOnMainThread(WTFMove(work), scheduledRunLoopPairs(m_handle));
    153162}
    154163
     
    172181        m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    173182    else
    174         callOnMainThread(WTFMove(work));
     183        callOnMainThread(WTFMove(work), scheduledRunLoopPairs(m_handle));
    175184
    176185    dispatch_semaphore_wait(m_semaphore, DISPATCH_TIME_FOREVER);
     
    211220        m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    212221    else
    213         callOnMainThread(WTFMove(work));
     222        callOnMainThread(WTFMove(work), scheduledRunLoopPairs(m_handle));
    214223
    215224    dispatch_semaphore_wait(m_semaphore, DISPATCH_TIME_FOREVER);
     
    240249        m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    241250    else
    242         callOnMainThread(WTFMove(work));
     251        callOnMainThread(WTFMove(work), scheduledRunLoopPairs(m_handle));
    243252}
    244253
     
    260269        m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    261270    else
    262         callOnMainThread(WTFMove(work));
     271        callOnMainThread(WTFMove(work), scheduledRunLoopPairs(m_handle));
    263272}
    264273
     
    284293        m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    285294    else
    286         callOnMainThread(WTFMove(work));
     295        callOnMainThread(WTFMove(work), scheduledRunLoopPairs(m_handle));
    287296}
    288297
     
    308317        m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    309318    else
    310         callOnMainThread(WTFMove(work));
     319        callOnMainThread(WTFMove(work), scheduledRunLoopPairs(m_handle));
    311320}
    312321
     
    332341        m_messageQueue->append(std::make_unique<Function<void()>>(WTFMove(work)));
    333342    else
    334         callOnMainThread(WTFMove(work));
     343        callOnMainThread(WTFMove(work), scheduledRunLoopPairs(m_handle));
    335344
    336345    dispatch_semaphore_wait(m_semaphore, DISPATCH_TIME_FOREVER);
  • trunk/Tools/ChangeLog

    r224685 r224687  
     12017-11-10  Alex Christensen  <achristensen@webkit.org>
     2
     3        REGRESSION(r224267): WebViews scheduled with custom run loop modes don't load
     4        https://bugs.webkit.org/show_bug.cgi?id=179515
     5
     6        Reviewed by Andy Estes.
     7
     8        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     9        * TestWebKitAPI/Tests/mac/WebViewScheduleInRunLoop.mm: Added.
     10        (-[ScheduleInRunLoopDelegate webView:didFinishLoadForFrame:]):
     11        (TestWebKitAPI::TEST):
     12
    1132017-11-10  Fujii Hironori  <Hironori.Fujii@sony.com>
    214
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r224281 r224687  
    236236                5C726D6F1D3EE06E00C5E1A1 /* InstanceMethodSwizzler.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C726D6E1D3EE06800C5E1A1 /* InstanceMethodSwizzler.mm */; };
    237237                5C7964101EB0278D0075D74C /* EventModifiers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C79640F1EB0269B0075D74C /* EventModifiers.cpp */; };
     238                5C7C74CB1FB529BA002F9ABE /* WebViewScheduleInRunLoop.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C7C74CA1FB528D4002F9ABE /* WebViewScheduleInRunLoop.mm */; };
    238239                5C838F7F1DB04F900082858F /* LoadInvalidURLRequest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57901FAE1CAF137100ED64F9 /* LoadInvalidURLRequest.mm */; };
    239240                5C973F5C1F58EF8B00359C27 /* WebGLPolicy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C973F5B1F58EF0A00359C27 /* WebGLPolicy.mm */; };
     
    13701371                5C726D6E1D3EE06800C5E1A1 /* InstanceMethodSwizzler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = InstanceMethodSwizzler.mm; path = cocoa/InstanceMethodSwizzler.mm; sourceTree = "<group>"; };
    13711372                5C79640F1EB0269B0075D74C /* EventModifiers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventModifiers.cpp; sourceTree = "<group>"; };
     1373                5C7C74CA1FB528D4002F9ABE /* WebViewScheduleInRunLoop.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewScheduleInRunLoop.mm; sourceTree = "<group>"; };
    13721374                5C973F5B1F58EF0A00359C27 /* WebGLPolicy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebGLPolicy.mm; sourceTree = "<group>"; };
    13731375                5C9E56841DF9143D00C9EE33 /* WebsitePolicies.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebsitePolicies.mm; sourceTree = "<group>"; };
     
    28182820                                37E38C33169B7D010084C28C /* WebViewDidRemoveFrameFromHierarchy.mm */,
    28192821                                51DB16CD1F085047001FA4C5 /* WebViewIconLoading.mm */,
     2822                                5C7C74CA1FB528D4002F9ABE /* WebViewScheduleInRunLoop.mm */,
    28202823                                CE32C7C718184C4900CD8C28 /* WillPerformClientRedirectToURLCrash.mm */,
    28212824                                1A7BFC0A171A0BDB00BC5F64 /* WillSendSubmitEvent.mm */,
     
    35243527                                7CCE7ED61A411A7E00447C4C /* WebViewDidRemoveFrameFromHierarchy.mm in Sources */,
    35253528                                51DB16CE1F085137001FA4C5 /* WebViewIconLoading.mm in Sources */,
     3529                                5C7C74CB1FB529BA002F9ABE /* WebViewScheduleInRunLoop.mm in Sources */,
    35263530                                7CCE7F1B1A411AE600447C4C /* WillLoad.cpp in Sources */,
    35273531                                7CCE7ED71A411A7E00447C4C /* WillPerformClientRedirectToURLCrash.mm in Sources */,
Note: See TracChangeset for help on using the changeset viewer.