This directory contains the Prerender2 implementation (https://crbug.com/1126305).
If you're interested in relevant code changes, join the [email protected] group.
Prerendering is “pre”-rendering, it's about pre-loading and rendering a page before the user actually navigates to it. The main goal of prerendering is to make the next page navigation faster, or ideally nearly instant.
The Prerender2 is the new implementation of prerendering.
<script type="speculationrules">
is the only trigger in content/. Embedders may define their triggers by calling WebContents::StartPrerendering
.As previously mentioned, there are two navigations involved in Prerender2: the prerendering navigation and the activation navigation. As a result, there are two UKM Source IDs that are currently used for a prerendered page; one derived from each navigation's ID.
The SourceId for the prerendering navigation is currently returned by RenderFrameHost::GetPageUkmSourceId(), and by NavigationHandle::GetNextPageUkmSourceId() when called on the NavigationHandle
for the prerendering navigation. This source ID is not associated with a URL by SourceUrlRecorder (the data collection policy disallows recording it before prerender activation), so any metrics recorded using it will not be associated with a URL.
The SourceId for the activation navigation is associated with a URL by SourceUrlRecorder
. The value is currently returned by NavigationHandle::GetNextPageUkmSourceId()
when called on the NavigationHandle
for the activation navigation, and by PageLoadMetricsObserverDelegate::GetPageUkmSourceId (and is used by all PLMOs that record UKMs for prerendered pages).
There are 2 patterns recording metrics for prerendering pages used currently in content/:
Use the source ID of the most recently navigated primary page (obtained from NavigationHandle::GetNextPageUkmSourceId()
, which uses the activation navigation ID for prerender activations). This UKM source ID is always associated with a URL. This approach is currently used by Precog (the UKM infrastructure in content/browser/preloading) to record the Preloading_Prediction
and Preloading_Attempt
UKMs.
Use the triggering page‘s UKM source ID to record metrics for a prerendering page. PrerenderHost uses this approach currently to record the PrerenderPageLoad
UKM, which it reports even if the prerendered page isn’t activated. Precog also uses this approach to record the Preloading_Attempt_PreviousPrimaryPage
UKM. They both currently use RenderFrameHost::GetPageUkmSourceId
to retrieve the source ID, which will be associated with a URL in most cases, except when the triggering page itself was prerendered.
Another possible approach is to collect/remember metrics while prerendering and only record them using the activation navigation's source ID after the prerender is activated (a similar pattern is used by PageLoadMetricsObserver
s outside content/). In the future, we may want to support recording UKMs after activation with both source IDs. This will require registering the prerender navigation source ID with a URL after activation.
Note that this section is targeting Chromium developers, to help diagnose issues where prerendering needs to be enabled or disabled. For web development, see Prerender pages in Chrome for instant page navigations and Debugging speculation rules.
For now the best strategy is to prerender the url with the bookmark bar's help.
--enable-features=BookmarkTriggerForPrerender2
Note it is expected that prerender2 would only prerender HTTPS sites with this approach.
An alternative is to trigger prerender with Direct URL Input in omnibox. Refer to Demonstration of URL-bar-triggered Omnibox prerendering, which demonstrates how to trigger it.
--disable-features=Prerender2
.Use feature param PreloadingConfig:preloading_config
.
Example:
holdback: true
for each entry.cat - | jq -c . | jq -sRr @uri | sed 's/%0A//g'
.--enable-features="PreloadingConfig:preloading_config/<url_encoded_preloading_config>
.Note that FeatureParam
doesn't decode %20
and +
[cs]. Minification is recommended.
Determine whether prerender is running with chrome://process-internals
Determine whether prerender is running with Task Manager
Determine whether prerendered pages were activated: chrome://histograms/Prerender.Experimental.PrerenderHostFinalStatus
covers the final status of all triggers, and the meaning of each enum item can be found in PrerenderFinalStatus.
The date is the publication date, not the last updated date.