Changeset 237267 in webkit
- Timestamp:
- Oct 18, 2018 2:41:41 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r237266 r237267 1 2018-10-18 Chris Dumez <cdumez@apple.com> 2 3 [PSON] SuspendedPages do not report meaningful domains in Activity Monitor 4 https://bugs.webkit.org/show_bug.cgi?id=190721 5 <rdar://problem/45059699> 6 7 Reviewed by Alex Christensen. 8 9 SuspendedPages do not report meaningful domains in Activity Monitor, which makes 10 debugging harder. 11 12 * WebProcess/cocoa/WebProcessCocoa.mm: 13 (WebKit::origin): 14 (WebKit::WebProcess::updateActivePages): 15 1 16 2018-10-18 Alexey Proskuryakov <ap@apple.com> 2 17 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
r237266 r237267 575 575 } 576 576 577 - (NSArray<NSString *> *)_getActivePagesOriginsInWebProcessForTesting:(pid_t)pid 578 { 579 auto activePagesOrigins = _processPool->activePagesOriginsInWebProcessForTesting(pid); 580 581 NSMutableArray<NSString *> *array = [[NSMutableArray alloc] initWithCapacity:activePagesOrigins.size()]; 582 for (auto& origin : activePagesOrigins) 583 [array addObject:(NSString *)origin]; 584 return [array autorelease]; 585 } 586 577 587 @end 578 588 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
r236690 r237267 114 114 - (void)_registerURLSchemeServiceWorkersCanHandle:(NSString *)scheme WK_API_AVAILABLE(macosx(10.13.4), ios(11.3)); 115 115 - (void)_setMaximumNumberOfProcesses:(NSUInteger)value WK_API_AVAILABLE(macosx(10.13.4), ios(11.3)); 116 - (NSArray<NSString *> *)_getActivePagesOriginsInWebProcessForTesting:(pid_t)pid WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 116 117 117 118 @property (nonatomic, getter=_isCookieStoragePartitioningEnabled, setter=_setCookieStoragePartitioningEnabled:) BOOL _cookieStoragePartitioningEnabled WK_API_DEPRECATED("Partitioned cookies are no longer supported", macosx(10.12.3, WK_MAC_TBA), ios(10.3, WK_IOS_TBA)); -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r237266 r237267 1326 1326 } 1327 1327 1328 Vector<String> WebProcessPool::activePagesOriginsInWebProcessForTesting(ProcessID pid) 1329 { 1330 for (auto& process : m_processes) { 1331 if (process->processIdentifier() == pid) 1332 return process->activePagesDomainsForTesting(); 1333 } 1334 return { }; 1335 } 1336 1328 1337 void WebProcessPool::setAlwaysUsesComplexTextCodePath(bool alwaysUseComplexText) 1329 1338 { -
trunk/Source/WebKit/UIProcess/WebProcessPool.h
r237266 r237267 216 216 217 217 ProcessID networkProcessIdentifier(); 218 Vector<String> activePagesOriginsInWebProcessForTesting(ProcessID); 218 219 219 220 WebPageGroup& defaultPageGroup() { return m_defaultPageGroup.get(); } -
trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp
r237266 r237267 1405 1405 } 1406 1406 1407 Vector<String> WebProcessProxy::activePagesDomainsForTesting() 1408 { 1409 Vector<String> activeDomains; 1410 sendSync(Messages::WebProcess::GetActivePagesOriginsForTesting(), Messages::WebProcess::GetActivePagesOriginsForTesting::Reply(activeDomains), 0); 1411 return activeDomains; 1412 } 1413 1407 1414 #if PLATFORM(WATCHOS) 1408 1415 -
trunk/Source/WebKit/UIProcess/WebProcessProxy.h
r237266 r237267 122 122 unsigned visiblePageCount() const { return m_visiblePageCounter.value(); } 123 123 124 Vector<String> activePagesDomainsForTesting(); // This is what is reported to ActivityMonitor. 125 124 126 virtual bool isServiceWorkerProcess() const { return false; } 125 127 -
trunk/Source/WebKit/WebProcess/WebProcess.cpp
r237266 r237267 1329 1329 } 1330 1330 1331 void WebProcess::getActivePagesOriginsForTesting(Vector<String>&) 1332 { 1333 } 1334 1331 1335 void WebProcess::updateCPULimit() 1332 1336 { -
trunk/Source/WebKit/WebProcess/WebProcess.h
r237266 r237267 193 193 194 194 void updateActivePages(); 195 void getActivePagesOriginsForTesting(Vector<String>&); 195 196 void pageActivityStateDidChange(uint64_t pageID, OptionSet<WebCore::ActivityState::Flag> changed); 196 197 -
trunk/Source/WebKit/WebProcess/WebProcess.messages.in
r236959 r237267 130 130 131 131 UpdateActivePages() 132 GetActivePagesOriginsForTesting() -> (Vector<String> activeOrigins) 132 133 133 134 #if PLATFORM(MAC) -
trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm
r237266 r237267 55 55 #import <WebCore/FontCache.h> 56 56 #import <WebCore/FontCascade.h> 57 #import <WebCore/HistoryController.h> 58 #import <WebCore/HistoryItem.h> 57 59 #import <WebCore/LocalizedStrings.h> 58 60 #import <WebCore/LogInitialization.h> … … 410 412 return nil; 411 413 412 URL mainFrameURL(URL(), mainFrame->url()); 414 URL mainFrameURL = { URL(), mainFrame->url() }; 415 if (page.isSuspended()) { 416 // Suspended page are navigated to about:blank upon suspension so we really want to report the previous URL. 417 if (auto* coreFrame = mainFrame->coreFrame()) { 418 if (auto* backHistoryItem = coreFrame->loader().history().previousItem()) 419 mainFrameURL = { URL(), backHistoryItem->urlString() }; 420 } 421 } 422 413 423 Ref<SecurityOrigin> mainFrameOrigin = SecurityOrigin::create(mainFrameURL); 414 424 String mainFrameOriginString; … … 427 437 #endif 428 438 439 #if PLATFORM(MAC) 440 static RetainPtr<NSArray<NSString *>> activePagesOrigins(const HashMap<uint64_t, RefPtr<WebPage>>& pageMap) 441 { 442 RetainPtr<NSMutableArray<NSString *>> activeOrigins = adoptNS([[NSMutableArray alloc] init]); 443 444 for (auto& page : pageMap.values()) { 445 if (page->usesEphemeralSession()) 446 continue; 447 448 if (NSURL *originAsURL = origin(*page)) 449 [activeOrigins addObject:userVisibleString(originAsURL)]; 450 } 451 452 return activeOrigins; 453 } 454 #endif 455 429 456 void WebProcess::updateActivePages() 430 457 { 431 458 #if PLATFORM(MAC) 432 auto activePageURLs = adoptNS([[NSMutableArray alloc] init]); 433 434 for (auto& page : m_pageMap.values()) { 435 if (page->usesEphemeralSession() || page->isSuspended()) 436 continue; 437 438 if (NSURL *originAsURL = origin(*page)) 439 [activePageURLs addObject:userVisibleString(originAsURL)]; 440 } 441 442 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), [activePageURLs] { 443 _LSSetApplicationInformationItem(kLSDefaultSessionID, _LSGetCurrentApplicationASN(), CFSTR("LSActivePageUserVisibleOriginsKey"), (__bridge CFArrayRef)activePageURLs.get(), nullptr); 459 auto activeOrigins = activePagesOrigins(m_pageMap); 460 461 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), [activeOrigins = WTFMove(activeOrigins)] { 462 _LSSetApplicationInformationItem(kLSDefaultSessionID, _LSGetCurrentApplicationASN(), CFSTR("LSActivePageUserVisibleOriginsKey"), (__bridge CFArrayRef)activeOrigins.get(), nullptr); 444 463 }); 464 #endif 465 } 466 467 void WebProcess::getActivePagesOriginsForTesting(Vector<String>& activeOrigins) 468 { 469 #if PLATFORM(MAC) 470 auto activeOriginsAsNSStrings = activePagesOrigins(m_pageMap); 471 activeOrigins.reserveCapacity([activeOriginsAsNSStrings count]); 472 for (NSString* activeOrigin in activeOriginsAsNSStrings.get()) 473 activeOrigins.uncheckedAppend(activeOrigin); 474 #else 475 UNUSED_PARAM(activeOrigins); 445 476 #endif 446 477 } -
trunk/Tools/ChangeLog
r237266 r237267 1 2018-10-18 Chris Dumez <cdumez@apple.com> 2 3 [PSON] SuspendedPages do not report meaningful domains in Activity Monitor 4 https://bugs.webkit.org/show_bug.cgi?id=190721 5 <rdar://problem/45059699> 6 7 Reviewed by Alex Christensen. 8 9 Add API test coverage. 10 11 * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm: 12 1 13 2018-10-18 Alexey Proskuryakov <ap@apple.com> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm
r237257 r237267 517 517 } 518 518 519 #if PLATFORM(MAC) 520 TEST(ProcessSwap, SuspendedPagesInActivityMonitor) 521 { 522 auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]); 523 processPoolConfiguration.get().processSwapsOnNavigation = YES; 524 auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]); 525 526 auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]); 527 [webViewConfiguration setProcessPool:processPool.get()]; 528 auto handler = adoptNS([[PSONScheme alloc] init]); 529 [handler addMappingFromURLString:@"pson://www.webkit.org/main.html" toData:testBytes]; 530 [handler addMappingFromURLString:@"pson://www.google.com/main.html" toData:testBytes]; 531 [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"]; 532 533 RetainPtr<PSONMessageHandler> messageHandler = adoptNS([[PSONMessageHandler alloc] init]); 534 [[webViewConfiguration userContentController] addScriptMessageHandler:messageHandler.get() name:@"pson"]; 535 536 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]); 537 auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]); 538 [webView setNavigationDelegate:delegate.get()]; 539 540 NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]]; 541 [webView loadRequest:request]; 542 543 TestWebKitAPI::Util::run(&done); 544 done = false; 545 546 auto webkitPID = [webView _webProcessIdentifier]; 547 auto* activeDomains = [processPool _getActivePagesOriginsInWebProcessForTesting:webkitPID]; 548 EXPECT_EQ(1u, activeDomains.count); 549 EXPECT_WK_STREQ(@"pson://www.webkit.org", activeDomains[0]); 550 551 request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.google.com/main.html"]]; 552 [webView loadRequest:request]; 553 554 TestWebKitAPI::Util::run(&done); 555 done = false; 556 557 auto googlePID = [webView _webProcessIdentifier]; 558 EXPECT_NE(webkitPID, googlePID); 559 560 activeDomains = [processPool _getActivePagesOriginsInWebProcessForTesting:googlePID]; 561 EXPECT_EQ(1u, activeDomains.count); 562 EXPECT_WK_STREQ(@"pson://www.google.com", activeDomains[0]); 563 564 activeDomains = [processPool _getActivePagesOriginsInWebProcessForTesting:webkitPID]; 565 EXPECT_EQ(1u, activeDomains.count); 566 EXPECT_WK_STREQ(@"pson://www.webkit.org", activeDomains[0]); 567 568 [webView goBack]; // Back to webkit.org. 569 570 TestWebKitAPI::Util::run(&receivedMessage); 571 receivedMessage = false; 572 TestWebKitAPI::Util::run(&done); 573 done = false; 574 575 auto pidAfterBackNavigation = [webView _webProcessIdentifier]; 576 EXPECT_EQ(webkitPID, pidAfterBackNavigation); 577 578 activeDomains = [processPool _getActivePagesOriginsInWebProcessForTesting:googlePID]; 579 EXPECT_EQ(1u, activeDomains.count); 580 EXPECT_WK_STREQ(@"pson://www.google.com", activeDomains[0]); 581 582 activeDomains = [processPool _getActivePagesOriginsInWebProcessForTesting:webkitPID]; 583 EXPECT_EQ(1u, activeDomains.count); 584 EXPECT_WK_STREQ(@"pson://www.webkit.org", activeDomains[0]); 585 } 586 #endif // PLATFORM(MAC) 587 519 588 TEST(ProcessSwap, BackWithoutSuspendedPage) 520 589 {
Note: See TracChangeset
for help on using the changeset viewer.