Closed Bug 1298381 Opened 9 years ago Closed 7 years ago

Implement Time to First Contentful Paint (TTFCP) for Telemetry/Profiler

Categories

(Core :: Layout, defect, P3)

All
Unspecified
defect

Tracking

()

RESOLVED FIXED
mozilla65
Performance Impact low
Tracking Status
firefox65 --- fixed

People

(Reporter: Dominik, Assigned: jesup)

References

Details

(Keywords: perf, Whiteboard: [perf-tools])

Attachments

(1 file, 5 obsolete files)

Time to First Contentful Visual celebrates the first visible change to the screen that average users can observe. It can also be seen as the time when any "contentful" thing (text, image, SVG, non-empty canvas) is painted for the first time on the screen.
Thread on Chromium about First Contentful Visual to confirm user's "is it happening?" question when requesting a new page: https://groups.google.com/a/chromium.org/forum/#!msg/loading-dev/NzBleQ4QP6Y/XRoR0NFQBwAJ Chromium's planning doc: https://docs.google.com/document/d/1Owfs6arciEnWgT2-8bWCcHdYRIKRKZ0Xj8UtqRx4c3k/edit#heading=h.nwfi9zag6eyn Thread on why these metrics are called "Visual" vs "Paint": https://groups.google.com/a/chromium.org/forum/#!topic/progressive-web-metrics/_s92zvTPblk
This will be most likely merged with Time to First Meaningful Paint.
No longer blocks: 1307242
Summary: Implement Time to First Contentful Visual (TTFCVisual) → Implement Time to First Contentful Paint (TCP)
There is a proposal about a Hero Element Timing API from Chrome team that was approved by the web-perf W3C group. Here's the current draft of the spec: https://docs.google.com/document/d/1yRYfYR1DnHtgwC4HRR04ipVVhT1h5gkI6yPmKCgJkyQ/edit
Clarified the minimal scope for this bug, which is only telemetry and profiler. Developer facing numbers depend on validation and spec stabilizing.
Keywords: dev-doc-needed
Summary: Implement Time to First Contentful Paint (TCP) → Implement Time to First Contentful Paint (TCP) for Telemetry/Profiler
Is this probe needed for QF? If so please tag with [qf:p1]
Flags: needinfo?(hkirschner)
Flags: needinfo?(hkirschner)
Whiteboard: [qf:p3]
Priority: -- → P3
Keywords: perf
Whiteboard: [qf:p3] → [qf:p3][perf-tools]
Has not been tested or built yet. Needs more work on the IsContentfulPaint code per discussion in #gfx
Assignee: nobody → rjesup
Status: NEW → ASSIGNED
Attachment #9018355 - Attachment is obsolete: true
Attachment #9018375 - Attachment is obsolete: true
I'm certain the list of types getting the TYPE_IS_CONTENTFUL flag is wrong in many ways. I need to know a) which are wrong, b) if the recursive check I have is right. Also, should I revise NonBlankPaint to be FirstPaint? (and what exactly are the differences at the DisplayList level). Thanks
Attachment #9019136 - Flags: feedback?(mstange)
Attachment #9019136 - Flags: feedback?(matt.woodrow)
Attachment #9018376 - Attachment is obsolete: true
Comment on attachment 9019136 [details] [diff] [review] Implement TimeToFirstContentfulPaint behind a pref Review of attachment 9019136 [details] [diff] [review]: ----------------------------------------------------------------- ::: layout/painting/nsDisplayItemTypesList.h @@ +22,1 @@ > DECLARE_DISPLAY_ITEM_TYPE(CANVAS, TYPE_RENDERS_NO_IMAGES) This usage of CANVAS refers to the HTML <canvas> element, which I assume is what is meant by "non-white canvas". You might want manual code in DisplayListIsContentful to query the actual element and figure out the 'non-white' bit (which it doesn't appear we have code for). The other 3 CANVAS_ types refer to the CSS conceptual canvas (see CSS2.3.1), and the flags look correct. @@ +64,1 @@ > DECLARE_DISPLAY_ITEM_TYPE(SVG_WRAPPER, 0) I think all the SVG types in this block should probably be considered contentful. @@ +66,1 @@ > DECLARE_DISPLAY_ITEM_TYPE(TABLE_CELL_BACKGROUND, 0) It looks like table cells don't have separate items for the colour and set of images, so this item represents whatever we have. You may want to query the item itself to find out if it's going to paint images. @@ +66,3 @@ > DECLARE_DISPLAY_ITEM_TYPE(TABLE_CELL_BACKGROUND, 0) > DECLARE_DISPLAY_ITEM_TYPE(TABLE_CELL_SELECTION, TYPE_RENDERS_NO_IMAGES) > DECLARE_DISPLAY_ITEM_TYPE(TABLE_BORDER_COLLAPSE, 0) This represents all the backgrounds for an entire border-collapse table, including colours and images for each cell/row/column. Again, may be worth trying to dig deeper to decide if it's contentful.
Attachment #9019136 - Flags: feedback?(matt.woodrow) → feedback+
disabled the actual check of the canvas MaybeModified state for now (also for some reason my simple test doesn't seem to get GetContext() when I ask for canvas.getContext('2d'))
Attachment #9019893 - Flags: feedback?(matt.woodrow)
Attachment #9019136 - Attachment is obsolete: true
Attachment #9019136 - Flags: feedback?(mstange)
Works; tested with a simple canvas-only testcase
Attachment #9021963 - Flags: review?(matt.woodrow)
Attachment #9021963 - Flags: review?(bobbyholley)
Attachment #9019893 - Attachment is obsolete: true
Attachment #9019893 - Flags: feedback?(matt.woodrow)
Can you confirm what I'm reviewing? Just the WebIDL changes?
Comment on attachment 9021963 [details] [diff] [review] Implement TimeToFirstContentfulPaint behind a pref Review of attachment 9021963 [details] [diff] [review]: ----------------------------------------------------------------- Display list side looks good! I'm sure there will be more tweaking required with the CONTENTFUL flags, and getting the canvas override and spec to match etc, but landing the infrastructure sounds like a good idea! ::: layout/painting/nsDisplayItemTypesList.h @@ +57,5 @@ > DECLARE_DISPLAY_ITEM_TYPE(SUBDOCUMENT, TYPE_RENDERS_NO_IMAGES) > DECLARE_DISPLAY_ITEM_TYPE(MASK, 0) > DECLARE_DISPLAY_ITEM_TYPE(FILTER, TYPE_RENDERS_NO_IMAGES) > DECLARE_DISPLAY_ITEM_TYPE(SVG_OUTER_SVG, TYPE_RENDERS_NO_IMAGES) > DECLARE_DISPLAY_ITEM_TYPE(SVG_GEOMETRY, 0) SVG_GEOMETRY is the standard svg display item, we should probably consider that CONTENTFUL too.
Attachment #9021963 - Flags: review?(matt.woodrow) → review+
Comment on attachment 9021963 [details] [diff] [review] Implement TimeToFirstContentfulPaint behind a pref Canceling review pending comment 4.
Attachment #9021963 - Flags: review?(bobbyholley)
(In reply to Bobby Holley (:bholley) from comment #14) > Can you confirm what I'm reviewing? Just the WebIDL changes? Yes - though if you're willing/able to review any more of the DOM/layout changes, that's great. If not I'll hit up appropriate other peers for those.
Attachment #9021963 - Flags: review?(bobbyholley)
Attachment #9021963 - Flags: review?(bugs)
Comment on attachment 9021963 [details] [diff] [review] Implement TimeToFirstContentfulPaint behind a pref Review of attachment 9021963 [details] [diff] [review]: ----------------------------------------------------------------- I'll defer to smaug, who can presumably also stamp the webidl changes.
Attachment #9021963 - Flags: review?(bobbyholley)
Comment on attachment 9021963 [details] [diff] [review] Implement TimeToFirstContentfulPaint behind a pref >+ nsPrintfCString marker("Contentful paint after %dms for URL %s, %s", >+ int(elapsed.ToMilliseconds()), spec.get(), >+ mDocShellHasBeenActiveSinceNavigationStart ? "foreground tab" : "this tab was inactive some of the time between navigation start and first non-blank paint"); overlong line > void >+nsPresContext::NotifyContentfulPaint() >+{ >+ if (!mHadContentfulPaint) { >+ mHadContentfulPaint = true; >+ if (IsRootContentDocument()) { >+ RefPtr<nsDOMNavigationTiming> timing = mDocument->GetNavigationTiming(); >+ if (timing) { >+ timing->NotifyContentfulPaintForRootContentDocument(); >+ } >+ >+ mFirstContentfulPaintTime = TimeStamp::Now(); You just assign to this variable once but never use the value for anything. Drop mFirstContentfulPaintTime from nsPresContext. >- >+ bool HadContentfulPaint() const { Nit, { should be on its own line > nsDisplayListBuilder::LeavePresShell(nsIFrame* aReferenceFrame, > nsDisplayList* aPaintedContents) > { > NS_ASSERTION(CurrentPresShellState()->mPresShell == > aReferenceFrame->PresShell(), > "Presshell mismatch"); > >- if (mIsPaintingToWindow) { >+ if (mIsPaintingToWindow && aPaintedContents) { > nsPresContext* pc = aReferenceFrame->PresContext(); > if (!pc->HadNonBlankPaint()) { > if (!CurrentPresShellState()->mIsBackgroundOnly && > DisplayListIsNonBlank(aPaintedContents)) { > pc->NotifyNonBlankPaint(); > } > } >+ if (!pc->HadContentfulPaint()) { >+ if (!CurrentPresShellState()->mIsBackgroundOnly && >+ DisplayListIsContentful(aPaintedContents)) { >+ pc->NotifyContentfulPaint(); >+ } >+ } > } I'm not super happy with checking both non-blank and contentful-paint, even if the pref isn't, but I guess it isn't too slow.
Attachment #9021963 - Flags: review?(bugs) → review+
Minor request, but could we change the bug title to say FCP rather than TCP to avoid confusion and showing up in search results for TCP? Thanks.
Looks like the acronym is TTFCP per https://github.com/paulirish/pwmetrics/blame/cc8d5e7fb009573cc1991c029faf21d5d9e09093/readme.md#L317 -- updating summary to use that acronym.
Summary: Implement Time to First Contentful Paint (TCP) for Telemetry/Profiler → Implement Time to First Contentful Paint (TTFCP) for Telemetry/Profiler
Pushed by rjesup@wgate.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/91659baa6ddb Implement TimeToFirstContentfulPaint behind a pref r=mattwoodrow,smaug
Pushed by rjesup@wgate.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/a10cbfd5f411 Implement TimeToFirstContentfulPaint behind a pref r=mattwoodrow,smaug
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla65
Depends on: 1507714
(In reply to Daniel Holbert [:dholbert] (PTO Fri Nov 16) from comment #21) > Looks like the acronym is TTFCP per > https://github.com/paulirish/pwmetrics/blame/ > cc8d5e7fb009573cc1991c029faf21d5d9e09093/readme.md#L317 -- updating summary > to use that acronym. I too was going to side w/ Philip, as the spec has it listed as FCP as well. https://w3c.github.io/paint-timing/ But I see that Paul's comment was pretty recent.
See Also: → 1603187
Performance Impact: --- → P3
Whiteboard: [qf:p3][perf-tools] → [perf-tools]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: