page_load_metrics.mojom 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. module page_load_metrics.mojom;
  5. import "ui/gfx/geometry/mojom/geometry.mojom";
  6. import "mojo/public/mojom/base/shared_memory.mojom";
  7. import "mojo/public/mojom/base/time.mojom";
  8. import "third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom";
  9. import
  10. "third_party/blink/public/mojom/mobile_metrics/mobile_friendliness.mojom";
  11. import "third_party/blink/public/mojom/use_counter/use_counter_feature.mojom";
  12. // TimeDeltas below relative to navigation start.
  13. struct DocumentTiming {
  14. // Time immediately before the DOMContentLoaded event is fired.
  15. mojo_base.mojom.TimeDelta? dom_content_loaded_event_start;
  16. // Time immediately before the load event is fired.
  17. mojo_base.mojom.TimeDelta? load_event_start;
  18. };
  19. struct LargestContentfulPaintTiming {
  20. // Time when the page's largest image is painted.
  21. mojo_base.mojom.TimeDelta? largest_image_paint;
  22. // Size of the largest image of the largest image paint, by
  23. // Size = Height * Width. Removed images are excluded.
  24. uint64 largest_image_paint_size;
  25. // Time when the page's largest text is painted.
  26. mojo_base.mojom.TimeDelta? largest_text_paint;
  27. // Size of the largest text of the largest text paint, by
  28. // Size = Height * Width. Removed text is excluded.
  29. uint64 largest_text_paint_size;
  30. // These are packed blink::LargestContentfulPaintType enums, indicating
  31. // the largest LCP candidate's type characteristics.
  32. uint64 type;
  33. // Computed entropy of the page's largest image, calculated as the image file
  34. // size, in bits, divided by the image's rendered size, in pixels.
  35. double image_bpp;
  36. };
  37. // TimeDeltas below relative to navigation start.
  38. struct PaintTiming {
  39. // Time when the first paint is performed.
  40. mojo_base.mojom.TimeDelta? first_paint;
  41. // Time when the first image is painted.
  42. mojo_base.mojom.TimeDelta? first_image_paint;
  43. // Time when the first contentful thing (image, text, etc.) is painted.
  44. mojo_base.mojom.TimeDelta? first_contentful_paint;
  45. // (Experimental) Time when the page's primary content is painted.
  46. mojo_base.mojom.TimeDelta? first_meaningful_paint;
  47. // Largest contentful paint, which includes removed content.
  48. LargestContentfulPaintTiming largest_contentful_paint;
  49. // (Experimental) largest contentful paint excluding removed content.
  50. LargestContentfulPaintTiming experimental_largest_contentful_paint;
  51. // (Experimental) Time when the frame is first eligible to be painted, i.e.
  52. // is first not render-throttled. Will be null if frame is throttled,
  53. // unless there has already been a |first_paint|.
  54. mojo_base.mojom.TimeDelta? first_eligible_to_paint;
  55. // (Experimental) Time when first input or scroll is received, causing the
  56. // largest contentful paint algorithm to stop.
  57. mojo_base.mojom.TimeDelta? first_input_or_scroll_notified_timestamp;
  58. // Time when the first paint happens after a portal activation.
  59. mojo_base.mojom.TimeTicks? portal_activated_paint;
  60. };
  61. // TimeDeltas below represent durations of time during the page load.
  62. struct ParseTiming {
  63. // Time that the document's parser started and stopped parsing main resource
  64. // content.
  65. mojo_base.mojom.TimeDelta? parse_start;
  66. mojo_base.mojom.TimeDelta? parse_stop;
  67. // Sum of times when the parser is blocked waiting on the load of a script.
  68. // This duration takes place between parser_start and parser_stop, and thus
  69. // must be less than or equal to parser_stop - parser_start. Note that this
  70. // value may be updated multiple times during the period between parse_start
  71. // and parse_stop.
  72. mojo_base.mojom.TimeDelta? parse_blocked_on_script_load_duration;
  73. // Sum of times when the parser is blocked waiting on the load of a script
  74. // that was inserted from document.write. This duration must be less than or
  75. // equal to parse_blocked_on_script_load_duration. Note that this value may be
  76. // updated multiple times during the period between parse_start and
  77. // parse_stop. Note that some uncommon cases where scripts are loaded via
  78. // document.write are not currently covered by this field. See crbug/600711
  79. // for details.
  80. mojo_base.mojom.TimeDelta? parse_blocked_on_script_load_from_document_write_duration;
  81. // Sum of times when the parser is executing a script. This duration takes
  82. // place between parser_start and parser_stop, and thus must be less than or
  83. // equal to parser_stop - parser_start. Note that this value may be updated
  84. // multiple times during the period between parse_start and parse_stop.
  85. mojo_base.mojom.TimeDelta? parse_blocked_on_script_execution_duration;
  86. // Sum of times when the parser is executing a script that was inserted from
  87. // document.write. This duration must be less than or equal to
  88. // parse_blocked_on_script_load_duration. Note that this value may be updated
  89. // multiple times during the period between parse_start and parse_stop. Note
  90. // that some uncommon cases where scripts are loaded via document.write are
  91. // not currently covered by this field. See crbug/600711 for details.
  92. mojo_base.mojom.TimeDelta? parse_blocked_on_script_execution_from_document_write_duration;
  93. };
  94. struct InteractiveTiming {
  95. // Queueing Time of the first click, tap, key press, cancellable touchstart,
  96. // or pointer down followed by a pointer up.
  97. mojo_base.mojom.TimeDelta? first_input_delay;
  98. // The timestamp of the event whose delay is reported by GetFirstInputDelay().
  99. mojo_base.mojom.TimeDelta? first_input_timestamp;
  100. // Queueing Time of the meaningful input event with longest delay. Meaningful
  101. // input events are click, tap, key press, cancellable touchstart, or pointer
  102. // down followed by a pointer up.
  103. mojo_base.mojom.TimeDelta? longest_input_delay;
  104. // The timestamp of the event whose delay is reported as longest_input_delay.
  105. mojo_base.mojom.TimeDelta? longest_input_timestamp;
  106. // The latency between user input and display update for the first scroll after
  107. // a navigation.
  108. mojo_base.mojom.TimeDelta? first_scroll_delay;
  109. // The timestamp of the user's first scroll after a navigation.
  110. mojo_base.mojom.TimeDelta? first_scroll_timestamp;
  111. // The duration of event handlers processing the first input event.
  112. mojo_base.mojom.TimeDelta? first_input_processing_time;
  113. };
  114. // PageLoadTiming contains timing metrics associated with a page load. Many of
  115. // the metrics here are based on the Navigation Timing spec:
  116. // http://www.w3.org/TR/navigation-timing/.
  117. struct PageLoadTiming {
  118. // Time that the navigation for the associated page was initiated. Note that
  119. // this field is only used for internal tracking purposes and should not be
  120. // used by PageLoadMetricsObservers. This field will likely be removed in the
  121. // future.
  122. mojo_base.mojom.Time navigation_start;
  123. // Time relative to navigation_start that the first byte of the response is
  124. // received.
  125. mojo_base.mojom.TimeDelta? response_start;
  126. DocumentTiming document_timing;
  127. InteractiveTiming interactive_timing;
  128. PaintTiming paint_timing;
  129. ParseTiming parse_timing;
  130. // List of back-forward cache timings, one for each time a page was restored
  131. // from the cache.
  132. array<BackForwardCacheTiming> back_forward_cache_timings;
  133. // Time relative to navigation_start that the prerender activation navigation
  134. // was initiated. This is set for prerendered page loads that were later
  135. // activated.
  136. mojo_base.mojom.TimeDelta? activation_start;
  137. // Time between user input and navigation start. This is set for navigations
  138. // where the input start timing is known; currently when the navigation is
  139. // initiated by a link click in the renderer, or from the desktop omnibox.
  140. mojo_base.mojom.TimeDelta? input_to_navigation_start;
  141. // Time when the standard UserTiming mark `mark_fully_loaded` occurs.
  142. mojo_base.mojom.TimeDelta? user_timing_mark_fully_loaded;
  143. // Time when the standard UserTiming mark `mark_fully_visible` occurs.
  144. mojo_base.mojom.TimeDelta? user_timing_mark_fully_visible;
  145. // Time when the standard UserTiming mark `mark_interactive` occurs.
  146. mojo_base.mojom.TimeDelta? user_timing_mark_interactive;
  147. // If you add additional members, also be sure to update page_load_timing.h.
  148. };
  149. struct FrameMetadata {
  150. // These are packed blink::LoadingBehaviorFlag enums.
  151. int32 behavior_flags = 0;
  152. // For the main frame, the rect is the main frame document size (at (0,0));
  153. // for a subframe, the rect is frame's intersection rect with the main frame
  154. // in the main frame's coordinate system, and is an empty rect when there is
  155. // no intersection with the main frame. This is only set for the first time
  156. // the intersection rectangle is initially computed, and for any subsequent
  157. // changes, and is null otherwise (i.e. hasn't changed).
  158. gfx.mojom.Rect? main_frame_intersection_rect;
  159. // The main frame's viewport rectangle (encapsulating the dimensions and the
  160. // scroll position) in the main frame's coordinate system. This is only set
  161. // for the main frame, for the first time the viewport rectangle is initially
  162. // computed, and for any subsequent changes, and is null otherwise (i.e.
  163. // hasn't changed).
  164. gfx.mojom.Rect? main_frame_viewport_rect;
  165. };
  166. // Enumeration of distinct cache types.
  167. enum CacheType {
  168. kNotCached, // Resource came from network.
  169. kHttp, // Resource was serviced by the http cache.
  170. kMemory, // Resource was serviced by the Renderer's MemoryCache.
  171. };
  172. struct ResourceDataUpdate {
  173. // The id for the resource request.
  174. int32 request_id = 0;
  175. // Network bytes received for the resource since the last timing update
  176. // from renderer to browser.
  177. int64 delta_bytes = 0;
  178. // Total network bytes received for the resource across timing updates. This
  179. // is the aggregate of the |delta_bytes| from each timing update.
  180. int64 received_data_length = 0;
  181. // The length of the response body for the resource before removing any
  182. // content encodings. Only set for complete resources.
  183. int64 encoded_body_length = 0;
  184. // The length of the response body in bytes for the resource after decoding.
  185. // Only set for complete resources.
  186. int64 decoded_body_length = 0;
  187. // Whether this resource load has completed.
  188. bool is_complete;
  189. // Whether this resource was tagged as an ad in the renderer. This flag can
  190. // be set to true at any point during a resource load. A more recent
  191. // ResourceDataUpdate can have a different flag than the previous update.
  192. // Once this is set to true, it will be true for all future updates.
  193. bool reported_as_ad_resource;
  194. // Whether this resource was loaded in the top-level frame.
  195. bool is_main_frame_resource;
  196. // Which cache this resource originated from, if any.
  197. CacheType cache_type;
  198. // Whether this resource is the primary resource for a frame.
  199. bool is_primary_frame_resource;
  200. // Mime type for the resource found in the network response header.
  201. string mime_type;
  202. // Whether the scheme of this resource indicates a secure connection.
  203. bool is_secure_scheme;
  204. // Whether this resource was fetched via proxy.
  205. bool proxy_used;
  206. // Whether this resource completed loading, either by network or cache, before
  207. // FCP in the frame it belongs to. This flag can be set to true at any point
  208. // during a resource load. A more recent ResourceDataUpdate can have a
  209. // different flag than the previous update. Once this is set to true, it will
  210. // be true for all future updates.
  211. bool completed_before_fcp;
  212. };
  213. // Timestamp and layout shift score of a layout shift.
  214. struct LayoutShift {
  215. mojo_base.mojom.TimeTicks layout_shift_time;
  216. double layout_shift_score;
  217. };
  218. // Metrics about how a RenderFrame rendered since the last UpdateTiming call.
  219. struct FrameRenderDataUpdate {
  220. // How much visible elements in the frame shifted (https://bit.ly/3fQz29y) since
  221. // the last timing update.
  222. float layout_shift_delta;
  223. // How much visible elements in the frame shifted (https://bit.ly/3fQz29y),
  224. // before a user input or document scroll, since the last timing update.
  225. float layout_shift_delta_before_input_or_scroll;
  226. // How many LayoutBlock instances were created.
  227. uint32 all_layout_block_count_delta;
  228. // How many LayoutNG-based LayoutBlock instances were created.
  229. uint32 ng_layout_block_count_delta;
  230. // How many times LayoutObject::UpdateLayout() is called.
  231. uint32 all_layout_call_count_delta;
  232. // How many times LayoutNG-based LayoutObject::UpdateLayout() is called.
  233. uint32 ng_layout_call_count_delta;
  234. // New layout shifts with timestamps.
  235. array<LayoutShift> new_layout_shifts;
  236. };
  237. // Metrics about the time spent in tasks (cpu time) by a frame.
  238. struct CpuTiming {
  239. // Time spent in tasks measured in wall time.
  240. mojo_base.mojom.TimeDelta task_time;
  241. };
  242. // Metrics about general input delay.
  243. struct InputTiming {
  244. // The sum of all input delay.
  245. mojo_base.mojom.TimeDelta total_input_delay;
  246. // The sum of all adjusted input delay. We adjust each input delay by
  247. // subtracting a small number, currently 50ms but subject to change in the
  248. // future. And if the subtraction result is negative, we will use 0ms.
  249. mojo_base.mojom.TimeDelta total_adjusted_input_delay;
  250. // The number of input events, including click, tap, key press,
  251. // cancellable touchstart, or pointer down followed by a pointer up.
  252. uint64 num_input_events = 0;
  253. // The number of user interactions, including click, tap and key press.
  254. uint64 num_interactions = 0;
  255. // Includes an array of max_event_duration which is the longest input event
  256. // duration within a user interaction. The unit of duration is ms. Currently,
  257. // we send this array to the browser process behind a Finch flag.
  258. // TODO(crbug.com/1252179): Once the experiment is done, we could simplify
  259. // this part.
  260. UserInteractionLatencies max_event_durations;
  261. };
  262. // Data for user interaction latencies which can be meausred in different ways.
  263. // Currently, the array user_interaction_latencies is sent behind a Finch flag.
  264. // If we don't send the array, the maximum value will be sent instead.
  265. union UserInteractionLatencies {
  266. array<UserInteractionLatency> user_interaction_latencies;
  267. // The maximum value in user_interaction_latencies.
  268. mojo_base.mojom.TimeDelta worst_interaction_latency;
  269. };
  270. // The latency and the type of a user interaction.
  271. struct UserInteractionLatency {
  272. mojo_base.mojom.TimeDelta interaction_latency;
  273. UserInteractionType interaction_type;
  274. };
  275. // The type of a user interaction, including keyboard, click or tap and drag.
  276. enum UserInteractionType {
  277. kKeyboard,
  278. kTapOrClick,
  279. kDrag,
  280. };
  281. // Sent from renderer to browser process when the PageLoadTiming for the
  282. // associated frame changed.
  283. interface PageLoadMetrics {
  284. // Called when an update is ready to be sent from renderer to browser.
  285. // UpdateTiming calls are buffered, and contain all updates that have been
  286. // received in the last buffer window. Some of the update data may be empty.
  287. // Only called when at least one change has been observed within the frame.
  288. UpdateTiming(PageLoadTiming page_load_timing,
  289. FrameMetadata frame_metadata,
  290. // `new_features` will not contain any previously seen values.
  291. array<blink.mojom.UseCounterFeature> new_features,
  292. array<ResourceDataUpdate> resources,
  293. FrameRenderDataUpdate render_data,
  294. CpuTiming cpu_load_timing,
  295. InputTiming input_timing_delta,
  296. blink.mojom.MobileFriendliness? mobile_friendliness,
  297. uint32 soft_navigation_count);
  298. // Set up a shared memory used to transfer smoothness data from the renderer
  299. // to the browser. The structure is defined in
  300. // //cc/metrics/ukm_smoothness_data.h
  301. SetUpSharedMemoryForSmoothness(
  302. mojo_base.mojom.ReadOnlySharedMemoryRegion shared_memory);
  303. };
  304. // TimeDelta below relative to the navigation start of the navigation restoring
  305. // page from the back- forward cache.
  306. struct BackForwardCacheTiming {
  307. // Time when the first paint is performed after the time when the page
  308. // is restored from the back-forward cache.
  309. mojo_base.mojom.TimeDelta first_paint_after_back_forward_cache_restore;
  310. // Times on requestAnimationFrame when the page is restored from the back-
  311. // forward cache.
  312. array<mojo_base.mojom.TimeDelta> request_animation_frames_after_back_forward_cache_restore;
  313. // Queueing Time of the first click, tap, key press, cancellable touchstart,
  314. // or pointer down followed by a pointer up after the time when the page is
  315. // restored from the back-forward cache.
  316. mojo_base.mojom.TimeDelta? first_input_delay_after_back_forward_cache_restore;
  317. };