document sequence numbers and prerendering

63 views
Skip to first unread message

Fergal Daly

unread,
Aug 28, 2025, 11:07:08 AM (9 days ago) Aug 28
to prer...@chromium.org, Rakina Zata Amni, navigation-dev
Prerender folks,

I've been trying to debug a BFCache issue and I came across something unexpected that appears to be related to prerendering.

BFCache relies on document_sequence_number when creating the BackForwardCacheMetrics object. The goal is that a contiguous sequence of history entries that all have the same main frame document will all have the same BackForwardCacheMetrics object. This logic is in CreateOrReuseBackForwardCacheMetricsForNavigation.

What I'm seeing is that params.document_sequence_number is often -1. If I disable prerendering, it's never -1.

It happens reliably with www.google.com and example.com.

The outcome of this is two-fold:
- someone navigating to www.google.com then example.com will have them sharing a metrics object. This can cause over-eviction of BFCache entries.
- someone navigating to example.com then example/com#foo will get 2 distinct metrics objects instead of sharing them. It's hard to figure out when this results in a real problem but it's definitely not WAI.

Is this intentional? I don't see anything in the docs in the .mojom file. If it's intentional, where can we find the actual DSN?

Thanks,

F

Fergal Daly

unread,
Aug 28, 2025, 8:45:39 PM (9 days ago) Aug 28
to loadi...@chroium.org, Rakina Zata Amni, navigation-dev, Hiroki Nakagawa
[-prerendering-dev, +loading-dev]

FYI, adding a

CHECK_NE(params.document_sequence_number, -1);

to NavigationControllerImpl::RendererDidNavigate and then running

content_browsertests:*/*BackForward*.*/*

causes 19 tests to fail and they all involve prerendering,

F

Fergal Daly

unread,
Aug 28, 2025, 8:47:18 PM (9 days ago) Aug 28
to loadi...@chromium.org, Rakina Zata Amni, navigation-dev, Hiroki Nakagawa
[fixing loading-dev]

Fergal Daly

unread,
Aug 28, 2025, 8:48:38 PM (9 days ago) Aug 28
to loadi...@chromium.org, Rakina Zata Amni, navigation-dev, Hiroki Nakagawa

Fergal Daly

unread,
Aug 28, 2025, 8:52:27 PM (9 days ago) Aug 28
to loadi...@chromium.org, Rakina Zata Amni, navigation-dev, Hiroki Nakagawa
[reposting having joined loading-dev group]

Fergal Daly

unread,
Aug 28, 2025, 10:23:16 PM (9 days ago) Aug 28
to loadi...@chromium.org, Rakina Zata Amni, navigation-dev, Hiroki Nakagawa

Hiroki Nakagawa

unread,
Aug 29, 2025, 4:59:58 AM (8 days ago) Aug 29
to Fergal Daly, loadi...@chromium.org, Rakina Zata Amni, navigation-dev
Hi Fergal,

Thanks for reaching out.

For prerender activation navigation, params.document_sequence_number is set in NavigationRequest::MakeDidCommitProvisionalLoadParamsForActivation() [cs].
I guess the number should have been copied from the prerendering navigation entry there. Otherwise, the number remains the default value, that is, -1. I'm now creating a fix.

Thanks,
Hiroki


Fergal Daly

unread,
Aug 29, 2025, 5:19:11 AM (8 days ago) Aug 29
to Hiroki Nakagawa, loadi...@chromium.org, Rakina Zata Amni, navigation-dev, bfcache-dev
On Fri, 29 Aug 2025 at 17:59, Hiroki Nakagawa <nhi...@chromium.org> wrote:
Hi Fergal,

Thanks for reaching out.

For prerender activation navigation, params.document_sequence_number is set in NavigationRequest::MakeDidCommitProvisionalLoadParamsForActivation() [cs].
I guess the number should have been copied from the prerendering navigation entry there. Otherwise, the number remains the default value, that is, -1. I'm now creating a fix.

Thanks. I have no idea what impact this is having on BFCache. I also wonder if what else is impacted by the missing DSNs.

added a CHECK_NE(params->document_sequence_number, -1) to RenderFrameHostImpl::DidCommitNavigationInternal. 724 tests fail. Filtering out prerender tests, we're still left with

All/AmpPageLoadMetricsBrowserTest.AmpMainFrame/1
All/AmpPageLoadMetricsBrowserTest.AmpSubframe/1
All/AmpPageLoadMetricsBrowserTest.NoAmp/1
All/HTTPCacheSearchPreloadUnifiedBrowserTest.BackwardHitHttpCache/0
All/HTTPCacheSearchPreloadUnifiedBrowserTest.BackwardHitHttpCache/1
All/InvisiblePageLazyLoadingImageBrowserTest.LazyLoading/all_invisible_page
All/NavigationControllerBrowserTest.ErrorPageNavigationWithoutNavigationRequestGetsKilled/RDAllFrames_BFCacheDisabled
All/NavigationControllerBrowserTest.ErrorPageNavigationWithoutNavigationRequestGetsKilled/RDAllFrames_BFCacheEnabled
All/NavigationControllerBrowserTest.ErrorPageNavigationWithoutNavigationRequestGetsKilled/RDCrashedFrame_BFCacheDisabled
All/NavigationControllerBrowserTest.ErrorPageNavigationWithoutNavigationRequestGetsKilled/RDCrashedFrame_BFCacheEnabled
NavigationControllerTest.PushStateUpdatesTitleAndFavicon
NavigationControllerTest.PushStateWithOnlyInitialEntry
NavigationControllerTest.SameDocument_Replace
RenderFrameHostImplTest.NavigationApiInterceptBrowserInitiated
RenderFrameHostImplTest.NavigationApiInterceptShowLoadingUi
SafeSearchPolicyTest.ForceGoogleSafeSearch
SearchPreloadUnifiedBrowserTest.ChunkedResponseBody
SearchPreloadUnifiedBrowserTest.OpenPrefetchedResponseInBackgroundedTab
SearchPreloadUnifiedBrowserTest.SetLoaderTimeCorrectly
SearchPreloadUnifiedBrowserTest.TriggerAndActivate
SecurityExploitBrowserTest.NonInitialAboutBlankRendererKill
WebContentsImplTest.UpdateTitle

I'm trying again with the CHECK_NE moved to NavigationControllerImpl::RendererDidNavigate and rebased on top of your fix.

F

Reply all
Reply to author
Forward
0 new messages