OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <!-- | |
3 Copyright 2017 The Chromium Authors. All rights reserved. | |
4 Use of this source code is governed by a BSD-style license that can be | |
5 found in the LICENSE file. | |
6 --> | |
7 | |
8 <!-- | |
9 media_metrics uses Chrome trace events to calculate metrics about video | |
10 and audio playback. It is meant to be used for pages with a <video> or | |
11 <audio> element. It is used by videostack-eng@google.com team for | |
12 regression testing. | |
13 | |
14 This metric currently supports the following measurement: | |
15 * time_to_play calculates how long after a video is requested to | |
16 start playing before the video actually starts. If time_to_play | |
17 regresses, then users will click to play videos and then have | |
18 to wait longer before the videos start actually playing. | |
19 | |
20 More measurements are expected to be added in the near future, such as: | |
21 * buffering_time | |
22 * seek_time | |
23 * dropped_frame_count | |
24 | |
25 Please inform crouleau@chromium.org and johnchen@chromium.org about | |
26 changes to this file. | |
27 --> | |
28 | |
29 <link rel="import" href="/tracing/metrics/metric_registry.html"> | |
30 <link rel="import" href="/tracing/model/helpers/chrome_model_helper.html"> | |
31 <link rel="import" href="/tracing/value/histogram.html"> | |
32 | |
33 <script> | |
34 'use strict'; | |
35 | |
36 tr.exportTo('tr.metrics', function() { | |
37 function mediaMetric(histograms, model) { | |
38 let playStart; | |
39 let timeToPlay; | |
40 | |
41 const chromeHelper = model.getOrCreateHelper( | |
42 tr.model.helpers.ChromeModelHelper); | |
43 if (chromeHelper === undefined) return; | |
44 for (const rendererHelper of Object.values(chromeHelper.rendererHelpers)) { | |
45 const mainThread = rendererHelper.mainThread; | |
46 const compositorThread = rendererHelper.compositorThread; | |
47 const audioThread = | |
48 rendererHelper.process.findAtMostOneThreadNamed('AudioOutputDevice'); | |
49 if (mainThread !== undefined && | |
benjhayden
2017/08/30 17:25:19
There's a lot of indentation here that is making i
| |
50 (compositorThread !== undefined || audioThread !== undefined)) { | |
51 // Look for the media player DoLoad event on main thread. | |
52 for (const event of mainThread.getDescendantEvents()) { | |
53 if (event.title === 'WebMediaPlayerImpl::DoLoad') { | |
Dale Curtis
2017/08/30 16:04:54
Keep in mind this only works if you ensure that th
| |
54 playStart = event.start; | |
55 break; | |
56 } | |
57 } | |
58 if (playStart === undefined) continue; | |
59 | |
60 // See if we have a video render event. | |
61 if (compositorThread !== undefined) { | |
62 for (const event of compositorThread.getDescendantEvents()) { | |
63 if (event.title === 'VideoRendererImpl::Render') { | |
64 timeToPlay = event.start - playStart; | |
Dale Curtis
2017/08/30 16:04:54
Probably should be timeToVideoPlay and timeToAudio
| |
65 break; | |
66 } | |
67 } | |
68 } | |
69 if (timeToPlay !== undefined) break; | |
70 | |
71 // No video render events. Try audio events instead. | |
72 if (audioThread !== undefined) { | |
73 for (const event of audioThread.getDescendantEvents()) { | |
74 if (event.title === 'AudioRendererImpl::Render') { | |
75 timeToPlay = event.start - playStart; | |
76 break; | |
77 } | |
78 } | |
79 } | |
80 if (timeToPlay !== undefined) break; | |
81 } | |
82 } | |
83 | |
84 if (timeToPlay !== undefined) { | |
85 histograms.createHistogram('time_to_play', | |
86 tr.b.Unit.byName.timeDurationInMs_smallerIsBetter, timeToPlay); | |
87 } | |
88 } | |
89 | |
90 tr.metrics.MetricRegistry.register(mediaMetric); | |
91 | |
92 return { | |
93 mediaMetric, | |
94 }; | |
95 }); | |
96 </script> | |
OLD | NEW |