getUserMedia is resolving before the document knows it is capturing
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Dec 2017 01:39:36 +0000 (01:39 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Dec 2017 01:39:36 +0000 (01:39 +0000)
commitaae7057dfbf7e21879a6fe1fcb5e700aa753e906
tree29180207738b7e13b7db0c3ee00c2aa003e8cc7d
parentd3b8af102b56f95cfeef723281fbc4d9064f38b2
getUserMedia is resolving before the document knows it is capturing
https://bugs.webkit.org/show_bug.cgi?id=180699

Patch by Youenn Fablet <youenn@apple.com> on 2017-12-12
Reviewed by Eric Carlson.

Source/WebCore:

Covered by updated test.

Ensure the document state is capturing when getUserMedia promise is resolved by doing the following:
- Promise is resolved when MediaStream is producing data.
- MediaStream asks Document to update its state when MediaStream state is updated.

Introduce PendingActivationMediaStream for waiting for the MediaStream to produce data.

* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::statusDidChange):
* Modules/mediastream/UserMediaRequest.cpp:
(WebCore::UserMediaRequest::allow):
(WebCore::UserMediaRequest::contextDestroyed):
(WebCore::UserMediaRequest::PendingActivationMediaStream::PendingActivationMediaStream):
(WebCore::UserMediaRequest::PendingActivationMediaStream::~PendingActivationMediaStream):
(WebCore::UserMediaRequest::PendingActivationMediaStream::characteristicsChanged):
(WebCore::UserMediaRequest::mediaStreamIsReady):
* Modules/mediastream/UserMediaRequest.h:
(WebCore::UserMediaRequest::PendingActivationMediaStream::create):
* platform/mediastream/RealtimeMediaSourceCenter.h:
* WebCore/WebCore.xcodeproj/project.pbxproj:

LayoutTests:

* webrtc/video.html: Adding a check that document is capturing within getUserMedia promise resolution callback.
Adding this check without the changes to WebCore makes the test flaky, sometimes the promise resolution happens
after document state is updated.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225828 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/webrtc/video.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/MediaStream.cpp
Source/WebCore/Modules/mediastream/UserMediaRequest.cpp
Source/WebCore/Modules/mediastream/UserMediaRequest.h
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.h