Wpt: Need mock MediaStream data for some WebRTC tests

Created on 20 Sep 2017  路  12Comments  路  Source: web-platform-tests/wpt

Currently 6 files in webrtc/ use getUserMedia(), and these will simply time out if run on a vanilla browser with no extra command line flags.

To run these WebRTC tests, a MediaStream is needed, so one of the following is needed:

  • WebDriver APIs that make the getUserMedia() calls work, bypassing permissions and providing mock data.
  • Depend on canvas.captureStream() or video.captureStream() (not widely supported)

See also https://github.com/w3c/web-platform-tests/issues/5671, the permissions problem would also have to be addressed to make the tests work.

infra mediacapture-streams roadmap testdriver.js untestable webrtc

Most helpful comment

FWIW it should be simple to whip up fake audio tracks using web audio. See my old blog.

All 12 comments

In many of the tests, the only reason getUserMedia() is called is because we need to pass on an instance of MediaStreamTrack. Ideally I'd like to be able to create mock instances of MediaStreamTrack for testing without having to depend on getUserMedia().

There is an alternative hackish way of creating instance of MediaStreamTrack, via new RTCPeerConnection().addTransceiver().receiver.track. But transceivers are not yet supported on most browsers, so we still use getUserMedia() for the moment.

@soareschen, doesn't any data need to pass through the MediaStreamTrack for the tests to work? Certainly some tests should exercise that code path.

@youennf @burg @eric-carlson, any thoughts on how to do this? I think we're leaning heavily towards some kind of WebDriver mocking API, see the second bullet of https://github.com/w3c/wptdashboard/issues/125.

@foolip It depends on what is being tested. We haven't done much interoperability tests in WPT to make sure the media content is streamed properly to the other peer. You are right that _some_ tests still need real MediaStreamTrack to work, so having mock MediaStream is essential for testing WebRTC.

For WebKit, captureStream would be an option but ICE candidate filtering would probably make the test fail. Using getUserMedia seems the best option and is closer to what most web developers will do anyway.

FWIW it should be simple to whip up fake audio tracks using web audio. See my old blog.

@agouaillard, can you poke this issue when you have an update on https://github.com/w3c/web-platform-tests/issues/5563#issuecomment-297281843?

Is this still blocked on adding a WebDriver API?

To run these WebRTC tests, a MediaStream is needed, so one of the following
is needed:

  • WebDriver APIs that make the getUserMedia() calls work, bypassing
    permissions and providing mock data.
  • Depend on canvas.captureStream() or video.captureStream() (not widely
    supported)

I think we should prefer the second approach because it will improve coverage of real-world code paths. @youennf is right to point out that using streams produced by getUserMedia is "what most web developers will do anyway," but most web developers will not be using fake streams produced by a
WebDriver-enabled stub of getUserMedia. They might be making applications where peers share pixel data in real time, though.

Browser support for canvas.captureStream is not as high as getUserMedia, but browser support for the as-yet-unspecified WebDriver endpoint is even worse :)

I've submitted a patch along these lines here: gh-10746. @jan-ivar you may be interested in that because I had to expand on the approach from your blog post in order to get things working in Chromium.

Is this still blocked on adding a WebDriver API?

@alijuma: we may get some clarity from the review of that patch.

@jugglinmike if we go with something like https://github.com/w3c/web-platform-tests/pull/10746, I wonder what you think we should do for testing of getUserMedia itself, i.e., the mediacapture-streams directory. @guidou, WDYT?

I have some ideas about this, but I'll need a little more space to explain. I'll follow up with you offline before elaborating here on GitHub.

With https://github.com/web-platform-tests/wpt/pull/10746 this is arguably resolved, but testing of getUserMedia() itself is still a problem. I'll file another issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gsnedders picture gsnedders  路  14Comments

jdm picture jdm  路  11Comments

bzbarsky picture bzbarsky  路  8Comments

guest271314 picture guest271314  路  10Comments

snuggs picture snuggs  路  13Comments