mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1741244 - p6: wait for frame encoded in capture throttle test. r=jib
Initializing platform encoders often takes some time and the frame rate measured is lower than actual number when the counting starts as soon as connection established. Delaying the measurement until there is at least some frame encoded makes it more accurate. Differential Revision: https://phabricator.services.mozilla.com/D141513
This commit is contained in:
parent
4087c24a22
commit
0b6b47af6f
@ -96,18 +96,20 @@ async function measureCanvasCaptureFrameRate(captureRate) {
|
||||
[...stats.values()].find(({type}) => type == "outbound-rtp");
|
||||
return outbound?.framesEncoded ?? 0;
|
||||
};
|
||||
is(await getFrameCount(), 0, "frame count starts at 0");
|
||||
// Wait for frame count change to ensure sender is working.
|
||||
while (await getFrameCount() == 0) {
|
||||
h.drawColor(c, h.green);
|
||||
await new Promise(resolve => setTimeout(resolve, intervalMillis));
|
||||
}
|
||||
const startFrameCount = await getFrameCount();
|
||||
const start = performance.now();
|
||||
let end;
|
||||
while(true) {
|
||||
let end = start;
|
||||
while(end - start <= 1000) {
|
||||
h.drawColor(c, h.green);
|
||||
await new Promise(resolve => setTimeout(resolve, intervalMillis));
|
||||
end = performance.now();
|
||||
if (end - start > 1000) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
const framerate = (await getFrameCount()) / ((end - start) / 1000);
|
||||
const framerate = (await getFrameCount() - startFrameCount) / ((end - start) / 1000);
|
||||
pc1.close();
|
||||
pc2.close();
|
||||
return framerate;
|
||||
|
Loading…
Reference in New Issue
Block a user