Skip to content

Commit 182be03

Browse files
[soft navs] Make PerformanceEntry.navigationId a number.
https://w3c.github.io/performance-timeline/ specifies navigationId to be a number, whereas Chromium currently implements it as a string. This change fixes that. The "algorithm" for making a navigation id is implemented in navigation_id_generator.cc, with commentary and unittest. Updating the spec remains a todo after this lands. Notes: 1) In largest_contentful_paint_calculator, there's a pre-existing "navigationId" in for the performance trace entries. I'm leaving this alone (slightly undoing the mixup there), but adding the performance timeline spec related ID as performanceTimelineNavigationId. The idea is that this will allow users of the trace to find corresponding PerformanceEntry instances e.g. from RUM data. 2) For the IDL file, the field is unsigned long long, just like it is in the spec. However, the C++ implementation uses uint32_t, because values above std::limits<int32_t>::max() don't make much sense for Javascript / JSON APIs. 3) I'll be preparing a Github PR to align the spec and this change w3c/performance-timeline#219; the PR needs more updating after this edit, so please consider that WIP for now. Implementation Details: The (simple) algorithm for randomly creating and incrementing navigation ids is in navigation_id_generator{.h,.cc,_test.cc}. It's a field of window_performance.{h,cc}, which is convenient in that hard navigations that would reset the performance object will also create a randomly initialized navigation id, whereas for soft navigations (and bfcache restores if enabled), we'll trigger the small increment. There's also a performance object that's not associated with a local dom window, and this will dole out the default navigation id value, which is 0. One of the constructors for PerformanceEntry now delegates to the other one; and both have the navigation_id parameter there, and then invoking that constructor by all subclasses, passing in the navigation id. This is relatively simple and better than getting it from the local dom window, because these things get instantiated by a performance object / when there's a performance object around, which now has the navigation id generator as a field. I added a new test, third_party/blink/web_tests/http/tests/inspector-protocol/tracing/performance-entry-navigation-id.js; this exercises the navigation id for situations that we care about. We actually don't care about situations with empty documents, because they don't involve interesting performance entries. To answer the question what happens with opening a window and then reusing that for a document, I added two lines to PerformanceLifetimeTest.SurviveContextSwitch in window_performance_test.cc. Bug: 421337393 Change-Id: Ia669a3f3eb201d491dafd49e488aa69558ecfd99 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6604387 Reviewed-by: Michal Mocny <[email protected]> Reviewed-by: Scott Haseley <[email protected]> Reviewed-by: Dave Tapuska <[email protected]> Commit-Queue: Johannes Henkel <[email protected]> Cr-Commit-Position: refs/heads/main@{#1485889}
1 parent 4424f59 commit 182be03

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

performance-timeline/navigation-id-worker-created-entries.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
worker.postMessage('');
1919
});
2020

21-
assert_equals(navigationId.length, 0,
22-
'Navigation id of performance entries created by a worker should be empty.');
23-
}, 'Navigation id of performance entries created by workers should be empty');
21+
assert_equals(navigationId, 0, '0 indicates the absence of a navigation id.');
22+
}, 'Navigation id of performance entries created by workers should be 0.');
2423
</script>
2524
</body>
2625

0 commit comments

Comments
 (0)