Skip to content

Commit

Permalink
[BreakoutBox] Replace MSTP::is_pending_pull_ with a counter
Browse files Browse the repository at this point in the history
|is_pending_pull_| was used to make sure that frames were made available
to the stream only if there was a pending pull request.

However, if multiple pull requests are issued and then no more pull
requests arrive, some of the corresponding read requests will remain
unsettled when |is_pending_pull_| becomes false.

This CL fixes this by replacing the boolean |is_pending_pull_| with a
counter.

Bug: 1218120
Change-Id: I0ffc038a73a6cd1d387dc17e9c21f2c62fc50613
  • Loading branch information
Guido Urdaneta authored and chromium-wpt-export-bot committed Jun 11, 2021
1 parent 5a38eb7 commit f54a2c8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lint.ignore
Expand Up @@ -814,3 +814,5 @@ DUPLICATE-BASENAME-PATH: dom/nodes/ParentNode-querySelector-All-content.html
DUPLICATE-BASENAME-PATH: dom/nodes/ParentNode-querySelector-All-content.xht
DUPLICATE-BASENAME-PATH: svg/struct/reftests/reference/green-100x100.html
DUPLICATE-BASENAME-PATH: svg/struct/reftests/reference/green-100x100.svg

SET TIMEOUT: mediacapture-insertable-streams/MediaStreamTrackProcessor-video.https.html
Expand Up @@ -45,6 +45,48 @@ <h1 class="instructions">Description</h1>
[processor.readable]);
return promise;
}, "Tests that the reader of a video MediaStreamTrackProcessor produces VideoFrame objects and is closed on track stop while running on a worker");

function makeVideoFrame() {
const canvas = new OffscreenCanvas(100, 100);
const ctx = canvas.getContext('2d');
return new VideoFrame(canvas);
}

promise_test(async t => {
// The generator will be used as the source for the processor to
// produce frames in a controlled manner.
const generator = new MediaStreamTrackGenerator('video');
// Use a larger maxBufferSize than the default to ensure no frames
// will be dropped.
const processor = new MediaStreamTrackProcessor({track: generator, maxBufferSize:10});
const reader = processor.readable.getReader();
const writer = generator.writable.getWriter();

let numReads = 0;
let resolve = null;
const promise = new Promise(r => resolve = r);

const numOperations = 4;
// Issue reads without waiting for the frames to arrive.
for (let i = 0; i < numOperations; i++) {
reader.read().then(dv=> {
dv.value.close();
if (++numReads == numOperations)
resolve();
});
}

// Write video frames in different tasks to "slowly" settle the pending read
// requests.
for (let i = 0; i<numOperations; i++) {
await writer.write(makeVideoFrame());
await new Promise(r=>setTimeout(r,0));
}

return promise;

}, "Tests that multiple read requests are eventually settled");

</script>
</body>
</html>

0 comments on commit f54a2c8

Please sign in to comment.