Title: [266454] trunk/Source/WebCore
Revision
266454
Author
you...@apple.com
Date
2020-09-02 02:45:29 -0700 (Wed, 02 Sep 2020)

Log Message

Safari is not able to hear audio when using WebRTC in multiple tabs
https://bugs.webkit.org/show_bug.cgi?id=215270
<rdar://problem/66736746>

Reviewed by Eric Carlson.

Covered by manually testing that audio continues when two pages in the same process create a peer connection,
one plays audio with WebRTC and the second one is closed.
Before the patch, the closing page would stop the audio device module, even though the first page would like the module to continue playing.
Fix this by creating an audio module per page instead of process wide.

* platform/mediastream/libwebrtc/LibWebRTCAudioModule.h:
* platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
(WebCore::initializePeerConnectionFactoryAndThreads):
(WebCore::LibWebRTCProvider::factory):
(WebCore::LibWebRTCProvider::createPeerConnectionFactory):
* platform/mediastream/libwebrtc/LibWebRTCProvider.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (266453 => 266454)


--- trunk/Source/WebCore/ChangeLog	2020-09-02 09:31:34 UTC (rev 266453)
+++ trunk/Source/WebCore/ChangeLog	2020-09-02 09:45:29 UTC (rev 266454)
@@ -1,3 +1,23 @@
+2020-09-02  Youenn Fablet  <you...@apple.com>
+
+        Safari is not able to hear audio when using WebRTC in multiple tabs
+        https://bugs.webkit.org/show_bug.cgi?id=215270
+        <rdar://problem/66736746>
+
+        Reviewed by Eric Carlson.
+
+        Covered by manually testing that audio continues when two pages in the same process create a peer connection,
+        one plays audio with WebRTC and the second one is closed.
+        Before the patch, the closing page would stop the audio device module, even though the first page would like the module to continue playing.
+        Fix this by creating an audio module per page instead of process wide.
+
+        * platform/mediastream/libwebrtc/LibWebRTCAudioModule.h:
+        * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
+        (WebCore::initializePeerConnectionFactoryAndThreads):
+        (WebCore::LibWebRTCProvider::factory):
+        (WebCore::LibWebRTCProvider::createPeerConnectionFactory):
+        * platform/mediastream/libwebrtc/LibWebRTCProvider.h:
+
 2020-09-02  Said Abou-Hallawa  <sabouhall...@apple.com>
 
         Unreviewed, reverting r266449.

Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCAudioModule.h (266453 => 266454)


--- trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCAudioModule.h	2020-09-02 09:31:34 UTC (rev 266453)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCAudioModule.h	2020-09-02 09:45:29 UTC (rev 266454)
@@ -40,7 +40,7 @@
 namespace WebCore {
 
 // LibWebRTCAudioModule is pulling streamed data to ensure audio data is passed to the audio track.
-class LibWebRTCAudioModule final : public webrtc::AudioDeviceModule {
+class LibWebRTCAudioModule : public webrtc::AudioDeviceModule {
     WTF_MAKE_FAST_ALLOCATED;
 public:
     LibWebRTCAudioModule();
@@ -52,9 +52,6 @@
         return value;
     }
 
-    void AddRef() const final { }
-    rtc::RefCountReleaseStatus Release() const final { return rtc::RefCountReleaseStatus::kOtherRefsRemained; }
-
     // webrtc::AudioDeviceModule API
     int32_t StartPlayout() final;
     int32_t StopPlayout() final;

Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp (266453 => 266454)


--- trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp	2020-09-02 09:31:34 UTC (rev 266453)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp	2020-09-02 09:45:29 UTC (rev 266454)
@@ -118,7 +118,6 @@
     std::unique_ptr<rtc::Thread> networkThread;
     std::unique_ptr<rtc::Thread> signalingThread;
     bool networkThreadWithSocketServer { false };
-    std::unique_ptr<LibWebRTCAudioModule> audioDeviceModule;
     std::unique_ptr<rtc::NetworkManager> networkManager;
     std::unique_ptr<BasicPacketSocketFactory> packetSocketFactory;
     std::unique_ptr<rtc::RTCCertificateGenerator> certificateGenerator;
@@ -187,8 +186,6 @@
 
     result = factoryAndThreads.signalingThread->Start();
     ASSERT(result);
-
-    factoryAndThreads.audioDeviceModule = makeUnique<LibWebRTCAudioModule>();
 }
 
 static inline PeerConnectionFactoryAndThreads& staticFactoryAndThreads()
@@ -263,14 +260,16 @@
 
     auto& factoryAndThreads = getStaticFactoryAndThreads(m_useNetworkThreadWithSocketServer);
 
-    m_factory = createPeerConnectionFactory(factoryAndThreads.networkThread.get(), factoryAndThreads.networkThread.get(), factoryAndThreads.audioDeviceModule.get());
+    m_factory = createPeerConnectionFactory(factoryAndThreads.networkThread.get(), factoryAndThreads.networkThread.get());
 
     return m_factory;
 }
 
-rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> LibWebRTCProvider::createPeerConnectionFactory(rtc::Thread* networkThread, rtc::Thread* signalingThread, LibWebRTCAudioModule* audioModule)
+rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> LibWebRTCProvider::createPeerConnectionFactory(rtc::Thread* networkThread, rtc::Thread* signalingThread)
 {
-    return webrtc::CreatePeerConnectionFactory(networkThread, signalingThread, signalingThread, audioModule, webrtc::CreateBuiltinAudioEncoderFactory(), webrtc::CreateBuiltinAudioDecoderFactory(), createEncoderFactory(), createDecoderFactory(), nullptr, nullptr);
+    auto audioModule = rtc::scoped_refptr<webrtc::AudioDeviceModule>(new rtc::RefCountedObject<LibWebRTCAudioModule>());
+
+    return webrtc::CreatePeerConnectionFactory(networkThread, signalingThread, signalingThread, WTFMove(audioModule), webrtc::CreateBuiltinAudioEncoderFactory(), webrtc::CreateBuiltinAudioDecoderFactory(), createEncoderFactory(), createDecoderFactory(), nullptr, nullptr);
 }
 
 std::unique_ptr<webrtc::VideoDecoderFactory> LibWebRTCProvider::createDecoderFactory()

Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h (266453 => 266454)


--- trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h	2020-09-02 09:31:34 UTC (rev 266453)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h	2020-09-02 09:45:29 UTC (rev 266454)
@@ -136,7 +136,7 @@
 
     rtc::scoped_refptr<webrtc::PeerConnectionInterface> createPeerConnection(webrtc::PeerConnectionObserver&, rtc::NetworkManager&, rtc::PacketSocketFactory&, webrtc::PeerConnectionInterface::RTCConfiguration&&, std::unique_ptr<webrtc::AsyncResolverFactory>&&);
 
-    rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> createPeerConnectionFactory(rtc::Thread* networkThread, rtc::Thread* signalingThread, LibWebRTCAudioModule*);
+    rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> createPeerConnectionFactory(rtc::Thread* networkThread, rtc::Thread* signalingThread);
     virtual std::unique_ptr<webrtc::VideoDecoderFactory> createDecoderFactory();
     virtual std::unique_ptr<webrtc::VideoEncoderFactory> createEncoderFactory();
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to