Expose initiator-url in resourceTiming for more resources [chromium/src : main]

0 views
Skip to first unread message

Scott Haseley (Gerrit)

unread,
Sep 26, 2025, 3:06:50 PMSep 26
to Guohui Deng, Chromium LUCI CQ, Alexis Menard, chromium...@chromium.org, Olga Gerchikov, Nate Chapin, blink-revie...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, chikamu...@chromium.org, core-timi...@chromium.org, ddrone...@google.com, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org, scheduler-...@chromium.org, speed-metrics...@chromium.org, web-schedulin...@chromium.org
Attention needed from Guohui Deng

Scott Haseley added 14 comments

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

Nice! I didn't get through the tests yet, but implementation is looking pretty reasonable.

File base/tracing/protos/chrome_track_event.proto
Line 43, Patchset 1 (Latest): TASK_SCOPE_RESOURCE_TIMING = 10;
Scott Haseley . unresolved

These shouldn't be renumbered, please move the new one to the end.

File third_party/blink/renderer/core/html/html_frame_owner_element.cc
Line 697, Patchset 1 (Latest): v8::Isolate* isolate = v8::Isolate::TryGetCurrent();
Scott Haseley . unresolved

I think this block needs to be flag-guarded behind the experimental feature flag.

Line 697, Patchset 1 (Latest): v8::Isolate* isolate = v8::Isolate::TryGetCurrent();
Scott Haseley . unresolved

Is this duplicated in the other file? It might be nice to have a helper method somewhere, maybe a static method in the new class?

Line 706, Patchset 1 (Latest): if (resource_timing_context) {
Scott Haseley . unresolved

Wha happens if this is null and `initiator_url` ends up empty, will it use a fallback somewhere else, or is intended to be empty for now?

File third_party/blink/renderer/core/loader/frame_fetch_context.cc
Line 472, Patchset 1 (Latest):void FrameFetchContext::FillInitiatorInfo(FetchInitiatorInfo& initiator_info) {
Scott Haseley . unresolved

nit: It might be worth adding `CHECK(RuntimeEnabledFeatures::ResourceTimingInitiatorEnabled())` to document that this is only called with an experimental feature enabled.

Line 475, Patchset 1 (Latest): // Initiator is a imported js file.
Scott Haseley . unresolved
```suggestion
// Initiator is an imported js file.
```
Line 489, Patchset 1 (Latest): // The initiator is a JS.
Scott Haseley . unresolved

Can you expand on this comment? I think this means that we're assuming JS is running because a v8::Context was entered?

Also, is this always guaranteed to be called on the main/worker thread? Just wondering if you'd ever expect `isolate` to be null, and in what situations, since IIUC we Enter() the isolate during init (but only on relevant threads).

File third_party/blink/renderer/core/scheduler/task_attribution_tracker_impl.cc
Line 127, Patchset 1 (Latest): TaskAttributionInfo* current_task_state = CurrentTaskState();
Scott Haseley . unresolved

What about web scheduling task state? For soft navs, we can get away with overwriting this because we know this is only called just prior to dispatching input.

File third_party/blink/renderer/core/scheduler/task_attribution_util.h
Line 60, Patchset 1 (Latest): // `tracker` is null if `context` is not a Window or if
Scott Haseley . unresolved

Is this a problem for resource timing? PerformanceResourceTiming is available on workers.

File third_party/blink/renderer/core/script/pending_script.cc
Line 179, Patchset 1 (Latest): // 1. No plan to support `InitiatorUrl` tracking for scripts generated by
// document.write();
// 2. Tracking `InitiatorUrl` for scripts generated by document.write() is
// Not compatible with test
// `wpt_internal/task-tracking/track-doc-write.html`.
Scott Haseley . unresolved

Seems like (1) is a design decision, and (2) is a bug. If (2) is something that needs to be addressed, I'd link to a crbug, otherwise I don't think this needs to be commented here. I'd suggest rewriting the comment to focus on why document.write() is not supported, or just put simply that the API does not support document.write() (ideally with a link to an explainer section or something).

Line 190, Patchset 1 (Latest): task_attribution_resource_timing_scope =
Scott Haseley . unresolved

This should be flag-guarded as well.

File third_party/blink/renderer/core/timing/resource_timing_context.h
Line 1, Patchset 1 (Latest):#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_TIMING_RESOURCE_TIMING_CONTEXT_H_
Scott Haseley . unresolved

This needs the copyright boilerplate.

File third_party/blink/renderer/platform/scheduler/public/task_attribution_info.h
Line 31, Patchset 1 (Latest): // Returns the `ResourceTimingContext` associated with the task state, which
Scott Haseley . unresolved

Please add a line break between methods.

Open in Gerrit

Related details

Attention is currently required from:
  • Guohui Deng
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: I125e62d488eec5a85f8afa6cd61c399183c56d86
Gerrit-Change-Number: 6960132
Gerrit-PatchSet: 1
Gerrit-Owner: Guohui Deng <guohu...@microsoft.com>
Gerrit-Reviewer: Guohui Deng <guohu...@microsoft.com>
Gerrit-Reviewer: Scott Haseley <shas...@chromium.org>
Gerrit-CC: Alexis Menard <alexis...@intel.com>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Olga Gerchikov <gerc...@microsoft.com>
Gerrit-Attention: Guohui Deng <guohu...@microsoft.com>
Gerrit-Comment-Date: Fri, 26 Sep 2025 19:06:40 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Guohui Deng (Gerrit)

unread,
Oct 16, 2025, 6:51:19 PM (3 days ago) Oct 16
to Scott Haseley, Chromium LUCI CQ, Alexis Menard, chromium...@chromium.org, Olga Gerchikov, Nate Chapin, blink-revie...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, chikamu...@chromium.org, core-timi...@chromium.org, ddrone...@google.com, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org, scheduler-...@chromium.org, speed-metrics...@chromium.org, web-schedulin...@chromium.org
Attention needed from Scott Haseley

Guohui Deng added 14 comments

Patchset-level comments
File-level comment, Patchset 4 (Latest):
Guohui Deng . resolved

I think I fixed the problems Scot pointed out but I also added new code, `initiator_helper` and adding `ResourceTimingContext` to `WebSchedulingTaskState`

Thanks.

File base/tracing/protos/chrome_track_event.proto
Line 43, Patchset 1: TASK_SCOPE_RESOURCE_TIMING = 10;
Scott Haseley . resolved

These shouldn't be renumbered, please move the new one to the end.

Guohui Deng

Done

File third_party/blink/renderer/core/html/html_frame_owner_element.cc
Line 697, Patchset 1: v8::Isolate* isolate = v8::Isolate::TryGetCurrent();
Scott Haseley . resolved

I think this block needs to be flag-guarded behind the experimental feature flag.

Guohui Deng

Done

Line 697, Patchset 1: v8::Isolate* isolate = v8::Isolate::TryGetCurrent();
Scott Haseley . resolved

Is this duplicated in the other file? It might be nice to have a helper method somewhere, maybe a static method in the new class?

Guohui Deng

Done. I put it to InitiatorHelper:GetIsolateIfRunningScript().

Line 706, Patchset 1: if (resource_timing_context) {
Scott Haseley . unresolved

Wha happens if this is null and `initiator_url` ends up empty, will it use a fallback somewhere else, or is intended to be empty for now?

Guohui Deng

For now, `InitiatorUrl` field in resource timing is an empty string if there is no valid value. An invalid |initiator_url| is converted to an empty string in `PerformanceResourceTiming::initiatorUrl()`

So it doesn't distinguish between 1) lack of implementation in UA 2) the "initiator" really doesn't exist (like the main page loaded by user action)

I expect it to remain that way until we find user case for it.

File third_party/blink/renderer/core/loader/frame_fetch_context.cc
Line 472, Patchset 1:void FrameFetchContext::FillInitiatorInfo(FetchInitiatorInfo& initiator_info) {
Scott Haseley . resolved

nit: It might be worth adding `CHECK(RuntimeEnabledFeatures::ResourceTimingInitiatorEnabled())` to document that this is only called with an experimental feature enabled.

Guohui Deng

Done

Line 475, Patchset 1: // Initiator is a imported js file.
Scott Haseley . resolved
```suggestion
// Initiator is an imported js file.
```
Guohui Deng

Done

Line 489, Patchset 1: // The initiator is a JS.
Scott Haseley . unresolved

Can you expand on this comment? I think this means that we're assuming JS is running because a v8::Context was entered?

Also, is this always guaranteed to be called on the main/worker thread? Just wondering if you'd ever expect `isolate` to be null, and in what situations, since IIUC we Enter() the isolate during init (but only on relevant threads).

Guohui Deng

I made a helper function `third_party/blink/renderer/core/loader/initiator_helper.h` and I put the comments there. And I added an extra condition to align with how the Devtools determines if the initiator is JS.

File third_party/blink/renderer/core/scheduler/task_attribution_tracker_impl.cc
Line 127, Patchset 1: TaskAttributionInfo* current_task_state = CurrentTaskState();
Scott Haseley . unresolved

What about web scheduling task state? For soft navs, we can get away with overwriting this because we know this is only called just prior to dispatching input.

Guohui Deng

oops, I missed it big time. Now I test if the Current task state is an instance of TaskAttributionInfoImpl or WebSchedulingTaskState, and then overwrite |resource_timing_context| accordingly.

File third_party/blink/renderer/core/scheduler/task_attribution_util.h
Line 60, Patchset 1: // `tracker` is null if `context` is not a Window or if
Scott Haseley . unresolved

Is this a problem for resource timing? PerformanceResourceTiming is available on workers.

Guohui Deng

I removed the comments. FYI at this CL we still not tracking the resource `initiator_url` in worker. But I plan to support that.

File third_party/blink/renderer/core/script/pending_script.cc
Line 179, Patchset 1: // 1. No plan to support `InitiatorUrl` tracking for scripts generated by

// document.write();
// 2. Tracking `InitiatorUrl` for scripts generated by document.write() is
// Not compatible with test
// `wpt_internal/task-tracking/track-doc-write.html`.
Scott Haseley . resolved

Seems like (1) is a design decision, and (2) is a bug. If (2) is something that needs to be addressed, I'd link to a crbug, otherwise I don't think this needs to be commented here. I'd suggest rewriting the comment to focus on why document.write() is not supported, or just put simply that the API does not support document.write() (ideally with a link to an explainer section or something).

Guohui Deng

Done

Line 190, Patchset 1: task_attribution_resource_timing_scope =
Scott Haseley . resolved

This should be flag-guarded as well.

Guohui Deng

Done

File third_party/blink/renderer/core/timing/resource_timing_context.h
Line 1, Patchset 1:#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_TIMING_RESOURCE_TIMING_CONTEXT_H_
Scott Haseley . resolved

This needs the copyright boilerplate.

Guohui Deng

Done

File third_party/blink/renderer/platform/scheduler/public/task_attribution_info.h
Line 31, Patchset 1: // Returns the `ResourceTimingContext` associated with the task state, which
Scott Haseley . resolved

Please add a line break between methods.

Guohui Deng

Done

Open in Gerrit

Related details

Attention is currently required from:
  • 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: I125e62d488eec5a85f8afa6cd61c399183c56d86
    Gerrit-Change-Number: 6960132
    Gerrit-PatchSet: 4
    Gerrit-Owner: Guohui Deng <guohu...@microsoft.com>
    Gerrit-Reviewer: Guohui Deng <guohu...@microsoft.com>
    Gerrit-Reviewer: Scott Haseley <shas...@chromium.org>
    Gerrit-CC: Alexis Menard <alexis...@intel.com>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Olga Gerchikov <gerc...@microsoft.com>
    Gerrit-Attention: Scott Haseley <shas...@chromium.org>
    Gerrit-Comment-Date: Thu, 16 Oct 2025 22:51:10 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Scott Haseley <shas...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages