Commit 1702c909 authored by Christian Fremerey's avatar Christian Fremerey Committed by Commit Bot

Make test MediaStreamTrack-gc-no-crash deterministic

The Layout Test MediaStreamTrack-gc-no-crash.html was non-determinstic in that
it depend on a race between the JavaScript side declaring the asynchronous test
"finished" and the callback to GetUserMedia arriving.

It appears there were at least 3 possible outcomes. The first case was that
the finishJSTest() would be invoked before the call to GetUserMedia
would do anything much, and the test would essentially verify nothing.
The second case was that when finishJSTest() was invoked, GetUserMedia would
have reach a point where it would have temporarily taken shared ownership
of the blink document but the callbacks would not yet have been invoked.
The third case would be that finishJSTest() would be invoked after the
callback to GetUserMedia had finished running.

It looks like in practice, at least on my local machine, the first case
was the only one reached so far.

When trying to activate the new video capture service with [1], the
timing changed so that the second case would typically be reached. This case
would lead to the leak detector running at the end of the test reporting
leaked blink objects and failing the test. I verified that the same would
happen without activating the video capture service, simply by making the
call to FakeVideoCaptureDeviceFactory::GetDescriptors() taking a bit longer,
via PlatformThread::Sleep().

After this CL, the test should deterministically always reach the third case.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/719416

Bug: 789669
Test: third_party/WebKit/Tools/Scripts/run-webkit-tests --target gn_release --enable-leak-detection fast/mediastream/MediaStreamTrack-gc-no-crash.html
Change-Id: I17c39e66cfd8c4af89f8f9b078d6512feaedbe6d
Reviewed-on: https://chromium-review.googlesource.com/806442Reviewed-by: default avatarHajime Hoshi <hajimehoshi@chromium.org>
Commit-Queue: Christian Fremerey <chfremer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521723}
parent 3f3ee3e4
......@@ -3,6 +3,7 @@ Verify that MediaStreamTracks aren't prematurely garbage collected.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS getUserMedia returned with stream containing a valid video track
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -17,11 +17,20 @@ function finishUp() {
finishJSTest();
}
navigator.webkitGetUserMedia({audio: true,video: true},function (stream) {
var vidTrack = stream.getVideoTracks()[0];
vidTrack.onended = function () { };
}, function () {} );
setTimeout(finishUp);
navigator.webkitGetUserMedia({audio: false,video: true},
// success callback
function (stream) {
var vidTrack = stream.getVideoTracks()[0];
vidTrack.onended = function () {};
testPassed("getUserMedia returned with stream containing a valid video track");
finishUp();
},
// error callback
function () {
testFailed("getUserMedia returned with an error");
finishUp();
}
);
</script>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment