Title: [259802] trunk
Revision
259802
Author
you...@apple.com
Date
2020-04-09 08:24:53 -0700 (Thu, 09 Apr 2020)

Log Message

Source/WebKit:
[MacOS] REGRESSION (r253275): Stopping a cloned audio capture track should not stop the original audio track
https://bugs.webkit.org/show_bug.cgi?id=210259
<rdar://problem/61466486>

Reviewed by Eric Carlson.

We changed video track cloning so that each cloned track would get its own source.
The source is getting video sample from the real capture source.
The real capture source will get stopped if all its client sources are stopped.

For audio, we are still using the same audio source for each track.
We should thus not close the source until all its tracks are stopped.
To do so, we reuse RealtimeMediaSource::requestToEnd instead of directly sending
the order to stop observing the remote audio source.

Test: fast/mediastream/mediastreamtrack-audio-clone.html

* WebProcess/cocoa/UserMediaCaptureManager.cpp:
(WebKit::UserMediaCaptureManager::Source::requestToEnd):
(WebKit::UserMediaCaptureManager::Source::stopBeingObserved): Deleted.

LayoutTests:
[MacOS] Stopping a cloned audio capture track should not stop the original audio track
https://bugs.webkit.org/show_bug.cgi?id=210259
<rdar://problem/61466486>

Reviewed by Eric Carlson.

* fast/mediastream/mediastreamtrack-audio-clone-expected.txt: Added.
* fast/mediastream/mediastreamtrack-audio-clone.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (259801 => 259802)


--- trunk/LayoutTests/ChangeLog	2020-04-09 15:19:13 UTC (rev 259801)
+++ trunk/LayoutTests/ChangeLog	2020-04-09 15:24:53 UTC (rev 259802)
@@ -1,3 +1,14 @@
+2020-04-09  Youenn Fablet  <you...@apple.com>
+
+        [MacOS] Stopping a cloned audio capture track should not stop the original audio track
+        https://bugs.webkit.org/show_bug.cgi?id=210259
+        <rdar://problem/61466486>
+
+        Reviewed by Eric Carlson.
+
+        * fast/mediastream/mediastreamtrack-audio-clone-expected.txt: Added.
+        * fast/mediastream/mediastreamtrack-audio-clone.html: Added.
+
 2020-04-09  Jason Lawrence  <lawrenc...@apple.com>
 
         [ iOS wk2 ] crypto/subtle/rsa-indexeddb.html is flaky timing out.

Added: trunk/LayoutTests/fast/mediastream/mediastreamtrack-audio-clone-expected.txt (0 => 259802)


--- trunk/LayoutTests/fast/mediastream/mediastreamtrack-audio-clone-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/mediastream/mediastreamtrack-audio-clone-expected.txt	2020-04-09 15:24:53 UTC (rev 259802)
@@ -0,0 +1,5 @@
+
+PASS Stopping the audio track should not stop the audio track clone 
+PASS Stopping the audio track clone should not stop the audio track 
+PASS Collecting the audio track clone should not stop the audio track 
+

Added: trunk/LayoutTests/fast/mediastream/mediastreamtrack-audio-clone.html (0 => 259802)


--- trunk/LayoutTests/fast/mediastream/mediastreamtrack-audio-clone.html	                        (rev 0)
+++ trunk/LayoutTests/fast/mediastream/mediastreamtrack-audio-clone.html	2020-04-09 15:24:53 UTC (rev 259802)
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>Clone an audio capture track.</title>
+    <script src=""
+    <script src=""
+    <script src=""
+    <script src=""
+</head>
+<body>
+<script>
+    var context = new webkitAudioContext();
+    promise_test(async (t) => {
+        const stream = await navigator.mediaDevices.getUserMedia({ audio : true });
+
+        const audioTrack = stream.getAudioTracks()[0];
+        const audioTrackClone = audioTrack.clone();
+
+        audioTrack.stop();
+        await new Promise(resolve => setTimeout(resolve, 100));
+
+        const results = await analyseAudio(new MediaStream([audioTrackClone]), 200, context);
+        assert_true(results.heardHum, "Heard hum from cloned track");
+
+        assert_equals(audioTrack.readyState, "ended");
+        assert_equals(audioTrackClone.readyState, "live");
+    }, "Stopping the audio track should not stop the audio track clone");
+
+    promise_test(async (t) => {
+        const stream = await navigator.mediaDevices.getUserMedia({ audio : true });
+
+        const audioTrack = stream.getAudioTracks()[0];
+        const audioTrackClone = audioTrack.clone();
+
+        audioTrackClone.stop();
+        await new Promise(resolve => setTimeout(resolve, 100));
+
+        const results = await analyseAudio(new MediaStream([audioTrack]), 200, context);
+        assert_true(results.heardHum, "Heard hum from track");
+
+        assert_equals(audioTrackClone.readyState, "ended");
+        assert_equals(audioTrack.readyState, "live");
+    }, "Stopping the audio track clone should not stop the audio track");
+
+    promise_test(async (t) => {
+        const stream = await navigator.mediaDevices.getUserMedia({ audio : true });
+
+        const audioTrack = stream.getAudioTracks()[0];
+        audioTrack.clone();
+        gc();
+
+        await new Promise(resolve => setTimeout(resolve, 100));
+
+        const results = await analyseAudio(new MediaStream([audioTrack]), 200, context);
+        assert_true(results.heardHum, "Heard hum from track");
+
+        assert_equals(audioTrack.readyState, "live");
+    }, "Collecting the audio track clone should not stop the audio track");
+</script>
+</body>
+</html>

Modified: trunk/Source/WebKit/ChangeLog (259801 => 259802)


--- trunk/Source/WebKit/ChangeLog	2020-04-09 15:19:13 UTC (rev 259801)
+++ trunk/Source/WebKit/ChangeLog	2020-04-09 15:24:53 UTC (rev 259802)
@@ -1,3 +1,26 @@
+2020-04-09  Youenn Fablet  <you...@apple.com>
+
+        [MacOS] REGRESSION (r253275): Stopping a cloned audio capture track should not stop the original audio track
+        https://bugs.webkit.org/show_bug.cgi?id=210259
+        <rdar://problem/61466486>
+
+        Reviewed by Eric Carlson.
+
+        We changed video track cloning so that each cloned track would get its own source.
+        The source is getting video sample from the real capture source.
+        The real capture source will get stopped if all its client sources are stopped.
+
+        For audio, we are still using the same audio source for each track.
+        We should thus not close the source until all its tracks are stopped.
+        To do so, we reuse RealtimeMediaSource::requestToEnd instead of directly sending
+        the order to stop observing the remote audio source.
+
+        Test: fast/mediastream/mediastreamtrack-audio-clone.html
+
+        * WebProcess/cocoa/UserMediaCaptureManager.cpp:
+        (WebKit::UserMediaCaptureManager::Source::requestToEnd):
+        (WebKit::UserMediaCaptureManager::Source::stopBeingObserved): Deleted.
+
 2020-04-09  Claudio Saavedra  <csaave...@igalia.com>
 
         [GTK] Clean-up use of deprecated GtkAction

Modified: trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp (259801 => 259802)


--- trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp	2020-04-09 15:19:13 UTC (rev 259801)
+++ trunk/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp	2020-04-09 15:24:53 UTC (rev 259802)
@@ -250,13 +250,10 @@
     void beginConfiguration() final { }
     void commitConfiguration() final { }
     bool setShouldApplyRotation(bool /* shouldApplyRotation */) final;
-
-
     void applyConstraints(const WebCore::MediaConstraints&, ApplyConstraintsHandler&&) final;
+    void requestToEnd(Observer&) final;
+    void stopBeingObserved() final;
 
-    void requestToEnd(RealtimeMediaSource::Observer&) { stopBeingObserved(); }
-    void stopBeingObserved();
-
     RealtimeMediaSourceIdentifier m_id;
     UserMediaCaptureManager& m_manager;
     RealtimeMediaSourceCapabilities m_capabilities;
@@ -504,6 +501,20 @@
     connection()->send(Messages::UserMediaCaptureManagerProxy::RequestToEnd { m_id }, 0);
 }
 
+void UserMediaCaptureManager::Source::requestToEnd(Observer& observer)
+{
+    switch (type()) {
+    case Type::Audio:
+        RealtimeMediaSource::requestToEnd(observer);
+        break;
+    case Type::Video:
+        stopBeingObserved();
+        break;
+    case Type::None:
+        ASSERT_NOT_REACHED();
+    }
+}
+
 CaptureSourceOrError UserMediaCaptureManager::AudioFactory::createAudioCaptureSource(const CaptureDevice& device, String&& hashSalt, const MediaConstraints* constraints)
 {
 #if !ENABLE(GPU_PROCESS)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to