Changeset 251261 in webkit
- Timestamp:
- Oct 17, 2019 3:05:24 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r251258 r251261 1 2019-10-17 Sihui Liu <sihui_liu@apple.com> 2 3 Using version 1 CFRunloopSource for faster task dispatch 4 https://bugs.webkit.org/show_bug.cgi?id=202874 5 6 Reviewed by Geoffrey Garen. 7 8 Fix a flaky test. 9 10 * inspector/css/pseudo-creation-expected.txt: 11 * inspector/css/pseudo-creation.html: 12 1 13 2019-10-17 Ryosuke Niwa <rniwa@webkit.org> 2 14 -
trunk/LayoutTests/inspector/css/pseudo-creation-expected.txt
r241189 r251261 13 13 Calling "createElementWithClass("test-pseudo-with-content")"... 14 14 Checking for nodes with class ".test-pseudo-with-content"... 15 PASS: There should be 1 node with the class ".test-pseudo-with-content". 15 16 PASS: Created ::before pseudo element 16 PASS: There should be 1 node with the class ".test-pseudo-with-content".17 17 18 18 Calling "removeElementWithClass("test-pseudo-with-content")"... 19 19 Checking for nodes with class ".test-pseudo-with-content"... 20 PASS: There should be 0 node with the class ".test-pseudo-with-content". 20 21 PASS: Removed ::before pseudo element 21 PASS: There should be 0 node with the class ".test-pseudo-with-content".22 22 -
trunk/LayoutTests/inspector/css/pseudo-creation.html
r249504 r251261 27 27 function test() { 28 28 let documentNode = null; 29 let pseudoElement = null; 29 let pseudoElementAdded = null; 30 let pseudoElementRemoved = null; 30 31 31 32 function handlePromiseReject(error) { … … 57 58 } 58 59 59 function createElementWithClass(className ) {60 function createElementWithClass(className, shouldCheckElement) { 60 61 return evaluateWithLog(`createElementWithClass("${className}")`) 61 62 .then(() => checkElementsWithClass(className, 1)) 63 .then(() => { 64 if (shouldCheckElement) { 65 if (pseudoElementAdded) 66 ProtocolTest.pass(`Created ::${pseudoElementAdded.pseudoType} pseudo element`); 67 else 68 return pseudoElementAddedPromise.then(() => { ProtocolTest.pass(`Created ::${pseudoElementAdded.pseudoType} pseudo element`); }); 69 } 70 }) 62 71 .catch(handlePromiseReject); 63 72 } 64 73 65 function removeElementWithClass(className ) {74 function removeElementWithClass(className, shouldCheckElement) { 66 75 return evaluateWithLog(`removeElementWithClass("${className}")`) 67 76 .then(() => checkElementsWithClass(className, 0)) 77 .then(() => { 78 if (shouldCheckElement) { 79 if (pseudoElementRemoved) 80 ProtocolTest.expectEqual(pseudoElementRemoved.pseudoElementId, pseudoElementAdded.nodeId, `Removed ::${pseudoElementAdded.pseudoType} pseudo element`); 81 else 82 return pseudoElementRemovedPromise.then(() => { ProtocolTest.expectEqual(pseudoElementRemoved.pseudoElementId, pseudoElementAdded.nodeId, `Removed ::${pseudoElementAdded.pseudoType} pseudo element`); }); 83 } 84 }) 68 85 .catch(handlePromiseReject); 69 86 } 70 87 71 InspectorProtocol.eventHandler["DOM.pseudoElementAdded"] = (response) => {72 pseudoElement = response.params.pseudoElement;88 let pseudoElementAddedPromise = InspectorProtocol.awaitEvent({event: "DOM.pseudoElementAdded"}).then((event) => { pseudoElementAdded = event.params.pseudoElement}); 89 let pseudoElementRemovedPromise = InspectorProtocol.awaitEvent({event: "DOM.pseudoElementRemoved"}).then((event) => { pseudoElementRemoved = event.params}); 73 90 74 ProtocolTest.pass(`Created ::${pseudoElement.pseudoType} pseudo element`);75 };76 77 InspectorProtocol.eventHandler["DOM.pseudoElementRemoved"] = (response) => {78 ProtocolTest.expectEqual(response.params.pseudoElementId, pseudoElement.nodeId, `Removed ::${pseudoElement.pseudoType} pseudo element`);79 };80 91 81 92 ProtocolTest.log("Requesting document..."); … … 86 97 87 98 Promise.resolve() 88 .then(() => createElementWithClass("test-pseudo-without-content") )89 .then(() => removeElementWithClass("test-pseudo-without-content") )90 .then(() => createElementWithClass("test-pseudo-with-content" ))91 .then(() => removeElementWithClass("test-pseudo-with-content" ))99 .then(() => createElementWithClass("test-pseudo-without-content"), false) 100 .then(() => removeElementWithClass("test-pseudo-without-content"), false) 101 .then(() => createElementWithClass("test-pseudo-with-content", true)) 102 .then(() => removeElementWithClass("test-pseudo-with-content", true)) 92 103 .then(() => ProtocolTest.completeTest()) 93 104 .catch(handlePromiseReject); -
trunk/Source/WTF/ChangeLog
r251190 r251261 1 2019-10-17 Sihui Liu <sihui_liu@apple.com> 2 3 Using version 1 CFRunloopSource for faster task dispatch 4 https://bugs.webkit.org/show_bug.cgi?id=202874 5 6 Reviewed by Geoffrey Garen. 7 8 We used CFRunLoopWakeUp to wake up runloop to process source, which seems to be slow according to profiling. To 9 avoid calling CFRunLoopWakeUp, we should use version 1 CFRunloopSource instead of version 0. This patch brings 10 about 15% speedup for test PerformanceTests/IndexedDB/basic/objectstore-get.html. 11 12 * wtf/RunLoop.cpp: 13 (WTF::RunLoop::initializeWebRunLoop): 14 (WTF::RunLoop::web): 15 * wtf/RunLoop.h: 16 * wtf/cf/RunLoopCF.cpp: 17 (WTF::RunLoop::performWork): 18 (WTF::RunLoop::RunLoop): 19 (WTF::RunLoop::~RunLoop): 20 (WTF::RunLoop::wakeUp): 21 * wtf/cocoa/MainThreadCocoa.mm: 22 (WTF::initializeMainThreadPlatform): 23 (WTF::scheduleDispatchFunctionsOnMainThread): 24 (WTF::initializeWebThread): 25 (-[JSWTFMainThreadCaller call]): Deleted. 26 1 27 2019-10-16 Wenson Hsieh <wenson_hsieh@apple.com> 2 28 -
trunk/Source/WTF/wtf/RunLoop.cpp
r248546 r251261 34 34 35 35 static RunLoop* s_mainRunLoop; 36 #if USE(WEB_THREAD) 37 static RunLoop* s_webRunLoop; 38 #endif 36 39 37 40 // Helper class for ThreadSpecificData. … … 69 72 return *s_mainRunLoop; 70 73 } 74 75 #if USE(WEB_THREAD) 76 void RunLoop::initializeWebRunLoop() 77 { 78 s_webRunLoop = &RunLoop::current(); 79 } 80 81 RunLoop& RunLoop::web() 82 { 83 ASSERT(s_webRunLoop); 84 return *s_webRunLoop; 85 } 86 #endif 71 87 72 88 bool RunLoop::isMain() -
trunk/Source/WTF/wtf/RunLoop.h
r251036 r251261 50 50 // can be called from any thread). 51 51 WTF_EXPORT_PRIVATE static void initializeMainRunLoop(); 52 #if USE(WEB_THREAD) 53 WTF_EXPORT_PRIVATE static void initializeWebRunLoop(); 54 #endif 52 55 53 56 WTF_EXPORT_PRIVATE static RunLoop& current(); 54 57 WTF_EXPORT_PRIVATE static RunLoop& main(); 58 #if USE(WEB_THREAD) 59 WTF_EXPORT_PRIVATE static RunLoop& web(); 60 #endif 55 61 WTF_EXPORT_PRIVATE static bool isMain(); 56 62 ~RunLoop(); … … 179 185 Lock m_loopLock; 180 186 #elif USE(COCOA_EVENT_LOOP) 181 static void performWork( void*);187 static void performWork(CFMachPortRef, void* msg, CFIndex size, void* info); 182 188 RetainPtr<CFRunLoopRef> m_runLoop; 183 189 RetainPtr<CFRunLoopSourceRef> m_runLoopSource; 190 RetainPtr<CFMachPortRef> m_port; 184 191 #elif USE(GLIB_EVENT_LOOP) 185 192 GRefPtr<GMainContext> m_mainContext; -
trunk/Source/WTF/wtf/cf/RunLoopCF.cpp
r251036 r251261 29 29 #include <CoreFoundation/CoreFoundation.h> 30 30 #include <dispatch/dispatch.h> 31 #include <mach/mach.h> 31 32 #include <wtf/AutodrainedPool.h> 32 33 33 34 namespace WTF { 34 35 35 void RunLoop::performWork( void* context)36 void RunLoop::performWork(CFMachPortRef, void*, CFIndex, void* info) 36 37 { 37 38 AutodrainedPool pool; 38 static_cast<RunLoop*>( context)->performWork();39 static_cast<RunLoop*>(info)->performWork(); 39 40 } 40 41 … … 42 43 : m_runLoop(CFRunLoopGetCurrent()) 43 44 { 44 CFRunLoopSourceContext context = { 0, this, 0, 0, 0, 0, 0, 0, 0, performWork }; 45 m_runLoopSource = adoptCF(CFRunLoopSourceCreate(kCFAllocatorDefault, 0, &context)); 45 CFMachPortContext context = { 0, this, nullptr, nullptr, nullptr }; 46 m_port = adoptCF(CFMachPortCreate(kCFAllocatorDefault, performWork, &context, nullptr)); 47 m_runLoopSource = adoptCF(CFMachPortCreateRunLoopSource(kCFAllocatorDefault, m_port.get(), 0)); 46 48 CFRunLoopAddSource(m_runLoop.get(), m_runLoopSource.get(), kCFRunLoopCommonModes); 47 49 } … … 49 51 RunLoop::~RunLoop() 50 52 { 53 CFMachPortInvalidate(m_port.get()); 51 54 CFRunLoopSourceInvalidate(m_runLoopSource.get()); 52 55 } … … 59 62 void RunLoop::wakeUp() 60 63 { 61 CFRunLoopSourceSignal(m_runLoopSource.get()); 62 CFRunLoopWakeUp(m_runLoop.get()); 64 mach_msg_header_t header; 65 header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, 0); 66 header.msgh_size = sizeof(mach_msg_header_t); 67 header.msgh_remote_port = CFMachPortGetPort(m_port.get()); 68 header.msgh_local_port = MACH_PORT_NULL; 69 header.msgh_id = 0; 70 mach_msg_return_t result = mach_msg(&header, MACH_SEND_MSG | MACH_SEND_TIMEOUT, header.msgh_size, 0, MACH_PORT_NULL, 0, MACH_PORT_NULL); 71 RELEASE_ASSERT(result == MACH_MSG_SUCCESS || result == MACH_SEND_TIMED_OUT); 72 if (result == MACH_SEND_TIMED_OUT) 73 mach_msg_destroy(&header); 63 74 } 64 75 -
trunk/Source/WTF/wtf/cocoa/MainThreadCocoa.mm
r251164 r251261 37 37 #import <wtf/HashSet.h> 38 38 #import <wtf/RetainPtr.h> 39 #import <wtf/RunLoop.h> 39 40 #import <wtf/SchedulePair.h> 40 41 #import <wtf/Threading.h> … … 43 44 #include <wtf/ios/WebCoreThread.h> 44 45 #endif 45 46 @interface JSWTFMainThreadCaller : NSObject47 - (void)call;48 @end49 50 @implementation JSWTFMainThreadCaller51 52 - (void)call53 {54 WTF::dispatchFunctionsFromMainThread();55 }56 57 @end58 46 59 47 #define LOG_CHANNEL_PREFIX Log … … 67 55 #endif 68 56 69 70 static JSWTFMainThreadCaller* staticMainThreadCaller;71 57 static bool isTimerPosted; // This is only accessed on the main thread. 72 58 … … 85 71 RELEASE_LOG_FAULT(Threading, "WebKit Threading Violation - initial use of WebKit from a secondary thread."); 86 72 ASSERT(pthread_main_np()); 87 88 ASSERT(!staticMainThreadCaller);89 staticMainThreadCaller = [[JSWTFMainThreadCaller alloc] init];90 73 } 91 74 … … 113 96 void scheduleDispatchFunctionsOnMainThread() 114 97 { 115 ASSERT(staticMainThreadCaller);116 117 98 #if USE(WEB_THREAD) 118 99 if (isWebThread()) { … … 122 103 123 104 if (mainThreadPthread) { 124 [staticMainThreadCaller performSelector:@selector(call) onThread:mainThreadNSThread withObject:nil waitUntilDone:NO]; 105 RunLoop::web().dispatch([] { 106 WTF::dispatchFunctionsFromMainThread(); 107 }); 125 108 return; 126 109 } … … 132 115 #endif 133 116 134 [staticMainThreadCaller performSelectorOnMainThread:@selector(call) withObject:nil waitUntilDone:NO]; 117 RunLoop::main().dispatch([] { 118 WTF::dispatchFunctionsFromMainThread(); 119 }); 135 120 } 136 121 … … 197 182 mainThreadNSThread = [NSThread currentThread]; 198 183 sWebThread = &Thread::current(); 184 RunLoop::initializeWebRunLoop(); 199 185 }); 200 186 } -
trunk/Tools/ChangeLog
r251259 r251261 1 2019-10-17 Sihui Liu <sihui_liu@apple.com> 2 3 Using version 1 CFRunloopSource for faster task dispatch 4 https://bugs.webkit.org/show_bug.cgi?id=202874 5 6 Reviewed by Geoffrey Garen. 7 8 Fix a flaky test. 9 10 * TestWebKitAPI/Tests/WebKit/getUserMedia.html: 11 1 12 2019-10-17 Jonathan Bedard <jbedard@apple.com> 2 13 -
trunk/Tools/TestWebKitAPI/Tests/WebKit/getUserMedia.html
r250774 r251261 3 3 <head> 4 4 <script> 5 6 let stream = null; 5 let streamPromise = Promise.resolve(); 7 6 8 7 function promptForCapture() 9 8 { 10 navigator.mediaDevices.enumerateDevices().then(() => {9 streamPromise = navigator.mediaDevices.enumerateDevices().then(() => { 11 10 return navigator.mediaDevices.getUserMedia({ audio: false, video: true }) 12 }).then((s) => { 11 }); 12 13 streamPromise.then((stream) => { 13 14 stream = s; 14 15 video.srcObject = stream; … … 19 20 function stop(kind) 20 21 { 21 let activeTracks = []; 22 stream.getTracks().forEach(track => { 23 if (!kind || track.kind == kind) 24 track.stop(); 25 else 26 activeTracks.push(track); 22 streamPromise.then((stream) => { 23 let activeTracks = []; 24 stream.getTracks().forEach(track => { 25 if (!kind || track.kind == kind) 26 track.stop(); 27 else 28 activeTracks.push(track); 29 }); 30 31 if (!activeTracks.length) { 32 streamPromiseDidResolve = false; 33 video.srcObject = null; 34 } 27 35 }); 36 } 28 37 29 if (!activeTracks.length) { 30 stream = null; 31 video.srcObject = null; 32 } 33 } 38 let streamPromiseDidResolve = false; 34 39 35 40 function haveStream() 36 41 { 37 return stream !== null; 42 // Our caller polls repeatedly until our promise resolves. 43 streamPromise.then((stream) => streamPromiseDidResolve = !!stream); 44 return streamPromiseDidResolve; 38 45 } 39 46 … … 54 61 function captureAudio() 55 62 { 56 navigator.mediaDevices.getUserMedia({audio: true}).then(s => stream = s);63 streamPromise = navigator.mediaDevices.getUserMedia({audio: true}); 57 64 } 58 65 59 66 function captureAudioAndVideo() 60 67 { 61 navigator.mediaDevices.getUserMedia({audio: true, video: true}).then(s => stream = s);68 streamPromise = navigator.mediaDevices.getUserMedia({audio: true, video: true}); 62 69 } 63 70 </script>
Note: See TracChangeset
for help on using the changeset viewer.