Changeset 244723 in webkit
- Timestamp:
- Apr 27, 2019 3:45:38 PM (5 years ago)
- Location:
- trunk/Tools
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r244711 r244723 1 2019-04-27 Chris Dumez <cdumez@apple.com> 2 3 [WKTR] Move test timeout handling to the UIProcess 4 https://bugs.webkit.org/show_bug.cgi?id=197333 5 6 Reviewed by Darin Adler. 7 8 Move test timeout handling in WebKitTestRunner to the UIProcess to play nicely with PSON. Previously, 9 we'd start the timeout timer in the InjectedBundle, which would fail to account of the time spent in 10 every WebContent process in the case of swapping. 11 12 Also, because of process caching, the timeout timer would sometime fire in a cached process and it 13 would lead to crashes when firing the timer. 14 15 * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp: 16 (WTR::InjectedBundle::didReceiveMessageToPage): 17 (WTR::InjectedBundle::done): 18 * WebKitTestRunner/InjectedBundle/InjectedBundle.h: 19 (WTR::InjectedBundle::shouldDumpPixels const): 20 * WebKitTestRunner/InjectedBundle/TestRunner.cpp: 21 (WTR::TestRunner::TestRunner): 22 (WTR::TestRunner::waitUntilDone): 23 (WTR::TestRunner::setWaitUntilDone): 24 * WebKitTestRunner/InjectedBundle/TestRunner.h: 25 * WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp: 26 * WebKitTestRunner/InjectedBundle/mac/TestRunnerMac.mm: 27 * WebKitTestRunner/InjectedBundle/win/TestRunnerWin.cpp: 28 * WebKitTestRunner/InjectedBundle/wpe/TestRunnerWPE.cpp: 29 * WebKitTestRunner/TestInvocation.cpp: 30 (WTR::TestInvocation::TestInvocation): 31 (WTR::TestInvocation::createTestSettingsDictionary): 32 (WTR::TestInvocation::didReceiveMessageFromInjectedBundle): 33 (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): 34 (WTR::TestInvocation::initializeWaitToDumpWatchdogTimerIfNeeded): 35 (WTR::TestInvocation::invalidateWaitToDumpWatchdogTimer): 36 (WTR::TestInvocation::waitToDumpWatchdogTimerFired): 37 (WTR::TestInvocation::setWaitUntilDone): 38 (WTR::TestInvocation::done): 39 * WebKitTestRunner/TestInvocation.h: 40 1 41 2019-04-25 Yusuke Suzuki <ysuzuki@apple.com> 2 42 -
trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
r244390 r244723 209 209 m_dumpPixels = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, dumpPixelsKey.get()))); 210 210 211 WKRetainPtr<WKStringRef> useWaitToDumpWatchdogTimerKey = adoptWK(WKStringCreateWithUTF8CString("UseWaitToDumpWatchdogTimer"));212 m_useWaitToDumpWatchdogTimer = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, useWaitToDumpWatchdogTimerKey.get())));213 214 211 WKRetainPtr<WKStringRef> timeoutKey = adoptWK(WKStringCreateWithUTF8CString("Timeout")); 215 212 m_timeout = Seconds::fromMilliseconds(WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, timeoutKey.get())))); … … 544 541 setTopLoadingFrame(0); 545 542 546 m_testRunner->invalidateWaitToDumpWatchdogTimer();547 548 543 #if HAVE(ACCESSIBILITY) 549 544 m_accessibilityController->resetToConsistentState(); -
trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
r235408 r244723 81 81 82 82 bool shouldDumpPixels() const { return m_dumpPixels; } 83 bool useWaitToDumpWatchdogTimer() const { return m_useWaitToDumpWatchdogTimer; }84 83 bool dumpJSConsoleLogInStdErr() const { return m_dumpJSConsoleLogInStdErr; }; 85 84 … … 195 194 196 195 bool m_dumpPixels { false }; 197 bool m_useWaitToDumpWatchdogTimer { true };198 196 bool m_useWorkQueue { false }; 199 197 bool m_pixelResultIsPending { false }; -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
r244614 r244723 67 67 TestRunner::TestRunner() 68 68 : m_userStyleSheetLocation(adoptWK(WKStringCreateWithUTF8CString(""))) 69 #if !PLATFORM(COCOA)70 , m_waitToDumpWatchdogTimer(RunLoop::main(), this, &TestRunner::waitToDumpWatchdogTimerFired)71 #endif72 69 { 73 70 platformInitialize(); … … 162 159 163 160 setWaitUntilDone(true); 164 // FIXME: Watchdog timer should be moved to UI process in order to take the elapsed time in anotehr process into account.165 if (injectedBundle.useWaitToDumpWatchdogTimer())166 initializeWaitToDumpWatchdogTimerIfNeeded();167 161 } 168 162 169 163 void TestRunner::setWaitUntilDone(bool value) 170 164 { 171 WKRetainPtr<WKStringRef> mess sageName = adoptWK(WKStringCreateWithUTF8CString("SetWaitUntilDone"));165 WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("SetWaitUntilDone")); 172 166 WKRetainPtr<WKBooleanRef> messageBody = adoptWK(WKBooleanCreate(value)); 173 WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), mess sageName.get(), messageBody.get(), nullptr);167 WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr); 174 168 } 175 169 … … 181 175 ASSERT(WKGetTypeID(returnData) == WKBooleanGetTypeID()); 182 176 return WKBooleanGetValue(adoptWK(static_cast<WKBooleanRef>(returnData)).get()); 183 }184 185 void TestRunner::waitToDumpWatchdogTimerFired()186 {187 invalidateWaitToDumpWatchdogTimer();188 auto& injectedBundle = InjectedBundle::singleton();189 #if PLATFORM(COCOA)190 char buffer[1024];191 snprintf(buffer, sizeof(buffer), "#PID UNRESPONSIVE - %s (pid %d)\n", getprogname(), getpid());192 injectedBundle.outputText(buffer);193 #endif194 injectedBundle.outputText("FAIL: Timed out waiting for notifyDone to be called\n\n");195 injectedBundle.done();196 177 } 197 178 -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
r244614 r244723 36 36 #include <wtf/Seconds.h> 37 37 #include <wtf/text/WTFString.h> 38 39 #if PLATFORM(COCOA)40 #include <wtf/RetainPtr.h>41 #include <CoreFoundation/CFRunLoop.h>42 typedef RetainPtr<CFRunLoopTimerRef> PlatformTimerRef;43 #else44 #include <wtf/RunLoop.h>45 namespace WTR {46 class TestRunner;47 typedef RunLoop::Timer<TestRunner> PlatformTimerRef;48 }49 #endif50 38 51 39 namespace WTR { … … 234 222 235 223 bool shouldWaitUntilDone() const; 236 void waitToDumpWatchdogTimerFired();237 void invalidateWaitToDumpWatchdogTimer();238 224 239 225 // Downloads … … 513 499 514 500 void platformInitialize(); 515 void initializeWaitToDumpWatchdogTimerIfNeeded();516 501 517 502 void setDumpPixels(bool); … … 527 512 WKRetainPtr<WKStringRef> m_userStyleSheetLocation; 528 513 WKRetainPtr<WKArrayRef> m_allowedHosts; 529 530 PlatformTimerRef m_waitToDumpWatchdogTimer;531 514 532 515 double m_databaseDefaultQuota { -1 }; -
trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp
r235399 r244723 40 40 } 41 41 42 void TestRunner::invalidateWaitToDumpWatchdogTimer()43 {44 m_waitToDumpWatchdogTimer.stop();45 }46 47 void TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded()48 {49 if (m_waitToDumpWatchdogTimer.isActive())50 return;51 52 m_waitToDumpWatchdogTimer.startOneShot(m_timeout);53 }54 55 42 JSRetainPtr<JSStringRef> TestRunner::pathToLocalResource(JSStringRef url) 56 43 { -
trunk/Tools/WebKitTestRunner/InjectedBundle/mac/TestRunnerMac.mm
r241597 r244723 37 37 } 38 38 39 void TestRunner::invalidateWaitToDumpWatchdogTimer()40 {41 if (!m_waitToDumpWatchdogTimer)42 return;43 44 CFRunLoopTimerInvalidate(m_waitToDumpWatchdogTimer.get());45 m_waitToDumpWatchdogTimer = nullptr;46 }47 48 static void waitUntilDoneWatchdogTimerFired(CFRunLoopTimerRef timer, void* info)49 {50 InjectedBundle::singleton().testRunner()->waitToDumpWatchdogTimerFired();51 }52 53 void TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded()54 {55 if (m_waitToDumpWatchdogTimer)56 return;57 58 CFTimeInterval interval = m_timeout.seconds();59 m_waitToDumpWatchdogTimer = adoptCF(CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, 0, 0, 0, WTR::waitUntilDoneWatchdogTimerFired, NULL));60 CFRunLoopAddTimer(CFRunLoopGetCurrent(), m_waitToDumpWatchdogTimer.get(), kCFRunLoopCommonModes);61 }62 63 39 JSRetainPtr<JSStringRef> TestRunner::pathToLocalResource(JSStringRef url) 64 40 { -
trunk/Tools/WebKitTestRunner/InjectedBundle/win/TestRunnerWin.cpp
r238098 r244723 41 41 } 42 42 43 void TestRunner::invalidateWaitToDumpWatchdogTimer()44 {45 m_waitToDumpWatchdogTimer.stop();46 }47 48 43 void TestRunner::platformInitialize() 49 44 { 50 }51 52 void TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded()53 {54 if (!m_waitToDumpWatchdogTimer.isActive())55 m_waitToDumpWatchdogTimer.startOneShot(m_timeout);56 45 } 57 46 -
trunk/Tools/WebKitTestRunner/InjectedBundle/wpe/TestRunnerWPE.cpp
r235399 r244723 41 41 } 42 42 43 void TestRunner::invalidateWaitToDumpWatchdogTimer()44 {45 m_waitToDumpWatchdogTimer.stop();46 }47 48 43 void TestRunner::platformInitialize() 49 44 { 50 }51 52 void TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded()53 {54 if (!m_waitToDumpWatchdogTimer.isActive())55 m_waitToDumpWatchdogTimer.startOneShot(m_timeout);56 45 } 57 46 -
trunk/Tools/WebKitTestRunner/TestInvocation.cpp
r244614 r244723 70 70 : m_options(options) 71 71 , m_url(url) 72 , m_waitToDumpWatchdogTimer(RunLoop::main(), this, &TestInvocation::waitToDumpWatchdogTimerFired) 72 73 { 73 74 WKRetainPtr<WKStringRef> urlString = adoptWK(WKURLCopyString(m_url.get())); … … 138 139 WKRetainPtr<WKBooleanRef> dumpPixelsValue = adoptWK(WKBooleanCreate(m_dumpPixels)); 139 140 WKDictionarySetItem(beginTestMessageBody.get(), dumpPixelsKey.get(), dumpPixelsValue.get()); 140 141 WKRetainPtr<WKStringRef> useWaitToDumpWatchdogTimerKey = adoptWK(WKStringCreateWithUTF8CString("UseWaitToDumpWatchdogTimer"));142 WKRetainPtr<WKBooleanRef> useWaitToDumpWatchdogTimerValue = adoptWK(WKBooleanCreate(TestController::singleton().useWaitToDumpWatchdogTimer()));143 WKDictionarySetItem(beginTestMessageBody.get(), useWaitToDumpWatchdogTimerKey.get(), useWaitToDumpWatchdogTimerValue.get());144 141 145 142 WKRetainPtr<WKStringRef> timeoutKey = adoptWK(WKStringCreateWithUTF8CString("Timeout")); … … 358 355 m_audioResult = static_cast<WKDataRef>(WKDictionaryGetItemForKey(messageBodyDictionary, audioResultKey.get())); 359 356 360 m_gotFinalMessage = true; 361 TestController::singleton().notifyDone(); 357 done(); 362 358 return; 363 359 } … … 833 829 if (WKStringIsEqualToUTF8CString(messageName, "SetWaitUntilDone")) { 834 830 ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID()); 835 m_waitUntilDone = static_cast<unsigned char>(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)));831 setWaitUntilDone(static_cast<unsigned char>(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)))); 836 832 return nullptr; 837 833 } … … 1830 1826 } 1831 1827 1828 void TestInvocation::initializeWaitToDumpWatchdogTimerIfNeeded() 1829 { 1830 if (m_waitToDumpWatchdogTimer.isActive()) 1831 return; 1832 1833 m_waitToDumpWatchdogTimer.startOneShot(m_timeout); 1834 } 1835 1836 void TestInvocation::invalidateWaitToDumpWatchdogTimer() 1837 { 1838 m_waitToDumpWatchdogTimer.stop(); 1839 } 1840 1841 void TestInvocation::waitToDumpWatchdogTimerFired() 1842 { 1843 invalidateWaitToDumpWatchdogTimer(); 1844 1845 #if PLATFORM(COCOA) 1846 char buffer[1024]; 1847 snprintf(buffer, sizeof(buffer), "#PID UNRESPONSIVE - %s (pid %d)\n", getprogname(), getpid()); 1848 outputText(buffer); 1849 #endif 1850 outputText("FAIL: Timed out waiting for notifyDone to be called\n\n"); 1851 done(); 1852 } 1853 1854 void TestInvocation::setWaitUntilDone(bool waitUntilDone) 1855 { 1856 m_waitUntilDone = waitUntilDone; 1857 if (waitUntilDone && TestController::singleton().useWaitToDumpWatchdogTimer()) 1858 initializeWaitToDumpWatchdogTimerIfNeeded(); 1859 } 1860 1861 void TestInvocation::done() 1862 { 1863 m_gotFinalMessage = true; 1864 invalidateWaitToDumpWatchdogTimer(); 1865 RunLoop::main().dispatch([] { 1866 TestController::singleton().notifyDone(); 1867 }); 1868 } 1869 1832 1870 } // namespace WTR -
trunk/Tools/WebKitTestRunner/TestInvocation.h
r244370 r244723 34 34 #include <string> 35 35 #include <wtf/Noncopyable.h> 36 #include <wtf/RunLoop.h> 36 37 #include <wtf/Seconds.h> 37 38 #include <wtf/text/StringBuilder.h> … … 94 95 WKRetainPtr<WKMutableDictionaryRef> createTestSettingsDictionary(); 95 96 97 void waitToDumpWatchdogTimerFired(); 98 void initializeWaitToDumpWatchdogTimerIfNeeded(); 99 void invalidateWaitToDumpWatchdogTimer(); 100 101 void done(); 102 void setWaitUntilDone(bool); 103 96 104 void dumpResults(); 97 105 static void dump(const char* textToStdout, const char* textToStderr = 0, bool seenError = false); … … 120 128 WKRetainPtr<WKURLRef> m_url; 121 129 WTF::String m_urlString; 130 RunLoop::Timer<TestInvocation> m_waitToDumpWatchdogTimer; 122 131 123 132 std::string m_expectedPixelHash;
Note: See TracChangeset
for help on using the changeset viewer.