[soft navs] Pure refactor - extract SoftNavigationMetricsObserver [chromium/src : main]

0 views
Skip to first unread message

Johannes Henkel (Gerrit)

unread,
Sep 15, 2025, 12:28:05 PM (6 days ago) Sep 15
to Annie Sullivan, Michal Mocny, AyeAye, bmcquad...@chromium.org, loading-rev...@chromium.org, core-web-vita...@chromium.org, speed-metr...@chromium.org, speed-metrics...@chromium.org, csharris...@chromium.org
Attention needed from Annie Sullivan and Michal Mocny

New activity on the change

Open in Gerrit

Related details

Attention is currently required from:
  • Annie Sullivan
  • Michal Mocny
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I58fd45f922f0f53cc80567262e9e3f7edb01a182
Gerrit-Change-Number: 6950612
Gerrit-PatchSet: 4
Gerrit-Owner: Johannes Henkel <joha...@chromium.org>
Gerrit-Reviewer: Annie Sullivan <sull...@chromium.org>
Gerrit-Reviewer: Michal Mocny <mmo...@chromium.org>
Gerrit-Attention: Michal Mocny <mmo...@chromium.org>
Gerrit-Attention: Annie Sullivan <sull...@chromium.org>
Gerrit-Comment-Date: Mon, 15 Sep 2025 16:27:57 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Annie Sullivan (Gerrit)

unread,
Sep 15, 2025, 3:26:15 PM (6 days ago) Sep 15
to Johannes Henkel, Michal Mocny, AyeAye, bmcquad...@chromium.org, loading-rev...@chromium.org, core-web-vita...@chromium.org, speed-metr...@chromium.org, speed-metrics...@chromium.org, csharris...@chromium.org
Attention needed from Johannes Henkel and Michal Mocny

Annie Sullivan added 2 comments

Commit Message
Line 12, Patchset 4 (Latest):CalculateLCPEntropyBucket is now duplicated, may need to move this somewhere else to make this cl nice.
Annie Sullivan . unresolved

Maybe `ContentfulPaintTimingInfo`?

File chrome/browser/page_load_metrics/page_load_metrics_initialize.cc
Line 225, Patchset 4 (Latest): }
Annie Sullivan . unresolved

One thing I'm not clear on is the lifetime of this observer and how it relates to BackForwardCachePageLoadMetricsObserver registered in RegisterCommonObservers above, and PrefetchPageLoadMetricsObserver above.

Open in Gerrit

Related details

Attention is currently required from:
  • Johannes Henkel
  • Michal Mocny
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I58fd45f922f0f53cc80567262e9e3f7edb01a182
    Gerrit-Change-Number: 6950612
    Gerrit-PatchSet: 4
    Gerrit-Owner: Johannes Henkel <joha...@chromium.org>
    Gerrit-Reviewer: Annie Sullivan <sull...@chromium.org>
    Gerrit-Reviewer: Michal Mocny <mmo...@chromium.org>
    Gerrit-Attention: Michal Mocny <mmo...@chromium.org>
    Gerrit-Attention: Johannes Henkel <joha...@chromium.org>
    Gerrit-Comment-Date: Mon, 15 Sep 2025 19:26:10 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Johannes Henkel (Gerrit)

    unread,
    Sep 15, 2025, 4:29:44 PM (6 days ago) Sep 15
    to Annie Sullivan, Michal Mocny, AyeAye, bmcquad...@chromium.org, loading-rev...@chromium.org, core-web-vita...@chromium.org, speed-metr...@chromium.org, speed-metrics...@chromium.org, csharris...@chromium.org
    Attention needed from Annie Sullivan and Michal Mocny

    Johannes Henkel voted and added 3 comments

    Votes added by Johannes Henkel

    Commit-Queue+1

    3 comments

    Patchset-level comments
    File-level comment, Patchset 8 (Latest):
    Johannes Henkel . resolved

    Thank you.

    Commit Message
    Line 12, Patchset 4:CalculateLCPEntropyBucket is now duplicated, may need to move this somewhere else to make this cl nice.
    Annie Sullivan . resolved

    Maybe `ContentfulPaintTimingInfo`?

    Johannes Henkel

    Done

    File chrome/browser/page_load_metrics/page_load_metrics_initialize.cc
    Annie Sullivan . unresolved

    One thing I'm not clear on is the lifetime of this observer and how it relates to BackForwardCachePageLoadMetricsObserver registered in RegisterCommonObservers above, and PrefetchPageLoadMetricsObserver above.

    Johannes Henkel

    Lifetime: It appears the observers are owned by the PageLoadTracker (in the observers_ field there), and they get destroyed when the tracker stops tracking. Which happens in void MetricsWebContentsObserver::DidFinishNavigation, in specific conditions. E.g., if the page is put into the bfcache then it looks that the tracker remains alive, presumably so that it can track some more later.

    https://source.chromium.org/chromium/chromium/src/+/main:components/page_load_metrics/browser/metrics_web_contents_observer.cc;l=654;bpv=1 - For the interesting conditions, I'm looking for the StopTracking calls in MetricsWebContentsObserver::DidFinishNavigation, since StopTracking will do observers_.clear(); and the only other way to delete an observer is when it returns STOP_OBSERVING from one of its methods - this happens in InvokeAndPruneObservers (https://source.chromium.org/chromium/chromium/src/+/main:components/page_load_metrics/browser/page_load_tracker.cc;l=833;bpv=1;bpt=1).

    I'm sort of thinking that these observers should be pretty light in logic, and just be about sending stuff to ukm.

    Perhaps one way to organize the code may be to make it so that each of these observers sends metrics for only a single ukm event, e.g., the new observer would only send data for the SoftNavigation UKM event. This is not the case in my changelist currently - it's also sending stuff for the PageLoad UKM event (the INP / CLS before soft navigation). Could change that.

    WDYT?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Annie Sullivan
    • Michal Mocny
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I58fd45f922f0f53cc80567262e9e3f7edb01a182
    Gerrit-Change-Number: 6950612
    Gerrit-PatchSet: 8
    Gerrit-Owner: Johannes Henkel <joha...@chromium.org>
    Gerrit-Reviewer: Annie Sullivan <sull...@chromium.org>
    Gerrit-Reviewer: Johannes Henkel <joha...@chromium.org>
    Gerrit-Reviewer: Michal Mocny <mmo...@chromium.org>
    Gerrit-Attention: Michal Mocny <mmo...@chromium.org>
    Gerrit-Attention: Annie Sullivan <sull...@chromium.org>
    Gerrit-Comment-Date: Mon, 15 Sep 2025 20:29:35 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Annie Sullivan <sull...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Annie Sullivan (Gerrit)

    unread,
    Sep 17, 2025, 8:47:17 AM (4 days ago) Sep 17
    to Johannes Henkel, Chromium LUCI CQ, Michal Mocny, AyeAye, bmcquad...@chromium.org, loading-rev...@chromium.org, core-web-vita...@chromium.org, speed-metr...@chromium.org, speed-metrics...@chromium.org, csharris...@chromium.org
    Attention needed from Johannes Henkel and Michal Mocny

    Annie Sullivan added 1 comment

    File chrome/browser/page_load_metrics/page_load_metrics_initialize.cc
    Annie Sullivan . unresolved

    One thing I'm not clear on is the lifetime of this observer and how it relates to BackForwardCachePageLoadMetricsObserver registered in RegisterCommonObservers above, and PrefetchPageLoadMetricsObserver above.

    Johannes Henkel

    Lifetime: It appears the observers are owned by the PageLoadTracker (in the observers_ field there), and they get destroyed when the tracker stops tracking. Which happens in void MetricsWebContentsObserver::DidFinishNavigation, in specific conditions. E.g., if the page is put into the bfcache then it looks that the tracker remains alive, presumably so that it can track some more later.

    https://source.chromium.org/chromium/chromium/src/+/main:components/page_load_metrics/browser/metrics_web_contents_observer.cc;l=654;bpv=1 - For the interesting conditions, I'm looking for the StopTracking calls in MetricsWebContentsObserver::DidFinishNavigation, since StopTracking will do observers_.clear(); and the only other way to delete an observer is when it returns STOP_OBSERVING from one of its methods - this happens in InvokeAndPruneObservers (https://source.chromium.org/chromium/chromium/src/+/main:components/page_load_metrics/browser/page_load_tracker.cc;l=833;bpv=1;bpt=1).

    I'm sort of thinking that these observers should be pretty light in logic, and just be about sending stuff to ukm.

    Perhaps one way to organize the code may be to make it so that each of these observers sends metrics for only a single ukm event, e.g., the new observer would only send data for the SoftNavigation UKM event. This is not the case in my changelist currently - it's also sending stuff for the PageLoad UKM event (the INP / CLS before soft navigation). Could change that.

    WDYT?

    Annie Sullivan

    Yeah, I definitely think having PageLoad before* events in the PageLoad observer, bfcache before* events in the bfcache observer, and SoftNavigation events in this observer is the way to go.

    I also think that currently, it's not a lot of duplicated code to write it that way.

    But when we look at all the timing issues I documented, fixing them all will require some code, and ideally that code runs at the PageLoadTracker level but maybe lives in its own class. This is why I'm hoping we can sketch out a bit around what the ideal solution looks like so we can iterate towards it.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Johannes Henkel
    • Michal Mocny
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I58fd45f922f0f53cc80567262e9e3f7edb01a182
    Gerrit-Change-Number: 6950612
    Gerrit-PatchSet: 8
    Gerrit-Owner: Johannes Henkel <joha...@chromium.org>
    Gerrit-Reviewer: Annie Sullivan <sull...@chromium.org>
    Gerrit-Reviewer: Johannes Henkel <joha...@chromium.org>
    Gerrit-Reviewer: Michal Mocny <mmo...@chromium.org>
    Gerrit-Attention: Michal Mocny <mmo...@chromium.org>
    Gerrit-Attention: Johannes Henkel <joha...@chromium.org>
    Gerrit-Comment-Date: Wed, 17 Sep 2025 12:47:08 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Annie Sullivan <sull...@chromium.org>
    Comment-In-Reply-To: Johannes Henkel <joha...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages