Skip to content

Set timeOrigin to align with spec, even when BCG switches take place. - #66437

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
yoavweiss:bcg_performance_timestamps
Jul 28, 2026
Merged

Set timeOrigin to align with spec, even when BCG switches take place.#66437
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
yoavweiss:bcg_performance_timestamps

Conversation

@yoavweiss

@yoavweiss yoavweiss commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

f8352ee

Set timeOrigin to align with spec, even when BCG switches take place.
https://bugs.webkit.org/show_bug.cgi?id=316291

Reviewed by Alex Christensen.

Currently the timeOrigin is set when the final process starts the navigation request load.
But in the case of a BCG switch, that load ends up resuming/reusing a load that was already
started in the previous process.
This PR pipes the relevant information over, so that the `timeOrigin` will be properly set
in these cases.

This is fine from a w3c/navigation-timing#160 perspective, because as
against this by obfuscating more than just the redirect data for cross-origin redirects.

Test progression.

* Source/WebCore/loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::startLoadingMainResource): Set the original navigation time if provided.
* Source/WebCore/loader/DocumentLoader.h:
(WebCore::DocumentLoader::setOriginalNavigationStartTime): Setter.
* Source/WebCore/loader/FrameLoadRequest.h:
(WebCore::FrameLoadRequest::originalNavigationStartTime const): Getter.
(WebCore::FrameLoadRequest::setOriginalNavigationStartTime): Setter.
* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::load): Set the originalNavigationStartTime from the request.
* Source/WebCore/loader/ResourceLoadTiming.h:
(WebCore::ResourceLoadTiming::setStartTime): Setter.
* Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h:
* Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.serialization.in:
* Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::sendDidReceiveResponsePotentiallyInNewBrowsingContextGroup): Add originalNavigationStartTime as parameter to the BCG switch.
(WebKit::NetworkResourceLoader::sendDidReceiveResponseWithPotentialProcessSwap):
* Source/WebKit/Shared/LoadParameters.h:
* Source/WebKit/Shared/LoadParameters.serialization.in:
* Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::triggerBrowsingContextGroupSwitchForNavigation): Add originalNavigationStartTime as parameter to the BCG switch.
(WebKit::NetworkProcessProxy::considerProcessSwapForNavigationResponse):
* Source/WebKit/UIProcess/Network/NetworkProcessProxy.h:
* Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in:
* Source/WebKit/UIProcess/ProvisionalPageProxy.cpp:
(WebKit::ProvisionalPageProxy::loadRequest): Add originalNavigationStartTime as parameter to the BCG switch.
* Source/WebKit/UIProcess/ProvisionalPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::loadRequestWithNavigationShared): Set the originalNavigationStartTime in parameters.
(WebKit::WebPageProxy::continueNavigationInNewProcess): Pass originalNavigationStartTime.
(WebKit::WebPageProxy::triggerBrowsingContextGroupSwitchForNavigation): Pass originalNavigationStartTime.
(WebKit::WebPageProxy::loadRequest):
(WebKit::WebPageProxy::receivedNavigationActionPolicyDecision):
(WebKit::WebPageProxy::performProcessSwapForNavigationResponse):
(WebKit::WebPageProxy::triggerProcessSwapForEnhancedSecurity):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess): Set the originalNavigationStartTime from the documentLoader's startTime.
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::loadRequest): Set the originalNavigationStartTime from the load parameters.
* LayoutTests/imported/w3c/web-platform-tests/navigation-timing/response-start-after-coop-bcg-switch-no-tao.tentative.https-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/navigation-timing/response-start-after-coop-bcg-switch-no-tao.tentative.https.html: Added.

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

14f69bd

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt 🧪 api-mac-debug
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk3-libwebrtc
✅ 🛠 ios-safer-cpp 🧪 mac-AS-debug-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 mac-wk2-stress ✅ 🧪 gtk-wk2
✅ 🛠 🧪 merge ✅ 🛠 vision-sim 🧪 mac-intel-wk2 ✅ 🧪 api-gtk
✅ 🧪 vision-wk2 ✅ 🛠 mac-safer-cpp ✅ 🛠 playstation
✅ 🛠 tv ✅ 🧪 mac-site-isolation
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@yoavweiss
yoavweiss requested a review from cdumez as a code owner June 4, 2026 08:34
@yoavweiss yoavweiss self-assigned this Jun 4, 2026
@yoavweiss yoavweiss added the New Bugs Unclassified bugs are placed in this component until the correct component can be determined. label Jun 4, 2026
@yoavweiss
yoavweiss marked this pull request as draft June 4, 2026 08:35
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 4, 2026
@yoavweiss yoavweiss removed the merging-blocked Applied to prevent a change from being merged label Jun 4, 2026
@yoavweiss
yoavweiss force-pushed the bcg_performance_timestamps branch from 784fdba to 7bc2c8c Compare June 4, 2026 11:42
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 4, 2026
@yoavweiss yoavweiss removed the merging-blocked Applied to prevent a change from being merged label Jun 4, 2026
@yoavweiss
yoavweiss force-pushed the bcg_performance_timestamps branch from 7bc2c8c to 7bf8b78 Compare June 4, 2026 12:30
@yoavweiss
yoavweiss force-pushed the bcg_performance_timestamps branch from 7bf8b78 to bd52538 Compare June 4, 2026 20:01
@yoavweiss
yoavweiss marked this pull request as ready for review June 4, 2026 20:02
@yoavweiss
yoavweiss requested a review from annevk June 4, 2026 20:03
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 4, 2026
@annevk

annevk commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

I think it makes sense that we report similar times with and without a BCG switch, but we should not add new tests for navigation redirects as part of this. And if they are added elsewhere, they should probably be tentative for now.

@yoavweiss yoavweiss removed the merging-blocked Applied to prevent a change from being merged label Jun 26, 2026
@yoavweiss
yoavweiss force-pushed the bcg_performance_timestamps branch from bd52538 to 3fac22e Compare June 26, 2026 11:35
@yoavweiss

Copy link
Copy Markdown
Contributor Author

I think it makes sense that we report similar times with and without a BCG switch, but we should not add new tests for navigation redirects as part of this. And if they are added elsewhere, they should probably be tentative for now.

Tests added to WPT separately. Now this PR only changes their expectations

@annevk
annevk requested review from achristensen07 and youennf July 2, 2026 08:29

@achristensen07 achristensen07 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to do this quite like this. I think our process swapping is the reason our navigation start time isn't leaked across origins when we swap processes for cross-origin navigations, and I think this would introduce that leak without a TAO check. I think we would need to fix #66762 first to know if a navigation passes a TAO check.

Comment thread Source/WebKit/UIProcess/WebPageProxy.h Outdated
@yoavweiss
yoavweiss force-pushed the bcg_performance_timestamps branch from 3fac22e to 7c1d30f Compare July 16, 2026 09:33
@yoavweiss

Copy link
Copy Markdown
Contributor Author

I think our process swapping is the reason our navigation start time isn't leaked across origins when we swap processes for cross-origin navigations, and I think this would introduce that leak without a TAO check. I think we would need to fix #66762 first to know if a navigation passes a TAO check.

Revamped to pipe in the original navigation timing only when the TAO check passes.

@yoavweiss
yoavweiss requested a review from achristensen07 July 16, 2026 09:35
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jul 16, 2026
@yoavweiss yoavweiss removed the merging-blocked Applied to prevent a change from being merged label Jul 16, 2026
@yoavweiss
yoavweiss force-pushed the bcg_performance_timestamps branch from 7c1d30f to 0a490d6 Compare July 16, 2026 20:22
@webkit-ews-buildbot

Copy link
Copy Markdown
Collaborator

macOS Safer C++ Build #121504 (0a490d6)

⚠️ Found 220 fixed files! Please update expectations in Source/[Project]/SaferCPPExpectations by running the following commands and update your pull request:

  • Tools/Scripts/update-safer-cpp-expectations -p WebCore --NoDeleteChecker dom/ElementData.h html/HTMLMediaElement.cpp Modules/webaudio/AudioNode.cpp layout/floats/FloatingContext.cpp platform/graphics/FloatPointGraph.cpp css/parser/CSSParserObserverWrapper.cpp layout/formattingContexts/inline/InlineContentAligner.cpp rendering/GridTrackSizingAlgorithm.cpp plugins/DOMPlugin.cpp rendering/Grid.cpp Modules/speech/SpeechRecognitionResult.cpp html/canvas/OffscreenCanvasRenderingContext2D.cpp xml/XPathNodeSet.cpp platform/graphics/PlatformTimeRanges.cpp layout/formattingContexts/inline/InlineLine.cpp html/parser/HTMLConstructionSite.cpp cssjit/SelectorCompiler.cpp platform/graphics/AV1Utilities.cpp dom/EventDispatcher.cpp platform/Timer.cpp Modules/webauthn/apdu/ApduCommand.cpp html/track/TextTrackList.cpp platform/gamepad/mac/HIDGamepadProvider.mm rendering/RegionContext.cpp html/canvas/WebGLVertexArrayObjectBase.cpp platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm loader/ResourceMonitorThrottler.cpp contentextensions/DFAMinimizer.cpp Modules/webauthn/cbor/CBORWriter.cpp page/LocalFrameViewLayoutContext.cpp layout/formattingContexts/grid/GridLayoutUtils.cpp page/scrolling/ScrollingStateScrollingNode.cpp rendering/TextBoxPainter.cpp html/canvas/WebGLFramebuffer.cpp rendering/RenderFrameSet.cpp layout/formattingContexts/inline/TextOnlySimpleLineBuilder.cpp platform/graphics/FloatPolygon.cpp platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm platform/graphics/GraphicsLayer.cpp style/MatchResultCache.cpp platform/audio/AudioResampler.cpp html/parser/HTMLFormattingElementList.cpp rendering/RenderLayerCompositor.cpp layout/formattingContexts/grid/GridLayout.cpp rendering/LayerAncestorClippingStack.cpp html/canvas/CanvasRenderingContext2DBase.cpp plugins/DOMMimeTypeArray.cpp css/MutableStyleProperties.cpp rendering/AutoTableLayout.cpp layout/formattingContexts/inline/InlineFormattingContext.cpp html/track/VTTRegionList.cpp Modules/webauthn/fido/U2fResponseConverter.cpp rendering/GridLayoutFunctions.cpp Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.cpp svg/SVGAnimationElement.cpp css/CSSFontFaceSet.cpp html/URLSearchParams.cpp rendering/RenderLayoutState.cpp dom/DOMStringList.cpp css/typedom/transform/CSSTransformValue.cpp Modules/speech/SpeechRecognitionResultList.cpp html/FormController.cpp css/StylePropertyShorthand.cpp rendering/NinePieceImagePainter.cpp html/parser/CSSPreloadScanner.cpp Modules/airplay/WebMediaSessionManager.mm fileapi/FileList.cpp rendering/updating/RenderTreeUpdater.cpp crypto/cocoa/CryptoKeyRSACocoa.cpp platform/SharedStringHash.cpp style/values/grid/StyleGridPositionsResolver.cpp layout/formattingContexts/inline/IntrinsicWidthHandler.cpp layout/formattingContexts/inline/display/InlineDisplayContent.cpp Modules/webaudio/AudioNodeInput.cpp platform/audio/AudioBus.cpp layout/formattingContexts/inline/InlineQuirks.cpp page/Navigation.cpp plugins/DOMPluginArray.cpp html/canvas/WebGLTransformFeedback.cpp platform/gamepad/cocoa/GameControllerGamepadProvider.mm rendering/svg/RenderSVGText.cpp css/SelectorFilter.cpp html/track/TextTrackCueList.cpp layout/integration/inline/LayoutIntegrationInlineContent.cpp Modules/url-pattern/URLPatternParser.cpp contentextensions/DFABytecodeCompiler.cpp svg/SVGToOTFFontConversion.cpp platform/network/BlobResourceHandleBase.cpp layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp platform/graphics/displaylists/DisplayListRecorder.cpp inspector/InspectorStyleSheet.cpp platform/audio/HRTFElevation.cpp layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp page/Page.cpp editing/TextIterator.cpp rendering/svg/SVGTextLayoutEngine.cpp html/track/VideoTrackList.cpp history/HistoryItem.cpp Modules/url-pattern/URLPatternConstructorStringParser.cpp platform/graphics/ComplexTextController.cpp style/StyleTreeResolver.cpp Modules/webaudio/AudioWorklet.cpp layout/formattingContexts/grid/ImplicitGrid.cpp dom/EventPath.cpp bindings/js/SerializedScriptValue.cpp html/track/WebVTTParser.cpp rendering/OutlinePainter.cpp platform/audio/Reverb.cpp --UncheckedLocalVarsChecker layout/formattingContexts/inline/ruby/RubyFormattingContext.cpp layout/formattingContexts/inline/InlineContentBreaker.cpp layout/integration/inline/InlineIteratorBoxModernPath.h xml/XPathNodeSet.cpp layout/formattingContexts/inline/InlineLine.cpp layout/formattingContexts/table/TableFormattingGeometry.cpp layout/formattingContexts/inline/InlineContentAligner.cpp --UncountedCallArgsChecker style/RuleSetBuilder.cpp Modules/webaudio/ChannelMergerNode.cpp editing/EditCommand.cpp html/FileInputType.cpp --UncountedLocalVarsChecker platform/graphics/filters/FilterOperations.cpp css/StyleSheetContents.cpp xml/XPathNodeSet.cpp animation/StyleOriginatedTimelinesController.cpp platform/graphics/ca/GraphicsLayerCA.cpp platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm inspector/InspectorStyleSheet.cpp --platform macOS
  • Tools/Scripts/update-safer-cpp-expectations -p WebKit --NoDeleteChecker NetworkProcess/NetworkResourceLoadParameters.cpp WebProcess/Plugins/PDF/UnifiedPDF/PDFDiscretePresentationController.mm UIProcess/WebBackForwardList.cpp Shared/Cocoa/SandboxInitialiationParametersCocoa.mm UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm Shared/WebBackForwardListFrameItem.cpp WebProcess/Plugins/PDF/UnifiedPDF/PDFScrollingPresentationController.mm WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.mm Shared/TextExtractionToStringConversion.cpp Shared/SessionState.cpp NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp WebProcess/Plugins/PDF/UnifiedPDF/PDFPresentationController.mm --UncountedCallArgsChecker WebProcess/WebPage/Cocoa/WebPageCocoa.mm Shared/Cocoa/WKNSArray.mm UIProcess/WebProcessPool.cpp UIProcess/WebFrameProxy.cpp Shared/API/c/WKArray.cpp --platform macOS
  • Tools/Scripts/update-safer-cpp-expectations -p WebKitLegacy --NoDeleteChecker mac/WebCoreSupport/WebFrameLoaderClient.mm --platform macOS
  • Tools/Scripts/update-safer-cpp-expectations -p WebGPU --NoDeleteChecker BindGroup.mm PipelineLayout.mm WGSL/UniformityAnalysis.cpp --platform macOS

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jul 17, 2026
@yoavweiss

Copy link
Copy Markdown
Contributor Author

The win-tests failures seem completely unrelated. Merging.

@yoavweiss yoavweiss removed the merging-blocked Applied to prevent a change from being merged label Jul 28, 2026
@yoavweiss
yoavweiss force-pushed the bcg_performance_timestamps branch from 4c3de2b to 14f69bd Compare July 28, 2026 06:37
@yoavweiss yoavweiss added the merge-queue Applied to send a pull request to merge-queue label Jul 28, 2026
https://bugs.webkit.org/show_bug.cgi?id=316291

Reviewed by Alex Christensen.

Currently the timeOrigin is set when the final process starts the navigation request load.
But in the case of a BCG switch, that load ends up resuming/reusing a load that was already
started in the previous process.
This PR pipes the relevant information over, so that the `timeOrigin` will be properly set
in these cases.

This is fine from a w3c/navigation-timing#160 perspective, because as
against this by obfuscating more than just the redirect data for cross-origin redirects.

Test progression.

* Source/WebCore/loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::startLoadingMainResource): Set the original navigation time if provided.
* Source/WebCore/loader/DocumentLoader.h:
(WebCore::DocumentLoader::setOriginalNavigationStartTime): Setter.
* Source/WebCore/loader/FrameLoadRequest.h:
(WebCore::FrameLoadRequest::originalNavigationStartTime const): Getter.
(WebCore::FrameLoadRequest::setOriginalNavigationStartTime): Setter.
* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::load): Set the originalNavigationStartTime from the request.
* Source/WebCore/loader/ResourceLoadTiming.h:
(WebCore::ResourceLoadTiming::setStartTime): Setter.
* Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h:
* Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.serialization.in:
* Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::sendDidReceiveResponsePotentiallyInNewBrowsingContextGroup): Add originalNavigationStartTime as parameter to the BCG switch.
(WebKit::NetworkResourceLoader::sendDidReceiveResponseWithPotentialProcessSwap):
* Source/WebKit/Shared/LoadParameters.h:
* Source/WebKit/Shared/LoadParameters.serialization.in:
* Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::triggerBrowsingContextGroupSwitchForNavigation): Add originalNavigationStartTime as parameter to the BCG switch.
(WebKit::NetworkProcessProxy::considerProcessSwapForNavigationResponse):
* Source/WebKit/UIProcess/Network/NetworkProcessProxy.h:
* Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in:
* Source/WebKit/UIProcess/ProvisionalPageProxy.cpp:
(WebKit::ProvisionalPageProxy::loadRequest): Add originalNavigationStartTime as parameter to the BCG switch.
* Source/WebKit/UIProcess/ProvisionalPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::loadRequestWithNavigationShared): Set the originalNavigationStartTime in parameters.
(WebKit::WebPageProxy::continueNavigationInNewProcess): Pass originalNavigationStartTime.
(WebKit::WebPageProxy::triggerBrowsingContextGroupSwitchForNavigation): Pass originalNavigationStartTime.
(WebKit::WebPageProxy::loadRequest):
(WebKit::WebPageProxy::receivedNavigationActionPolicyDecision):
(WebKit::WebPageProxy::performProcessSwapForNavigationResponse):
(WebKit::WebPageProxy::triggerProcessSwapForEnhancedSecurity):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess): Set the originalNavigationStartTime from the documentLoader's startTime.
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::loadRequest): Set the originalNavigationStartTime from the load parameters.
* LayoutTests/imported/w3c/web-platform-tests/navigation-timing/response-start-after-coop-bcg-switch-no-tao.tentative.https-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/navigation-timing/response-start-after-coop-bcg-switch-no-tao.tentative.https.html: Added.

Canonical link: https://commits.webkit.org/318057@main
@webkit-commit-queue
webkit-commit-queue force-pushed the bcg_performance_timestamps branch from 14f69bd to f8352ee Compare July 28, 2026 10:36
@webkit-commit-queue

Copy link
Copy Markdown
Collaborator

Committed 318057@main (f8352ee): https://commits.webkit.org/318057@main

Reviewed commits have been landed. Closing PR #66437 and removing active labels.

@webkit-commit-queue
webkit-commit-queue merged commit f8352ee into WebKit:main Jul 28, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jul 28, 2026
@yoavweiss
yoavweiss deleted the bcg_performance_timestamps branch July 28, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New Bugs Unclassified bugs are placed in this component until the correct component can be determined.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants