Changeset 241821 in webkit
- Timestamp:
- Feb 20, 2019 10:34:44 AM (5 years ago)
- Location:
- trunk/Tools
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r241790 r241821 1 2019-02-20 Chris Dumez <cdumez@apple.com> 2 3 [WKTR] Avoid starting new NetworkProcesses unnecessarily when running the layout tests 4 https://bugs.webkit.org/show_bug.cgi?id=194829 5 <rdar://problem/47889906> 6 7 Reviewed by Alexey Proskuryakov. 8 9 Every time the TestOptions were changing we were creating both a new Web view and 10 a new WKContext, which would start a new Network process. In most cases, we only 11 need to contruct a new Web view and we do can keep reusing the same WKContext. 12 This patch implements this optimization and thus avoids spinning a lot of new 13 Network processes while running the layout tests. 14 15 * WebKitTestRunner/TestController.cpp: 16 (WTR::TestController::generateContextConfiguration const): 17 (WTR::TestController::generatePageConfiguration): 18 (WTR::TestController::createWebViewWithOptions): 19 (WTR::TestController::resetPreferencesToConsistentValues): 20 (WTR::updateTestOptionsFromTestHeader): 21 * WebKitTestRunner/TestController.h: 22 * WebKitTestRunner/TestOptions.h: 23 (WTR::TestOptions::ContextOptions::hasSameInitializationOptions const): 24 (WTR::TestOptions::ContextOptions::shouldEnableProcessSwapOnNavigation const): 25 (WTR::TestOptions::hasSameInitializationOptions const): 26 (WTR::TestOptions::shouldEnableProcessSwapOnNavigation const): Deleted. 27 * WebKitTestRunner/cocoa/TestControllerCocoa.mm: 28 (WTR::TestController::platformAddTestOptions const): 29 1 30 2019-02-20 Adrian Perez de Castro <aperez@igalia.com> 2 31 -
trunk/Tools/WebKitTestRunner/TestController.cpp
r241654 r241821 455 455 } 456 456 457 WKRetainPtr<WKContextConfigurationRef> TestController::generateContextConfiguration(const TestOptions & options) const457 WKRetainPtr<WKContextConfigurationRef> TestController::generateContextConfiguration(const TestOptions::ContextOptions& options) const 458 458 { 459 459 auto configuration = adoptWK(WKContextConfigurationCreate()); … … 461 461 WKContextConfigurationSetFullySynchronousModeIsAllowedForTesting(configuration.get(), true); 462 462 WKContextConfigurationSetIgnoreSynchronousMessagingTimeoutsForTesting(configuration.get(), options.ignoreSynchronousMessagingTimeouts); 463 464 WKRetainPtr<WKMutableArrayRef> overrideLanguages = adoptWK(WKMutableArrayCreate()); 465 for (auto& language : options.overrideLanguages) 466 WKArrayAppendItem(overrideLanguages.get(), adoptWK(WKStringCreateWithUTF8CString(language.utf8().data())).get()); 467 WKContextConfigurationSetOverrideLanguages(configuration.get(), overrideLanguages.get()); 468 469 if (options.shouldEnableProcessSwapOnNavigation()) { 470 WKContextConfigurationSetProcessSwapsOnNavigation(configuration.get(), true); 471 if (options.enableProcessSwapOnWindowOpen) 472 WKContextConfigurationSetProcessSwapsOnWindowOpenWithOpener(configuration.get(), true); 473 } 463 474 464 475 if (const char* dumpRenderTreeTemp = libraryPathForTesting()) { … … 476 487 } 477 488 478 WKRetainPtr<WKPageConfigurationRef> TestController::generatePageConfiguration(WKContextConfigurationRef configuration) 479 { 480 m_context = platformAdjustContext(adoptWK(WKContextCreateWithConfiguration(configuration)).get(), configuration); 481 482 m_geolocationProvider = std::make_unique<GeolocationProviderMock>(m_context.get()); 483 484 if (const char* dumpRenderTreeTemp = libraryPathForTesting()) { 485 String temporaryFolder = String::fromUTF8(dumpRenderTreeTemp); 486 487 // FIXME: This should be migrated to WKContextConfigurationRef. 488 // Disable icon database to avoid fetching <http://127.0.0.1:8000/favicon.ico> and making tests flaky. 489 // Invividual tests can enable it using testRunner.setIconDatabaseEnabled, although it's not currently supported in WebKitTestRunner. 490 WKContextSetIconDatabasePath(m_context.get(), toWK(emptyString()).get()); 491 } 492 493 WKContextSetDiskCacheSpeculativeValidationEnabled(m_context.get(), true); 494 WKContextUseTestingNetworkSession(m_context.get()); 495 WKContextSetCacheModel(m_context.get(), kWKCacheModelDocumentBrowser); 496 497 auto* websiteDataStore = WKContextGetWebsiteDataStore(m_context.get()); 498 WKWebsiteDataStoreSetCacheStoragePerOriginQuota(websiteDataStore, 400 * 1024); 499 500 platformInitializeContext(); 489 WKRetainPtr<WKPageConfigurationRef> TestController::generatePageConfiguration(const TestOptions& options) 490 { 491 if (!m_context || !m_contextOptions->hasSameInitializationOptions(options.contextOptions)) { 492 auto contextConfiguration = generateContextConfiguration(options.contextOptions); 493 m_context = platformAdjustContext(adoptWK(WKContextCreateWithConfiguration(contextConfiguration.get())).get(), contextConfiguration.get()); 494 m_contextOptions = options.contextOptions; 495 496 m_geolocationProvider = std::make_unique<GeolocationProviderMock>(m_context.get()); 497 498 if (const char* dumpRenderTreeTemp = libraryPathForTesting()) { 499 String temporaryFolder = String::fromUTF8(dumpRenderTreeTemp); 500 501 // FIXME: This should be migrated to WKContextConfigurationRef. 502 // Disable icon database to avoid fetching <http://127.0.0.1:8000/favicon.ico> and making tests flaky. 503 // Invividual tests can enable it using testRunner.setIconDatabaseEnabled, although it's not currently supported in WebKitTestRunner. 504 WKContextSetIconDatabasePath(m_context.get(), toWK(emptyString()).get()); 505 } 506 507 WKContextSetDiskCacheSpeculativeValidationEnabled(m_context.get(), true); 508 WKContextUseTestingNetworkSession(m_context.get()); 509 WKContextSetCacheModel(m_context.get(), kWKCacheModelDocumentBrowser); 510 511 auto* websiteDataStore = WKContextGetWebsiteDataStore(m_context.get()); 512 WKWebsiteDataStoreSetCacheStoragePerOriginQuota(websiteDataStore, 400 * 1024); 513 514 platformInitializeContext(); 515 } 501 516 502 517 WKContextInjectedBundleClientV1 injectedBundleClient = { … … 548 563 void TestController::createWebViewWithOptions(const TestOptions& options) 549 564 { 550 auto contextConfiguration = generateContextConfiguration(options); 551 552 WKRetainPtr<WKMutableArrayRef> overrideLanguages = adoptWK(WKMutableArrayCreate()); 553 for (auto& language : options.overrideLanguages) 554 WKArrayAppendItem(overrideLanguages.get(), adoptWK(WKStringCreateWithUTF8CString(language.utf8().data())).get()); 555 WKContextConfigurationSetOverrideLanguages(contextConfiguration.get(), overrideLanguages.get()); 556 557 if (options.shouldEnableProcessSwapOnNavigation()) { 558 WKContextConfigurationSetProcessSwapsOnNavigation(contextConfiguration.get(), true); 559 if (options.enableProcessSwapOnWindowOpen) 560 WKContextConfigurationSetProcessSwapsOnWindowOpenWithOpener(contextConfiguration.get(), true); 561 } 562 563 auto configuration = generatePageConfiguration(contextConfiguration.get()); 565 auto configuration = generatePageConfiguration(options); 564 566 565 567 // Some preferences (notably mock scroll bars setting) currently cannot be re-applied to an existing view, so we need to set them now. … … 737 739 WKPreferencesSetInternalDebugFeatureForKey(preferences, internalDebugFeature.value, toWK(internalDebugFeature.key).get()); 738 740 739 WKPreferencesSetProcessSwapOnNavigationEnabled(preferences, options. shouldEnableProcessSwapOnNavigation());741 WKPreferencesSetProcessSwapOnNavigationEnabled(preferences, options.contextOptions.shouldEnableProcessSwapOnNavigation()); 740 742 WKPreferencesSetPageVisibilityBasedProcessSuppressionEnabled(preferences, false); 741 743 WKPreferencesSetOfflineWebApplicationCacheEnabled(preferences, true); … … 1230 1232 1231 1233 if (key == "language") 1232 testOptions. overrideLanguages = String(value.c_str()).split(',');1234 testOptions.contextOptions.overrideLanguages = String(value.c_str()).split(','); 1233 1235 else if (key == "useThreadedScrolling") 1234 1236 testOptions.useThreadedScrolling = parseBooleanTestHeaderValue(value); … … 1274 1276 testOptions.domPasteAllowed = parseBooleanTestHeaderValue(value); 1275 1277 else if (key == "enableProcessSwapOnNavigation") 1276 testOptions. enableProcessSwapOnNavigation = parseBooleanTestHeaderValue(value);1278 testOptions.contextOptions.enableProcessSwapOnNavigation = parseBooleanTestHeaderValue(value); 1277 1279 else if (key == "enableProcessSwapOnWindowOpen") 1278 testOptions. enableProcessSwapOnWindowOpen = parseBooleanTestHeaderValue(value);1280 testOptions.contextOptions.enableProcessSwapOnWindowOpen = parseBooleanTestHeaderValue(value); 1279 1281 else if (key == "enableColorFilter") 1280 1282 testOptions.enableColorFilter = parseBooleanTestHeaderValue(value); … … 1298 1300 testOptions.contentInsetTop = std::stod(value); 1299 1301 else if (key == "ignoreSynchronousMessagingTimeouts") 1300 testOptions. ignoreSynchronousMessagingTimeouts = parseBooleanTestHeaderValue(value);1302 testOptions.contextOptions.ignoreSynchronousMessagingTimeouts = parseBooleanTestHeaderValue(value); 1301 1303 pairStart = pairEnd + 1; 1302 1304 } -
trunk/Tools/WebKitTestRunner/TestController.h
r241654 r241821 27 27 28 28 #include "GeolocationProviderMock.h" 29 #include "TestOptions.h" 29 30 #include "WebNotificationProvider.h" 30 31 #include "WorkQueueManager.h" … … 299 300 300 301 private: 301 WKRetainPtr<WKPageConfigurationRef> generatePageConfiguration( WKContextConfigurationRef);302 WKRetainPtr<WKContextConfigurationRef> generateContextConfiguration(const TestOptions &) const;302 WKRetainPtr<WKPageConfigurationRef> generatePageConfiguration(const TestOptions&); 303 WKRetainPtr<WKContextConfigurationRef> generateContextConfiguration(const TestOptions::ContextOptions&) const; 303 304 void initialize(int argc, const char* argv[]); 304 305 void createWebViewWithOptions(const TestOptions&); … … 467 468 std::unique_ptr<PlatformWebView> m_mainWebView; 468 469 WKRetainPtr<WKContextRef> m_context; 470 Optional<TestOptions::ContextOptions> m_contextOptions; 469 471 WKRetainPtr<WKPageGroupRef> m_pageGroup; 470 472 WKRetainPtr<WKUserContentControllerRef> m_userContentController; -
trunk/Tools/WebKitTestRunner/TestOptions.h
r241322 r241821 34 34 35 35 struct TestOptions { 36 struct ContextOptions { 37 Vector<String> overrideLanguages; 38 bool ignoreSynchronousMessagingTimeouts { false }; 39 bool enableProcessSwapOnNavigation { true }; 40 bool enableProcessSwapOnWindowOpen { false }; 41 42 bool hasSameInitializationOptions(const ContextOptions& options) const 43 { 44 if (ignoreSynchronousMessagingTimeouts != options.ignoreSynchronousMessagingTimeouts 45 || overrideLanguages != options.overrideLanguages 46 || enableProcessSwapOnNavigation != options.enableProcessSwapOnNavigation 47 || enableProcessSwapOnWindowOpen != options.enableProcessSwapOnWindowOpen) 48 return false; 49 return true; 50 } 51 52 bool shouldEnableProcessSwapOnNavigation() const 53 { 54 return enableProcessSwapOnNavigation || enableProcessSwapOnWindowOpen; 55 } 56 }; 57 36 58 bool useThreadedScrolling { false }; 37 59 bool useAcceleratedDrawing { false }; … … 59 81 bool allowCrossOriginSubresourcesToAskForCredentials { false }; 60 82 bool domPasteAllowed { true }; 61 bool enableProcessSwapOnNavigation { true };62 bool enableProcessSwapOnWindowOpen { false };63 83 bool enableColorFilter { false }; 64 84 bool punchOutWhiteBackgroundsInDarkMode { false }; … … 70 90 bool editable { false }; 71 91 bool enableUndoManagerAPI { false }; 72 bool ignoreSynchronousMessagingTimeouts { false };73 92 74 93 double contentInsetTop { 0 }; 75 94 76 95 float deviceScaleFactor { 1 }; 77 Vector<String> overrideLanguages;78 96 std::string applicationManifest; 79 97 std::string jscOptions; 80 98 HashMap<String, bool> experimentalFeatures; 81 99 HashMap<String, bool> internalDebugFeatures; 100 101 ContextOptions contextOptions; 82 102 83 103 TestOptions(const std::string& pathOrURL); … … 91 111 if (useThreadedScrolling != options.useThreadedScrolling 92 112 || useAcceleratedDrawing != options.useAcceleratedDrawing 93 || overrideLanguages != options.overrideLanguages94 113 || useMockScrollbars != options.useMockScrollbars 95 114 || needsSiteSpecificQuirks != options.needsSiteSpecificQuirks … … 108 127 || allowCrossOriginSubresourcesToAskForCredentials != options.allowCrossOriginSubresourcesToAskForCredentials 109 128 || domPasteAllowed != options.domPasteAllowed 110 || enableProcessSwapOnNavigation != options.enableProcessSwapOnNavigation111 || enableProcessSwapOnWindowOpen != options.enableProcessSwapOnWindowOpen112 129 || enableColorFilter != options.enableColorFilter 113 130 || punchOutWhiteBackgroundsInDarkMode != options.punchOutWhiteBackgroundsInDarkMode … … 120 137 || editable != options.editable 121 138 || enableUndoManagerAPI != options.enableUndoManagerAPI 122 || contentInsetTop != options.contentInsetTop 123 || ignoreSynchronousMessagingTimeouts != options.ignoreSynchronousMessagingTimeouts) 139 || contentInsetTop != options.contentInsetTop) 140 return false; 141 142 if (!contextOptions.hasSameInitializationOptions(options.contextOptions)) 124 143 return false; 125 144 … … 132 151 return true; 133 152 } 134 135 bool shouldEnableProcessSwapOnNavigation() const136 {137 return enableProcessSwapOnNavigation || enableProcessSwapOnWindowOpen;138 }139 153 }; 140 154 -
trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm
r241654 r241821 143 143 { 144 144 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"EnableProcessSwapOnNavigation"]) 145 options. enableProcessSwapOnNavigation = true;145 options.contextOptions.enableProcessSwapOnNavigation = true; 146 146 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"EnableProcessSwapOnWindowOpen"]) 147 options. enableProcessSwapOnWindowOpen = true;147 options.contextOptions.enableProcessSwapOnWindowOpen = true; 148 148 } 149 149
Note: See TracChangeset
for help on using the changeset viewer.