Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3b068d9c3d5f80474d9e58e311d6310c1e746cda
      
https://github.com/WebKit/WebKit/commit/3b068d9c3d5f80474d9e58e311d6310c1e746cda
  Author: Kiet Ho <[email protected]>
  Date:   2026-09-02 (Wed, 02 Sep 2026)

  Changed paths:
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/page/IntersectionObserver.cpp

  Log Message:
  -----------
  [intersection-observer] Some performance/power optimizations
rdar://185839711
https://bugs.webkit.org/show_bug.cgi?id=323047

Reviewed by Ryosuke Niwa and Simon Fraser.

Recent changes in intersection observer have been shown to cause power
regressions. This is an attempt to optimize parts that show up in power
traces:

1) In IntersectionObserver::updateObservations, we copy the list of targets
   before iterating through it. It seems that copying WeakListHashSet to
   another WeakListHashSet involves adding each element, and power traces
   shows we spend more time expanding the underlying hash table. Replace the
   copy with copyToVectorOf, which reserves capacity before copying, so it
   wouldn't expand capacity during copy.
2) Also in IntersectionObserver::updateObservations, we check if the target's
   document is fully active before proceeding. This check is expensive as it
   traverses the frame tree. Since it's more likely that targets belong to a
   handful of documents, and documents wouldn't change their fully active
   status during update, add a cache to cache document's fully active status.
3) In Document::updateRemoteIntersectionObservers, add an assert to check that
   a document only has remote obsevers if the page has remote frames. This is
   always true, as remote observers only exist in a document that is remote
   (not in the same process) with the main frame.

Optimization patch, tested by existing test suite.

* Source/WebCore/page/IntersectionObserver.cpp:
(WebCore::IntersectionObserver::updateObservations):
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::updateRemoteIntersectionObservers):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to