Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d7c940fc0a09e4cfbc249ad1c62e2d7e2da1430a
      
https://github.com/WebKit/WebKit/commit/d7c940fc0a09e4cfbc249ad1c62e2d7e2da1430a
  Author: Timothy Hatcher <timo...@apple.com>
  Date:   2024-07-12 (Fri, 12 Jul 2024)

  Changed paths:
    M Source/WTF/wtf/Assertions.h
    M Source/WTF/wtf/WeakObjCPtr.h
    M Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionContext.mm
    M 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIRuntimeCocoa.mm
    M 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPITabsCocoa.mm
    M 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIWindowsCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionTabCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionWindowCocoa.mm
    M Source/WebKit/UIProcess/Extensions/WebExtensionAction.h
    M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h

  Log Message:
  -----------
  MobileSafari hangs for 2.6 to 5.2 seconds in 
WebKit::WebExtensionWindow::tabs(WebKit::WebExtensionWindow::SkipValidation) 
const.
https://webkit.org/b/276552
rdar://131567261

Reviewed by Brian Weinstein.

Reduced amount of time spent in web extension classes by removing all internal 
`conformsToProtocol:`
checks. This saves 31.78% of time spent. We still do protocol checks at the API 
entry points. All the
methods in these protocols are optional, and we have `respondsToSelector:` 
checks that are cached.

Removed expensive checks in release builds for the web view configuration of 
tabs every time we get
a `WebExtensionTab`. This saves 23.69% of time spent. This method is still 
helpful and used in debug
builds for catching misconfiguration issues.

Stopped making a throw-away `RetainPtr` when checking a `WeakObjCPtr` as a 
`bool`. This saves 6.7% of
time spent. We can use `getAutoreleased()` instead when converting the raw 
pointer value to `bool`.
This was happening in all the `WebExtensionWindow` and `WebExtensionTab` 
methods that do `isValid()`
checks at the beginning of the method.

Adopted `UNLIKELY()` in uncommon code branches, logging macros, and assertions 
to help the compiler
optimize these paths better in release builds.

In total, this change removes 62.18% of time spent and should be at least 2.64x 
faster.

* Source/WTF/wtf/Assertions.h: Use UNLIKELY() in more cases.
* Source/WTF/wtf/WeakObjCPtr.h:
(WTF::WeakObjCPtr::operator! const): Use getAutoreleased() to avoid making a 
throw-away RetainPtr.
(WTF::WeakObjCPtr::operator bool const): Ditto.
* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionContext.mm:
(toImpl): Drive-by to simplify loop type that will be renamed soon.
* 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIRuntimeCocoa.mm:
(WebKit::WebExtensionContext::runtimeOpenOptionsPage): Removed 
conformsToProtocol: check.
* 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPITabsCocoa.mm:
(WebKit::WebExtensionContext::tabsCreate): Removed conformsToProtocol: check.
* 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIWindowsCocoa.mm:
(WebKit::WebExtensionContext::windowsCreate): Removed conformsToProtocol: check.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::getWindow const): Adopt UNLIKELY() and remove 
conformsToProtocol:.
(WebKit::WebExtensionContext::getTab const): Ditto.
(WebKit::WebExtensionContext::getCurrentTab const): Ditto.
(WebKit::WebExtensionContext::populateWindowsAndTabs): Ditto.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionTabCocoa.mm:
(WebKit::WebExtensionTab::WebExtensionTab): Removed conformsToProtocol: check.
(WebKit::WebExtensionTab::window const): Ditto.
(WebKit::WebExtensionTab::parentTab const): Ditto.
(WebKit::WebExtensionTab::mainWebView const): Reduce property access with 
variables.
(WebKit::WebExtensionTab::duplicate): Removed conformsToProtocol: check.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionWindowCocoa.mm:
(WebKit::WebExtensionWindow::WebExtensionWindow): Removed conformsToProtocol: 
check.
(WebKit::WebExtensionWindow::tabs const): Ditto.
(WebKit::WebExtensionWindow::activeTab const): Ditto.
* Source/WebKit/UIProcess/Extensions/WebExtensionAction.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
(WebKit::WebExtensionContext::reportWebViewConfigurationErrorIfNeeded const): 
Made a no-op in release
builds since it has a performance impact with little benefit to release builds.

Canonical link: https://commits.webkit.org/280925@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to