Add window.mozPaintCount API




8 years ago
8 years ago


(Reporter: roc, Assigned: roc)



Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)



(1 attachment)

I would like chrome and even Web content to be able to easily and accurately measure frames-per-second graphics performance.

Therefore I propose adding a new API to the Window object: mozPaintCount, a readonly 'long long' attribute, accessible to Web content as well as chrome. This would simply return the number of times the presshell for the current document in the window has been rendered to the screen.

I have a patch to implement this. This makes it really easy for Web content to calculate frames-per-second. Currently, presshells that are clipped out or otherwise not visible do not get their counters updated. We might want to change that later so that there's only a per-toplevel-window counter, but I think that's fine.
So in practice this will never show framerates above 50Hz once we have painting also hooked up to refresh driver, right?
Yes, if there is no way to force synchronous repainting.

(Well, we might want to raise the refresh-driver limit to 60Hz or something.)
You can actually get the correct limit from the OS on most platforms.
Created attachment 443566 [details] [diff] [review]

OK, here it is.
Attachment #443566 - Flags: superreview?(vladimir)
Attachment #443566 - Flags: review?(Olli.Pettay)

Comment 5

8 years ago
Comment on attachment 443566 [details] [diff] [review]

>+  /**
>+   * Keep track of how many times this presshell has been rendered to
>+   * a window.
>+   */
>+  PRUint64 GetFrameCount() { return mFrameCount; }
>+  void IncrementFrameCount() { ++mFrameCount; }
I would use some other names for these.
We have so many different "frames" (nsIFrame, <iframe> etc) already.
PaintCount() and IncrementPaintCount()?

Btw, GetXXX isn't IMO needed here, since the method returns always some
valid value.

>+  // Count of the number of times this presshell has been painted to
>+  // a window
>+  PRUint64                  mFrameCount;
mPaintCount? mRenderingCount?

>+++ b/layout/base/nsLayoutUtils.cpp
>@@ -1173,16 +1173,19 @@ nsLayoutUtils::PaintFrame(nsIRenderingCo
>   nsDisplayList list;
>   nsRect dirtyRect = aDirtyRegion.GetBounds();
>   if (aFlags & PAINT_IN_TRANSFORM) {
>     builder.SetInTransform(PR_TRUE);
>   }
>   if (aFlags & PAINT_SYNC_DECODE_IMAGES) {
>     builder.SetSyncDecodeImages(PR_TRUE);
>   }
>+  if (aFlags & PAINT_WIDGET_LAYERS) {
>+    builder.SetPaintingToWindow(PR_TRUE);
>+  }
I'm not at all familiar with this code, but vlad probably is.

mozPaintCount isn't quickstubbed, so I hope no one will use it in a tight loop.
Attachment #443566 - Flags: review?(Olli.Pettay) → review+
Comment on attachment 443566 [details] [diff] [review]

I like smaug's suggestion of calling the internal API GetPaintCount as well, especially since the content-side is mozPaintCount.
Attachment #443566 - Flags: superreview?(vladimir) → superreview+
yeah. I renamed the external API because 'frame' is too overloaded, so I should change the internals to match.
Whiteboard: [needs landing]
Last Resolved: 8 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Whiteboard: [needs landing]
Keywords: dev-doc-needed
Now documented here:

With links added from the main DOM window reference page, and from Firefox 4 for developers.
Keywords: dev-doc-needed → dev-doc-complete
You need to log in before you can comment on or make changes to this bug.