Title: [250663] trunk
Revision
250663
Author
you...@apple.com
Date
2019-10-03 11:09:31 -0700 (Thu, 03 Oct 2019)

Log Message

Regression: iOS 13.1 MediaStreamTrack.enabled = false kills audio track
https://bugs.webkit.org/show_bug.cgi?id=202405
<rdar://problem/55922616>

Reviewed by Eric Carlson.

Source/WebCore:

When the web page is setting enabled to false, media session might change from PlayRecord to None.
This might trigger CoreAudio to no longer output audio samples, thus triggering our audio capture failure timer.
This would end the track after 2 seconds.
Given audio tracks can be reenabled by a web page, we should not change the Media Session setup based on that.
This patch updates MediaStream::mediaType to return independently of the enabled state.

Add internals API to write a cross platform test.

Test: fast/mediastream/audio-track-enabled.html
Manually tested as well.

* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::mediaType const):
* platform/mediastream/MediaStreamPrivate.cpp:
(WebCore::MediaStreamPrivate::hasCaptureAudioSource const):
* testing/Internals.cpp:
(WebCore::Internals::supportsAudioSession const):
(WebCore::Internals::audioSessionCategory const):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

* fast/mediastream/audio-track-enabled-expected.txt: Added.
* fast/mediastream/audio-track-enabled.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (250662 => 250663)


--- trunk/LayoutTests/ChangeLog	2019-10-03 18:07:25 UTC (rev 250662)
+++ trunk/LayoutTests/ChangeLog	2019-10-03 18:09:31 UTC (rev 250663)
@@ -1,5 +1,16 @@
 2019-10-03  youenn fablet  <you...@apple.com>
 
+        Regression: iOS 13.1 MediaStreamTrack.enabled = false kills audio track
+        https://bugs.webkit.org/show_bug.cgi?id=202405
+        <rdar://problem/55922616>
+
+        Reviewed by Eric Carlson.
+
+        * fast/mediastream/audio-track-enabled-expected.txt: Added.
+        * fast/mediastream/audio-track-enabled.html: Added.
+
+2019-10-03  youenn fablet  <you...@apple.com>
+
         http/tests/security/navigate-when-restoring-cached-page.html should not use RTCPeerConnection to not enter in page cache
         https://bugs.webkit.org/show_bug.cgi?id=202521
 

Added: trunk/LayoutTests/fast/mediastream/audio-track-enabled-expected.txt (0 => 250663)


--- trunk/LayoutTests/fast/mediastream/audio-track-enabled-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/mediastream/audio-track-enabled-expected.txt	2019-10-03 18:09:31 UTC (rev 250663)
@@ -0,0 +1,4 @@
+
+
+PASS Check audio session state in case of disabled audio tracks 
+

Added: trunk/LayoutTests/fast/mediastream/audio-track-enabled.html (0 => 250663)


--- trunk/LayoutTests/fast/mediastream/audio-track-enabled.html	                        (rev 0)
+++ trunk/LayoutTests/fast/mediastream/audio-track-enabled.html	2019-10-03 18:09:31 UTC (rev 250663)
@@ -0,0 +1,28 @@
+<body>
+<video id="localVideo" autoplay playsInline></video>
+<script src=""
+<script src=""
+<script>
+
+promise_test(async() => {
+    if (!window.internals)
+       return Promise.reject("Test requires internals API");
+
+    if (!window.internals.supportsAudioSession)
+        return;
+
+    internals.settings.setShouldManageAudioSessionCategory(true);
+
+    let stream = await navigator.mediaDevices.getUserMedia({audio : true});
+
+    localVideo.srcObject = stream;
+    await localVideo.play();
+
+    assert_equals(internals.audioSessionCategory(), "PlayAndRecord");
+
+    stream.getAudioTracks()[0].enabled = false;
+    await new Promise(resolve => setTimeout(resolve, 10));
+    assert_equals(internals.audioSessionCategory(), "PlayAndRecord");
+}, "Check audio session state in case of disabled audio tracks");
+</script>
+</body>

Modified: trunk/Source/WebCore/ChangeLog (250662 => 250663)


--- trunk/Source/WebCore/ChangeLog	2019-10-03 18:07:25 UTC (rev 250662)
+++ trunk/Source/WebCore/ChangeLog	2019-10-03 18:09:31 UTC (rev 250663)
@@ -1,5 +1,34 @@
 2019-10-03  youenn fablet  <you...@apple.com>
 
+        Regression: iOS 13.1 MediaStreamTrack.enabled = false kills audio track
+        https://bugs.webkit.org/show_bug.cgi?id=202405
+        <rdar://problem/55922616>
+
+        Reviewed by Eric Carlson.
+
+        When the web page is setting enabled to false, media session might change from PlayRecord to None.
+        This might trigger CoreAudio to no longer output audio samples, thus triggering our audio capture failure timer.
+        This would end the track after 2 seconds.
+        Given audio tracks can be reenabled by a web page, we should not change the Media Session setup based on that.
+        This patch updates MediaStream::mediaType to return independently of the enabled state.
+
+        Add internals API to write a cross platform test.
+
+        Test: fast/mediastream/audio-track-enabled.html
+        Manually tested as well.
+
+        * Modules/mediastream/MediaStream.cpp:
+        (WebCore::MediaStream::mediaType const):
+        * platform/mediastream/MediaStreamPrivate.cpp:
+        (WebCore::MediaStreamPrivate::hasCaptureAudioSource const):
+        * testing/Internals.cpp:
+        (WebCore::Internals::supportsAudioSession const):
+        (WebCore::Internals::audioSessionCategory const):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
+2019-10-03  youenn fablet  <you...@apple.com>
+
         http/tests/security/navigate-when-restoring-cached-page.html should not use RTCPeerConnection to not enter in page cache
         https://bugs.webkit.org/show_bug.cgi?id=202521
 

Modified: trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp (250662 => 250663)


--- trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp	2019-10-03 18:07:25 UTC (rev 250662)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStream.cpp	2019-10-03 18:09:31 UTC (rev 250663)
@@ -403,7 +403,7 @@
 {
     // We only need to override the type when capturing audio, HTMLMediaElement and/or WebAudio
     // will do the right thing when a stream is attached to a media element or an audio context.
-    if (m_private->hasAudio() && m_isProducingData && m_private->hasCaptureAudioSource())
+    if (m_private->hasCaptureAudioSource())
         return PlatformMediaSession::MediaStreamCapturingAudio;
 
     return PlatformMediaSession::None;

Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp (250662 => 250663)


--- trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp	2019-10-03 18:07:25 UTC (rev 250662)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp	2019-10-03 18:09:31 UTC (rev 250663)
@@ -229,7 +229,7 @@
 bool MediaStreamPrivate::hasCaptureAudioSource() const
 {
     for (auto& track : m_trackSet.values()) {
-        if (track->type() == RealtimeMediaSource::Type::Audio && track->isCaptureTrack())
+        if (track->type() == RealtimeMediaSource::Type::Audio && track->isCaptureTrack() && !track->ended() && !track->muted())
             return true;
     }
     return false;

Modified: trunk/Source/WebCore/testing/Internals.cpp (250662 => 250663)


--- trunk/Source/WebCore/testing/Internals.cpp	2019-10-03 18:07:25 UTC (rev 250662)
+++ trunk/Source/WebCore/testing/Internals.cpp	2019-10-03 18:09:31 UTC (rev 250663)
@@ -4853,6 +4853,15 @@
 }
 #endif
 
+bool Internals::supportsAudioSession() const
+{
+#if USE(AUDIO_SESSION)
+    return true;
+#else
+    return false;
+#endif
+}
+
 String Internals::audioSessionCategory() const
 {
 #if USE(AUDIO_SESSION)

Modified: trunk/Source/WebCore/testing/Internals.h (250662 => 250663)


--- trunk/Source/WebCore/testing/Internals.h	2019-10-03 18:07:25 UTC (rev 250662)
+++ trunk/Source/WebCore/testing/Internals.h	2019-10-03 18:09:31 UTC (rev 250663)
@@ -736,6 +736,7 @@
     void setDisableGetDisplayMediaUserGestureConstraint(bool);
 #endif
 
+    bool supportsAudioSession() const;
     String audioSessionCategory() const;
     double preferredAudioBufferSize() const;
     bool audioSessionActive() const;

Modified: trunk/Source/WebCore/testing/Internals.idl (250662 => 250663)


--- trunk/Source/WebCore/testing/Internals.idl	2019-10-03 18:07:25 UTC (rev 250662)
+++ trunk/Source/WebCore/testing/Internals.idl	2019-10-03 18:09:31 UTC (rev 250663)
@@ -735,6 +735,7 @@
 
     void setConsoleMessageListener(StringCallback callback);
 
+    readonly attribute boolean supportsAudioSession;
     DOMString audioSessionCategory();
     double preferredAudioBufferSize();
     boolean audioSessionActive();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to