RealtimeIncomingAudioSource is not stopping properly
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Mar 2017 17:16:51 +0000 (17:16 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Mar 2017 17:16:51 +0000 (17:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=169807

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

Source/WebCore:

Test: webrtc/release-after-getting-track.html

* platform/mediastream/mac/RealtimeIncomingAudioSource.cpp:
(WebCore::RealtimeIncomingAudioSource::~RealtimeIncomingAudioSource):
(WebCore::RealtimeIncomingAudioSource::stopProducingData):

LayoutTests:

* webrtc/release-after-getting-track-expected.txt: Added.
* webrtc/release-after-getting-track.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214108 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/webrtc/release-after-getting-track-expected.txt [new file with mode: 0644]
LayoutTests/webrtc/release-after-getting-track.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.cpp

index b264a12..c9ca718 100644 (file)
@@ -1,3 +1,13 @@
+2017-03-17  Youenn Fablet  <youenn@apple.com>
+
+        RealtimeIncomingAudioSource is not stopping properly
+        https://bugs.webkit.org/show_bug.cgi?id=169807
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/release-after-getting-track-expected.txt: Added.
+        * webrtc/release-after-getting-track.html: Added.
+
 2017-03-17  Miguel Gomez  <magomez@igalia.com>
 
         Follow-up (r213833): write a layout test for 169199
diff --git a/LayoutTests/webrtc/release-after-getting-track-expected.txt b/LayoutTests/webrtc/release-after-getting-track-expected.txt
new file mode 100644 (file)
index 0000000..2855ff6
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS Ensuring collecting tracks does not lead to crashing 
+
diff --git a/LayoutTests/webrtc/release-after-getting-track.html b/LayoutTests/webrtc/release-after-getting-track.html
new file mode 100644 (file)
index 0000000..fb65250
--- /dev/null
@@ -0,0 +1,36 @@
+<!doctype html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>Testing garbage collection after getting tracks</title>
+        <script src="../resources/testharness.js"></script>
+        <script src="../resources/testharnessreport.js"></script>
+    </head>
+    <body>
+        <script src ="routines.js"></script>
+        <script>
+promise_test((test) => {
+    if (window.testRunner)
+        testRunner.setUserMediaPermission(true);
+
+    return navigator.mediaDevices.getUserMedia({ video: true, audio: true}).then((stream) => {
+        return new Promise((resolve, reject) => {
+            if (window.internals)
+                internals.useMockRTCPeerConnectionFactory("TwoRealPeerConnections");
+
+            createConnections((firstConnection) => {
+                firstConnection.addStream(stream);
+            }, (secondConnection) => {
+                secondConnection.ontrack = resolve;
+            });
+            setTimeout(() => reject("Test timed out"), 5000);
+        });
+    }).then(() => {
+        if (window.GCController)
+            window.GCController.collect();
+        waitFor(1000);
+    });
+}, "Ensuring collecting tracks does not lead to crashing");
+        </script>
+    </body>
+</html>
index 6384037..a88203c 100644 (file)
@@ -1,3 +1,16 @@
+2017-03-17  Youenn Fablet  <youenn@apple.com>
+
+        RealtimeIncomingAudioSource is not stopping properly
+        https://bugs.webkit.org/show_bug.cgi?id=169807
+
+        Reviewed by Eric Carlson.
+
+        Test: webrtc/release-after-getting-track.html
+
+        * platform/mediastream/mac/RealtimeIncomingAudioSource.cpp:
+        (WebCore::RealtimeIncomingAudioSource::~RealtimeIncomingAudioSource):
+        (WebCore::RealtimeIncomingAudioSource::stopProducingData):
+
 2017-03-16  Alex Christensen  <achristensen@webkit.org>
 
         Use completion handlers instead of return values for sending websocket data
index 2ff8aa9..7df1a62 100644 (file)
@@ -63,6 +63,7 @@ RealtimeIncomingAudioSource::~RealtimeIncomingAudioSource()
         m_audioSourceProvider->unprepare();
         m_audioSourceProvider = nullptr;
     }
+    stopProducingData();
 }
 
 
@@ -121,7 +122,7 @@ void RealtimeIncomingAudioSource::startProducingData()
 
 void RealtimeIncomingAudioSource::stopProducingData()
 {
-    if (m_isProducingData)
+    if (!m_isProducingData)
         return;
 
     m_isProducingData = false;