Closed Bug 1158032 Opened 9 years ago Closed 2 years ago

Implement Frame Timing API

Categories

(Core :: DOM: Core & HTML, enhancement, P5)

enhancement

Tracking

()

RESOLVED WONTFIX

People

(Reporter: hiro, Unassigned)

References

(Depends on 2 open bugs, )

Details

Attachments

(1 file, 6 obsolete files)

This bug will be a tracker bug to implement Frame Timing API.

The spec is: https://w3c.github.io/frame-timing/
Depends on: 1158731
Blocks: 1163901
Attached patch [WIP] buffer type API (obsolete) — Splinter Review
* does not work on E10S yet.
* sourceFrameNumber is not set yet. (I have no idea how to deal with the number between main and compositor threads yet)
* PerformanceCompositeTiming does not work (I do not know why, need to investigate)
* not considered :visible change issue.


This patch breaks unified build, needs a patch. I will post the patch in a new bug for the unified build issue.
Depends on: 1164366
Awesome to see quick progress -- great stuff! :)

As a heads up, both Chrome and IE are planning to block and ship FT on Performance Observer. To be specific, the plan is to update the FT spec and remove the buffer based API entirely and only provide access to FT events via Performance Observer. Related GH bug: https://github.com/w3c/frame-timing/issues/20 - we should probably make this more clear in the spec itself as well.

[1] https://github.com/w3c/frame-timing/issues/20
Depends on: 1165796
Ilya, thanks for the info.
I've opened a new bug for Performance Observer and set the dependency. Bug 1165796.

My plan here is to implement buffer base Frame Timing API and confirm its basic behavior first, then rewrite it with observer.
Attached patch [WIP] buffer type API v2 (obsolete) — Splinter Review
Changes from previous one:

* Add basic mochitests.
* Works on e10s partially. (will not work in iframe)
Attachment #8605118 - Attachment is obsolete: true
Yep, makes sense.. We're taking the same approach in Chrome as well. Let me know if you run into any questions or issues while you're at it :)
Attached patch [WIP] buffer type API v3 (obsolete) — Splinter Review
Changes from v2
* Add mochitests in iframe
* Works in iframe
Attachment #8606860 - Attachment is obsolete: true
Depends on: 1167487
Attached patch [WIP] buffer type API v4 (obsolete) — Splinter Review
This patch relies on the patch for bug 1167487.

The buffer type API works fine in most cases.

Remaining issues

* layout/base/tests/chrome/test_bug533845.xul crashes on Windows 8 and XP.
* The startTime in PerformanceRenderTiming does not match rAF time on Android opt builds
* :visited link handling
Attachment #8607918 - Attachment is obsolete: true
Depends on: 1168726
(In reply to Hiroyuki Ikezoe (:hiro) from comment #7)
> * The startTime in PerformanceRenderTiming does not match rAF time on
> Android opt builds

It turned out that the failure is intermittent and happens both opt and debug debuilds. And the failure reason is that the main thread on Android emulator is too busy to get RenderTiming in mochitest.
Depends on: 1169531
I am going to handle :visited link issue in a separate bug. Bug 1169531.
Attached patch [WIP] buffer type API v5 (obsolete) — Splinter Review
This patch relies on attachment 8612703 [details] [diff] [review] for bug 1167487.

Changes from v4:

* Adapted to the latest nsPerformance changes by bug 1155761
* Fix mismatch of rAF time partially. Still fails on Android 2.3 emulator.
* Rewrite test with testharness.js

The crash on Windows XP/8 will be handled in another bug. I will post a patch against the crashed test in the bug.
Attachment #8610286 - Attachment is obsolete: true
(In reply to Hiroyuki Ikezoe (:hiro) from comment #11)

> The crash on Windows XP/8 will be handled in another bug. I will post a
> patch against the crashed test in the bug.

Filed 1170448.
Depends on: 1170448
Attached patch [WIP] buffer type API v6 (obsolete) — Splinter Review
Changes from v5:
* Fix time lag between rAF time and render startTime.
* Add some test cases
* Split test into smaller test cases
  some of these tests could be merged into web platform tests
* Fix a problem that render event is recorded even if there is no paint event.
Attachment #8613901 - Attachment is obsolete: true
This patch no longer relies on the patch for bug 1167487
This patch makes web platform tests for Frame Timing API (with a few modifications for Firefox) [1] success.

[1] https://github.com/w3c/web-platform-tests/pull/1894

In the previous patch, each frame number is advanced in each vsync frame, but current Chromium implementation of Frame Timing API does not so. The behavior of the frame number on Chromium is similar to transaction id in gecko.  So I've changed out implementation to adapt the Chromium's frame number behavior.

An example of Frame Timing entries on a CSS animation

Firefox with this patch
=======
render
[ startTime,  frameNumber ]
[ 1049.048, 19 ]

composite
[ startTime,  frameNumber ]
[ 1066.255, 19 ]
[ 1082.349, 19 ]
[ 1099.668, 19 ]
[ 1115.791, 19 ]
[ 1132.987, 19 ]
[ 1149.133, 19 ]
[ 1166.272, 19 ]
[ 1182.384, 19 ]
[ 1199.567, 19 ]
[ 1215.962, 19 ]
[ 1232.884, 19 ]
[ 1249.018, 19 ]
[ 1266.123, 19 ]
[ 1282.230, 19 ]
[ 1299.262, 19 ]
[ 1316.366, 19 ]
[ 1332.454, 19 ]
[ 1349.563, 19 ]
[ 1365.671, 19 ]
[ 1382.788, 19 ]
[ 1398.863, 19 ]
[ 1415.947, 19 ]
[ 1432.043, 19 ]
[ 1449.169, 19 ]
[ 1466.384, 19 ]
[ 1482.530, 19 ]
[ 1499.671, 19 ]
[ 1515.883, 19 ]
[ 1533.045, 19 ]

Chromium 45.0.2438.0
========

render
[ startTime,  frameNumber ]
[ 1144.354, 2 ]
[ 1161.020, 2 ]
composite"
[ startTime,  frameNumber ]
[ 1144.354, 2 ]
[ 1161.020, 2 ]
[ 1177.686, 2 ]
[ 1194.369, 2 ]
[ 1211.034, 2 ]
[ 1227.717, 2 ]
[ 1244.393, 2 ]
[ 1261.053, 2 ]
[ 1277.704, 2 ] 
[ 1294.382, 2 ]
[ 1311.052, 2 ]
[ 1327.724, 2 ]
[ 1344.380, 2 ]
[ 1361.048, 2 ]
[ 1377.724, 2 ]
[ 1394.395, 2 ]
[ 1411.032, 2 ]
[ 1427.726, 2 ]
[ 1444.381, 2 ]
[ 1461.048, 2 ]
[ 1477.725, 2 ] 
[ 1494.367, 2 ]
[ 1511.055, 2 ]
[ 1527.703, 2 ]
[ 1544.386, 2 ]
[ 1561.058, 2 ]

As you can see there are some differences:

1. Firefox starts compositor events from a subsequent frame but Chromium starts it in the same frame.
2. Chromium renders something in the second frame.
Attachment #8624050 - Attachment is obsolete: true
Depends on: 1191178
No longer depends on: 1170448
No longer depends on: 1167487
Depends on: 1197003
Depends on: 1198548
Note that the spec has been updated to use the "slow-only" model:
- background: https://github.com/w3c/frame-timing/pull/48
- new draft: https://w3c.github.io/frame-timing/
See Also: → 1178972
Priority: -- → P5
Component: DOM → DOM: Core & HTML

Did this die?

Severity: normal → --
Type: defect → enhancement

I suppose I can provide more clarity as well:

I’m on the Photoshop for Web team at Adobe. We’re looking for a solid way to programmatically track frames per second on a number of devices. Right now I’m just doing this with requestAnimationFrame and timers, but it doesn’t feel terribly accurate.

I believe this spec has been abandoned. According to https://wicg.github.io/frame-timing/

This work is NO LONGER BEING PURSUED. It's left here for historical purposes.

Regarding requestAnimationFrame, you can use the timestamp passed-in the to callback to get the frame time (or query document.timeline.currentTime for the same value) although I agree it is less than ideal.

Thank you for these tips! These definitely look more accurate than using performance.now. I had never even heard of document.timeline.currentTime.

If the spec has been abandoned, should we close this and linked bugs as WONTFIX?

Flags: needinfo?(brian)

Yes, sounds good.

Flags: needinfo?(brian)

Spec has been abandoned.

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → WONTFIX
Keywords: dev-doc-needed
You need to log in before you can comment on or make changes to this bug.