[soft navs] Record soft navs to correct URL in UKM. [chromium/src : main]

0 views
Skip to first unread message

Johannes Henkel (Gerrit)

unread,
Nov 12, 2025, 11:55:18 PM (2 days ago) Nov 12
to Daniel Cheng, Nate Chapin, Code Review Nudger, Annie Sullivan, Scott Haseley, Michal Mocny, Chromium LUCI CQ, AyeAye, kinuko...@chromium.org, blink-revi...@chromium.org, navigation...@chromium.org, creis...@chromium.org, alexmo...@chromium.org, loading...@chromium.org, gavinp...@chromium.org, blink-...@chromium.org, core-web-vita...@chromium.org, speed-metr...@chromium.org, csharris...@chromium.org, blink-re...@chromium.org, core-timi...@chromium.org, bmcquad...@chromium.org, loading-rev...@chromium.org, speed-metrics...@chromium.org
Attention needed from Annie Sullivan, Michal Mocny and Scott Haseley

Johannes Henkel added 2 comments

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

Redid this cl so now it uses a token to tie soft navs and same document navs together so that the correct URL gets logged. And Cl description now describes motivation, fix, and details. Ready for review. :-)

File third_party/blink/renderer/core/timing/soft_navigation_heuristics.cc
Line 312, Patchset 17:void SoftNavigationHeuristics::SameDocumentNavigationCommitted(
Johannes Henkel . resolved

Note to myself: This needs to be called at least for all committed same document navs in the main frame. I think at the moment we filter some out at the call site, e.g. the replacestate, we'll need to do the filtering in here so we can still get the count correctly... or do the count in the caller.

Johannes Henkel

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Annie Sullivan
  • Michal Mocny
  • Scott Haseley
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
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: I4adf5404200d2c473ae88b5eb2229c04ca348a31
Gerrit-Change-Number: 7108439
Gerrit-PatchSet: 33
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-Reviewer: Scott Haseley <shas...@chromium.org>
Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
Gerrit-CC: Daniel Cheng <dch...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Scott Haseley <shas...@chromium.org>
Gerrit-Attention: Annie Sullivan <sull...@chromium.org>
Gerrit-Attention: Michal Mocny <mmo...@chromium.org>
Gerrit-Comment-Date: Thu, 13 Nov 2025 04:55:04 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Johannes Henkel <joha...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Scott Haseley (Gerrit)

unread,
Nov 13, 2025, 1:33:10 PM (yesterday) Nov 13
to Johannes Henkel, Daniel Cheng, Nate Chapin, Code Review Nudger, Annie Sullivan, Michal Mocny, Chromium LUCI CQ, AyeAye, kinuko...@chromium.org, blink-revi...@chromium.org, navigation...@chromium.org, creis...@chromium.org, alexmo...@chromium.org, loading...@chromium.org, gavinp...@chromium.org, blink-...@chromium.org, core-web-vita...@chromium.org, speed-metr...@chromium.org, csharris...@chromium.org, blink-re...@chromium.org, core-timi...@chromium.org, bmcquad...@chromium.org, loading-rev...@chromium.org, speed-metrics...@chromium.org
Attention needed from Annie Sullivan, Johannes Henkel and Michal Mocny

Scott Haseley added 6 comments

File chrome/browser/page_load_metrics/observers/core/ukm_page_load_metrics_observer.cc
Line 644, Patchset 35: if (ukm_source_id == ukm::kInvalidSourceId) {
Scott Haseley . unresolved

In what cases will this happen?

File components/page_load_metrics/browser/page_load_tracker.cc
Line 658, Patchset 35: if (token.has_value() && !token->is_empty()) {
Scott Haseley . unresolved

In what cases will this fail?

Line 1395, Patchset 35: return ukm::kInvalidSourceId;
Scott Haseley . unresolved

Similarly, is this expected to happen?

File content/browser/renderer_host/navigation_request.cc
Line 1455, Patchset 35: /*same_document_navigation_token*/ std::nullopt);
Scott Haseley . unresolved

nit: to match the rest:

```suggestion
/*same_document_navigation_token=*/std::nullopt);
```
File content/browser/renderer_host/render_frame_host_impl.cc
Line 15651, Patchset 35: std::optional<base::UnguessableToken> same_document_navigation_token;
if (same_document_params) {
same_document_navigation_token =
same_document_params->same_document_navigation_token;
}
Scott Haseley . unresolved

Can you lift this block above the comment, to keep that with the relevant code?

Also, maybe check `is_same_document_navigation` instead, like the other checks above (I guess it's equivalent, but maybe for consistency)?

(and maybe match the ternary expression style, if you want.)

File third_party/blink/renderer/core/timing/soft_navigation_context.h
Line 151, Patchset 35: base::UnguessableToken same_document_navigation_token_;
Scott Haseley . unresolved

nit/IWYU: #include "base/unguessable_token.h" (here and elsewhere)?

(https://google.github.io/styleguide/cppguide.html#Include_What_You_Use)

Open in Gerrit

Related details

Attention is currently required from:
  • Annie Sullivan
  • 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
    • requirement is not satisfiedReview-Enforcement
    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: I4adf5404200d2c473ae88b5eb2229c04ca348a31
    Gerrit-Change-Number: 7108439
    Gerrit-PatchSet: 36
    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-Reviewer: Scott Haseley <shas...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Daniel Cheng <dch...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-Attention: Johannes Henkel <joha...@chromium.org>
    Gerrit-Attention: Annie Sullivan <sull...@chromium.org>
    Gerrit-Attention: Michal Mocny <mmo...@chromium.org>
    Gerrit-Comment-Date: Thu, 13 Nov 2025 18:32:58 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Scott Haseley (Gerrit)

    unread,
    Nov 13, 2025, 1:33:50 PM (yesterday) Nov 13
    to Johannes Henkel, Daniel Cheng, Nate Chapin, Code Review Nudger, Annie Sullivan, Michal Mocny, Chromium LUCI CQ, AyeAye, kinuko...@chromium.org, blink-revi...@chromium.org, navigation...@chromium.org, creis...@chromium.org, alexmo...@chromium.org, loading...@chromium.org, gavinp...@chromium.org, blink-...@chromium.org, core-web-vita...@chromium.org, speed-metr...@chromium.org, csharris...@chromium.org, blink-re...@chromium.org, core-timi...@chromium.org, bmcquad...@chromium.org, loading-rev...@chromium.org, speed-metrics...@chromium.org
    Attention needed from Annie Sullivan, Johannes Henkel and Michal Mocny

    Scott Haseley added 1 comment

    Patchset-level comments
    File-level comment, Patchset 36 (Latest):
    Scott Haseley . unresolved

    Does this also work for browser-inititated navs, like back button?

    Gerrit-Comment-Date: Thu, 13 Nov 2025 18:33:40 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Johannes Henkel (Gerrit)

    unread,
    4:56 AM (18 hours ago) 4:56 AM
    to Daniel Cheng, Nate Chapin, Code Review Nudger, Annie Sullivan, Scott Haseley, Michal Mocny, Chromium LUCI CQ, AyeAye, kinuko...@chromium.org, blink-revi...@chromium.org, navigation...@chromium.org, creis...@chromium.org, alexmo...@chromium.org, loading...@chromium.org, gavinp...@chromium.org, blink-...@chromium.org, core-web-vita...@chromium.org, speed-metr...@chromium.org, csharris...@chromium.org, blink-re...@chromium.org, core-timi...@chromium.org, bmcquad...@chromium.org, loading-rev...@chromium.org, speed-metrics...@chromium.org
    Attention needed from Annie Sullivan, Michal Mocny and Scott Haseley

    Johannes Henkel voted and added 7 comments

    Votes added by Johannes Henkel

    Commit-Queue+1

    7 comments

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

    Main update: I'm no longer adding the token in navigation_params.mojom, but rather, have it be a simple field in navigation_request.cc, and setting it in the browser just before the request gets destroyed. This way, the single location where the token gets created (in the renderer at commit time) can also cover navigations that originate in the browser, and the thing works for back/forward buttons now.

    PTAL

    File chrome/browser/page_load_metrics/observers/core/ukm_page_load_metrics_observer.cc
    Line 644, Patchset 35: if (ukm_source_id == ukm::kInvalidSourceId) {
    Scott Haseley . unresolved

    In what cases will this happen?

    Johannes Henkel

    I'm thinking it's more robust, since the PageLoadTracker could return this invalid source id, if the renderer sent a corrupt soft_navigation_metrics message, or if the timing is way to early (also due to corruption). I don't think these are likely / I haven't exercised this, it's just based on the idea to not trust stuff coming from the renderer.

    File components/page_load_metrics/browser/page_load_tracker.cc
    Line 658, Patchset 35: if (token.has_value() && !token->is_empty()) {
    Scott Haseley . unresolved

    In what cases will this fail?

    Johannes Henkel

    Since I'm now setting the thingy unconditionally for navigation_request objects that are about to get destroyed, I'm expecting this to not fail, so converted it to checks.

    Line 1395, Patchset 35: return ukm::kInvalidSourceId;
    Scott Haseley . unresolved

    Similarly, is this expected to happen?

    Johannes Henkel

    This could happen if a corrupted soft_navigation_metrics message is sent from a renderer. So, I think it's best to be graceful here.

    Previously, {potential,previous}_soft_navigation_id_ were initialized with ukm::kInvalidSourceId by default, so I think a corrupt renderer could also have triggered this return value (e.g. if the soft navs metrics message was received unexpectedly early).

    I don't think these are likely / I haven't exercised this, it's just based on the idea to not trust stuff coming from the renderer.

    File content/browser/renderer_host/navigation_request.cc
    Line 1455, Patchset 35: /*same_document_navigation_token*/ std::nullopt);
    Scott Haseley . resolved

    nit: to match the rest:

    ```suggestion
    /*same_document_navigation_token=*/std::nullopt);
    ```
    Johannes Henkel

    parameter is gone

    File content/browser/renderer_host/render_frame_host_impl.cc
    Line 15651, Patchset 35: std::optional<base::UnguessableToken> same_document_navigation_token;
    if (same_document_params) {
    same_document_navigation_token =
    same_document_params->same_document_navigation_token;
    }
    Scott Haseley . resolved

    Can you lift this block above the comment, to keep that with the relevant code?

    Also, maybe check `is_same_document_navigation` instead, like the other checks above (I guess it's equivalent, but maybe for consistency)?

    (and maybe match the ternary expression style, if you want.)

    Johannes Henkel

    I'm using the is_same_document_navigation check now, but instead of
    trying to set the parameter at construction time here, I'm now
    tagging the navigation_request after this section with
    the token; this way it covers both the newly constructed
    requests and those that already existed (because they were
    started in the browser like the back/forward buttons.

    File third_party/blink/renderer/core/timing/soft_navigation_context.h
    Line 151, Patchset 35: base::UnguessableToken same_document_navigation_token_;
    Scott Haseley . resolved

    nit/IWYU: #include "base/unguessable_token.h" (here and elsewhere)?

    (https://google.github.io/styleguide/cppguide.html#Include_What_You_Use)

    Johannes Henkel

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Annie Sullivan
    • Michal Mocny
    • Scott Haseley
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    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: I4adf5404200d2c473ae88b5eb2229c04ca348a31
    Gerrit-Change-Number: 7108439
    Gerrit-PatchSet: 39
    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-Reviewer: Scott Haseley <shas...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Daniel Cheng <dch...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-Attention: Scott Haseley <shas...@chromium.org>
    Gerrit-Attention: Annie Sullivan <sull...@chromium.org>
    Gerrit-Attention: Michal Mocny <mmo...@chromium.org>
    Gerrit-Comment-Date: Fri, 14 Nov 2025 09:56:36 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Scott Haseley <shas...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Scott Haseley (Gerrit)

    unread,
    12:52 PM (10 hours ago) 12:52 PM
    to Johannes Henkel, Daniel Cheng, Nate Chapin, Code Review Nudger, Annie Sullivan, Michal Mocny, Chromium LUCI CQ, AyeAye, kinuko...@chromium.org, blink-revi...@chromium.org, navigation...@chromium.org, creis...@chromium.org, alexmo...@chromium.org, loading...@chromium.org, gavinp...@chromium.org, blink-...@chromium.org, core-web-vita...@chromium.org, speed-metr...@chromium.org, csharris...@chromium.org, blink-re...@chromium.org, core-timi...@chromium.org, bmcquad...@chromium.org, loading-rev...@chromium.org, speed-metrics...@chromium.org
    Attention needed from Annie Sullivan, Johannes Henkel and Michal Mocny

    Scott Haseley added 3 comments

    Patchset-level comments
    Scott Haseley . resolved

    I think this works, but I'll take a closer look once the bots are green.

    File chrome/browser/page_load_metrics/observers/core/ukm_page_load_metrics_observer.cc
    Line 644, Patchset 35: if (ukm_source_id == ukm::kInvalidSourceId) {
    Scott Haseley . resolved

    In what cases will this happen?

    Johannes Henkel

    I'm thinking it's more robust, since the PageLoadTracker could return this invalid source id, if the renderer sent a corrupt soft_navigation_metrics message, or if the timing is way to early (also due to corruption). I don't think these are likely / I haven't exercised this, it's just based on the idea to not trust stuff coming from the renderer.

    Scott Haseley

    ACK, makes sense, and crashing the browser would be bad :). Just making sure it's needed, since otherwise it could mask a bug, i.e. a case we didn't anticipate, that we won't find out about.

    File components/page_load_metrics/browser/page_load_tracker.cc
    Line 658, Patchset 35: if (token.has_value() && !token->is_empty()) {
    Scott Haseley . unresolved

    In what cases will this fail?

    Johannes Henkel

    Since I'm now setting the thingy unconditionally for navigation_request objects that are about to get destroyed, I'm expecting this to not fail, so converted it to checks.

    Scott Haseley

    Looks like maybe it can still be null in tests, so maybe it's okay to document that and ignore it? Also, to your other point, should you not trust this either since it's coming from the renderer (I'm not sure the what's typical to do for this)?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Annie Sullivan
    • 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
    • requirement is not satisfiedReview-Enforcement
    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: I4adf5404200d2c473ae88b5eb2229c04ca348a31
    Gerrit-Change-Number: 7108439
    Gerrit-PatchSet: 39
    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-Reviewer: Scott Haseley <shas...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Daniel Cheng <dch...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-Attention: Johannes Henkel <joha...@chromium.org>
    Gerrit-Attention: Annie Sullivan <sull...@chromium.org>
    Gerrit-Attention: Michal Mocny <mmo...@chromium.org>
    Gerrit-Comment-Date: Fri, 14 Nov 2025 17:52:27 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Johannes Henkel <joha...@chromium.org>
    Comment-In-Reply-To: Scott Haseley <shas...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Johannes Henkel (Gerrit)

    unread,
    2:26 PM (9 hours ago) 2:26 PM
    to Daniel Cheng, Nate Chapin, Code Review Nudger, Annie Sullivan, Scott Haseley, Michal Mocny, Chromium LUCI CQ, AyeAye, kinuko...@chromium.org, blink-revi...@chromium.org, navigation...@chromium.org, creis...@chromium.org, alexmo...@chromium.org, loading...@chromium.org, gavinp...@chromium.org, blink-...@chromium.org, core-web-vita...@chromium.org, speed-metr...@chromium.org, csharris...@chromium.org, blink-re...@chromium.org, core-timi...@chromium.org, bmcquad...@chromium.org, loading-rev...@chromium.org, speed-metrics...@chromium.org
    Attention needed from Annie Sullivan, Michal Mocny and Scott Haseley

    Johannes Henkel added 1 comment

    File components/page_load_metrics/browser/page_load_tracker.cc
    Line 658, Patchset 35: if (token.has_value() && !token->is_empty()) {
    Scott Haseley . unresolved

    In what cases will this fail?

    Johannes Henkel

    Since I'm now setting the thingy unconditionally for navigation_request objects that are about to get destroyed, I'm expecting this to not fail, so converted it to checks.

    Scott Haseley

    Looks like maybe it can still be null in tests, so maybe it's okay to document that and ignore it? Also, to your other point, should you not trust this either since it's coming from the renderer (I'm not sure the what's typical to do for this)?

    Johannes Henkel

    I think it's OK to trust this one, reasons being:
    (1) if we get into this code path, there must be a DidCommitSameDocumentNavigationParams. Even though this thing came from the renderer in practice, I think since the field is non-optional in these params, I can also safely assume that it's not null, and further, I can assume that it's not empty (UnguesableToken::is_empty() check) because empty unguessable tokens wouldn't serialize and I think verifying that sort of thing is up to the IPC layer.
    (2) On the other hand, getting the token into the navigation_handle object, which is under the hood a NavigationRequest, that happens in the browser (in render_frame_host_impl.cc), so that's why I think it's OK to check-fail if that went wrong.

    The situation with the other place in this change where I want to be robust and allow the invalid ukm source id to be passed is different, since that condition would not be caught by the IPC layer, in a sense there'd be structurally valid messages but at the IPC layer but we'd fail to match up the soft nav with the same document nav due to timing or the wrong token or stuff like that.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Annie Sullivan
    • Michal Mocny
    • Scott Haseley
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    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: I4adf5404200d2c473ae88b5eb2229c04ca348a31
    Gerrit-Change-Number: 7108439
    Gerrit-PatchSet: 40
    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-Reviewer: Scott Haseley <shas...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Daniel Cheng <dch...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-Attention: Scott Haseley <shas...@chromium.org>
    Gerrit-Attention: Annie Sullivan <sull...@chromium.org>
    Gerrit-Attention: Michal Mocny <mmo...@chromium.org>
    Gerrit-Comment-Date: Fri, 14 Nov 2025 19:26:24 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Scott Haseley (Gerrit)

    unread,
    7:30 PM (4 hours ago) 7:30 PM
    to Johannes Henkel, Daniel Cheng, Nate Chapin, Code Review Nudger, Annie Sullivan, Michal Mocny, Chromium LUCI CQ, AyeAye, kinuko...@chromium.org, blink-revi...@chromium.org, navigation...@chromium.org, creis...@chromium.org, alexmo...@chromium.org, loading...@chromium.org, gavinp...@chromium.org, blink-...@chromium.org, core-web-vita...@chromium.org, speed-metr...@chromium.org, csharris...@chromium.org, blink-re...@chromium.org, core-timi...@chromium.org, bmcquad...@chromium.org, loading-rev...@chromium.org, speed-metrics...@chromium.org
    Attention needed from Annie Sullivan, Johannes Henkel and Michal Mocny

    Scott Haseley voted and added 8 comments

    Votes added by Scott Haseley

    Code-Review+1

    8 comments

    Patchset-level comments
    File-level comment, Patchset 42 (Latest):
    Scott Haseley . resolved

    Nice! I like this approach; this feels pretty clean. Hopefully navigation folks agree :). LGTM % test for back/forward, which we should probably make sure we have coverage on.

    Commit Message
    Line 14, Patchset 42 (Latest):- For each soft navigation we detect, there's exactly one corresponding same-document navigation: it's the initial URL change caused by the interaction that triggered the soft navigation.
    Scott Haseley . unresolved

    nit: can you format the CL description? There are a bunch of long lines > 72 char.

    Line 34, Patchset 42 (Latest):Pointers for reading the cl:
    Scott Haseley . unresolved

    nit: for the commit message, it might be better to give a shorter/concise overview of the plumbing/flow?

    Line 114, Patchset 42 (Latest):covers a portion of this behavior and continues to pass.
    Scott Haseley . unresolved

    \o/

    It sounds like you found some holes in testing with back/forward though? It would be probably be good to exercise that path as well here, or in a prequel CL?

    Line 117, Patchset 42 (Latest):that UKM would attribute to the soft navigations, and surfed a few sites
    Scott Haseley . unresolved

    nit: this bit might not be needed in the commit description?

    File components/page_load_metrics/browser/page_load_tracker.cc
    Line 658, Patchset 35: if (token.has_value() && !token->is_empty()) {
    Scott Haseley . resolved

    In what cases will this fail?

    Johannes Henkel

    Since I'm now setting the thingy unconditionally for navigation_request objects that are about to get destroyed, I'm expecting this to not fail, so converted it to checks.

    Scott Haseley

    Looks like maybe it can still be null in tests, so maybe it's okay to document that and ignore it? Also, to your other point, should you not trust this either since it's coming from the renderer (I'm not sure the what's typical to do for this)?

    Johannes Henkel

    I think it's OK to trust this one, reasons being:
    (1) if we get into this code path, there must be a DidCommitSameDocumentNavigationParams. Even though this thing came from the renderer in practice, I think since the field is non-optional in these params, I can also safely assume that it's not null, and further, I can assume that it's not empty (UnguesableToken::is_empty() check) because empty unguessable tokens wouldn't serialize and I think verifying that sort of thing is up to the IPC layer.
    (2) On the other hand, getting the token into the navigation_handle object, which is under the hood a NavigationRequest, that happens in the browser (in render_frame_host_impl.cc), so that's why I think it's OK to check-fail if that went wrong.

    The situation with the other place in this change where I want to be robust and allow the invalid ukm source id to be passed is different, since that condition would not be caught by the IPC layer, in a sense there'd be structurally valid messages but at the IPC layer but we'd fail to match up the soft nav with the same document nav due to timing or the wrong token or stuff like that.

    Scott Haseley

    Done

    Line 660, Patchset 42 (Latest): source_id_by_same_document_navigation_.try_emplace(
    Scott Haseley . unresolved

    Do we need to handle the case where try_emplace fails? Probably not? Under normal circumstances this will never happen, but wondering how you want to handle the untrusted renderer case, especially when that's the thing generating the token?

    Line 1395, Patchset 35: return ukm::kInvalidSourceId;
    Scott Haseley . resolved

    Similarly, is this expected to happen?

    Johannes Henkel

    This could happen if a corrupted soft_navigation_metrics message is sent from a renderer. So, I think it's best to be graceful here.

    Previously, {potential,previous}_soft_navigation_id_ were initialized with ukm::kInvalidSourceId by default, so I think a corrupt renderer could also have triggered this return value (e.g. if the soft navs metrics message was received unexpectedly early).

    I don't think these are likely / I haven't exercised this, it's just based on the idea to not trust stuff coming from the renderer.

    Scott Haseley

    Acknowledged

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Annie Sullivan
    • Johannes Henkel
    • Michal Mocny
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      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: I4adf5404200d2c473ae88b5eb2229c04ca348a31
      Gerrit-Change-Number: 7108439
      Gerrit-PatchSet: 42
      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-Reviewer: Scott Haseley <shas...@chromium.org>
      Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
      Gerrit-CC: Daniel Cheng <dch...@chromium.org>
      Gerrit-CC: Nate Chapin <jap...@chromium.org>
      Gerrit-Attention: Johannes Henkel <joha...@chromium.org>
      Gerrit-Attention: Annie Sullivan <sull...@chromium.org>
      Gerrit-Attention: Michal Mocny <mmo...@chromium.org>
      Gerrit-Comment-Date: Sat, 15 Nov 2025 00:30:12 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages