Title: [279584] trunk/Source/WebKit
Revision
279584
Author
you...@apple.com
Date
2021-07-06 09:02:24 -0700 (Tue, 06 Jul 2021)

Log Message

REGRESSION: [iOS] ASSERTION FAILED: !m_messageReceiverMapCount under WebKit::RemoteRemoteCommandListener::~RemoteRemoteCommandListener()
https://bugs.webkit.org/show_bug.cgi?id=226248
<rdar://problem/78481758>

Reviewed by Eric Carlson.

Make sure to remove message receiver on the same gpu process connection it was added.
Also make sure to recreate remote command listener every time we use a new connection.
Do the same thing for RemoteAudioHardwareListener.
Also make sure to remove message receiver in RemoteRenderingBackendProxy::gpuProcessConnectionDidClose

Covered by existing tests.

* WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
(WebKit::RemoteRenderingBackendProxy::gpuProcessConnectionDidClose):
* WebProcess/GPU/media/RemoteAudioHardwareListener.cpp:
(WebKit::RemoteAudioHardwareListener::RemoteAudioHardwareListener):
(WebKit::RemoteAudioHardwareListener::~RemoteAudioHardwareListener):
* WebProcess/GPU/media/RemoteAudioHardwareListener.h:
* WebProcess/GPU/media/RemoteRemoteCommandListener.cpp:
(WebKit::RemoteRemoteCommandListener::RemoteRemoteCommandListener):
(WebKit::RemoteRemoteCommandListener::~RemoteRemoteCommandListener):
(WebKit::RemoteRemoteCommandListener::ensureGPUProcessConnection):
(WebKit::RemoteRemoteCommandListener::gpuProcessConnectionDidClose):
(WebKit::RemoteRemoteCommandListener::updateSupportedCommands):
* WebProcess/GPU/media/RemoteRemoteCommandListener.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (279583 => 279584)


--- trunk/Source/WebKit/ChangeLog	2021-07-06 16:00:16 UTC (rev 279583)
+++ trunk/Source/WebKit/ChangeLog	2021-07-06 16:02:24 UTC (rev 279584)
@@ -1,3 +1,32 @@
+2021-07-06  Youenn Fablet  <you...@apple.com>
+
+        REGRESSION: [iOS] ASSERTION FAILED: !m_messageReceiverMapCount under WebKit::RemoteRemoteCommandListener::~RemoteRemoteCommandListener()
+        https://bugs.webkit.org/show_bug.cgi?id=226248
+        <rdar://problem/78481758>
+
+        Reviewed by Eric Carlson.
+
+        Make sure to remove message receiver on the same gpu process connection it was added.
+        Also make sure to recreate remote command listener every time we use a new connection.
+        Do the same thing for RemoteAudioHardwareListener.
+        Also make sure to remove message receiver in RemoteRenderingBackendProxy::gpuProcessConnectionDidClose
+
+        Covered by existing tests.
+
+        * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
+        (WebKit::RemoteRenderingBackendProxy::gpuProcessConnectionDidClose):
+        * WebProcess/GPU/media/RemoteAudioHardwareListener.cpp:
+        (WebKit::RemoteAudioHardwareListener::RemoteAudioHardwareListener):
+        (WebKit::RemoteAudioHardwareListener::~RemoteAudioHardwareListener):
+        * WebProcess/GPU/media/RemoteAudioHardwareListener.h:
+        * WebProcess/GPU/media/RemoteRemoteCommandListener.cpp:
+        (WebKit::RemoteRemoteCommandListener::RemoteRemoteCommandListener):
+        (WebKit::RemoteRemoteCommandListener::~RemoteRemoteCommandListener):
+        (WebKit::RemoteRemoteCommandListener::ensureGPUProcessConnection):
+        (WebKit::RemoteRemoteCommandListener::gpuProcessConnectionDidClose):
+        (WebKit::RemoteRemoteCommandListener::updateSupportedCommands):
+        * WebProcess/GPU/media/RemoteRemoteCommandListener.h:
+
 2021-07-06  Chris Dumez  <cdu...@apple.com>
 
         Unreviewed, reverting r279495.

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp (279583 => 279584)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp	2021-07-06 16:00:16 UTC (rev 279583)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp	2021-07-06 16:02:24 UTC (rev 279584)
@@ -86,7 +86,9 @@
 void RemoteRenderingBackendProxy::gpuProcessConnectionDidClose(GPUProcessConnection& previousConnection)
 {
     previousConnection.removeClient(*this);
+    previousConnection.messageReceiverMap().removeMessageReceiver(*this);
     m_gpuProcessConnection = nullptr;
+
     m_remoteResourceCacheProxy.remoteResourceCacheWasDestroyed();
 
     m_identifiersOfReusableHandles.clear();

Modified: trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioHardwareListener.cpp (279583 => 279584)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioHardwareListener.cpp	2021-07-06 16:00:16 UTC (rev 279583)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioHardwareListener.cpp	2021-07-06 16:02:24 UTC (rev 279584)
@@ -44,20 +44,19 @@
 
 RemoteAudioHardwareListener::RemoteAudioHardwareListener(AudioHardwareListener::Client& client, WebProcess& webProcess)
     : AudioHardwareListener(client)
-    , m_process(webProcess)
     , m_identifier(RemoteAudioHardwareListenerIdentifier::generate())
+    , m_gpuProcessConnection(makeWeakPtr(WebProcess::singleton().ensureGPUProcessConnection()))
 {
-    auto& connection = WebProcess::singleton().ensureGPUProcessConnection();
-    connection.addClient(*this);
-    connection.messageReceiverMap().addMessageReceiver(Messages::RemoteAudioHardwareListener::messageReceiverName(), m_identifier.toUInt64(), *this);
-    connection.connection().send(Messages::GPUConnectionToWebProcess::CreateAudioHardwareListener(m_identifier), { });
+    m_gpuProcessConnection->addClient(*this);
+    m_gpuProcessConnection->messageReceiverMap().addMessageReceiver(Messages::RemoteAudioHardwareListener::messageReceiverName(), m_identifier.toUInt64(), *this);
+    m_gpuProcessConnection->connection().send(Messages::GPUConnectionToWebProcess::CreateAudioHardwareListener(m_identifier), { });
 }
 
 RemoteAudioHardwareListener::~RemoteAudioHardwareListener()
 {
-    if (auto* connection = WebProcess::singleton().existingGPUProcessConnection()) {
-        connection->messageReceiverMap().removeMessageReceiver(*this);
-        connection->connection().send(Messages::GPUConnectionToWebProcess::ReleaseAudioHardwareListener(m_identifier), 0);
+    if (m_gpuProcessConnection) {
+        m_gpuProcessConnection->messageReceiverMap().removeMessageReceiver(*this);
+        m_gpuProcessConnection->connection().send(Messages::GPUConnectionToWebProcess::ReleaseAudioHardwareListener(m_identifier), 0);
     }
 }
 

Modified: trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioHardwareListener.h (279583 => 279584)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioHardwareListener.h	2021-07-06 16:00:16 UTC (rev 279583)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioHardwareListener.h	2021-07-06 16:02:24 UTC (rev 279584)
@@ -64,8 +64,8 @@
     void audioHardwareDidBecomeInactive();
     void audioOutputDeviceChanged(size_t bufferSizeMinimum, size_t bufferSizeMaximum);
 
-    WebProcess& m_process;
     RemoteAudioHardwareListenerIdentifier m_identifier;
+    WeakPtr<GPUProcessConnection> m_gpuProcessConnection;
 };
 
 }

Modified: trunk/Source/WebKit/WebProcess/GPU/media/RemoteRemoteCommandListener.cpp (279583 => 279584)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteRemoteCommandListener.cpp	2021-07-06 16:00:16 UTC (rev 279583)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteRemoteCommandListener.cpp	2021-07-06 16:02:24 UTC (rev 279584)
@@ -48,25 +48,38 @@
     , m_process(webProcess)
     , m_identifier(RemoteRemoteCommandListenerIdentifier::generate())
 {
-    auto& connection = m_process.ensureGPUProcessConnection();
-    connection.addClient(*this);
-    connection.messageReceiverMap().addMessageReceiver(Messages::RemoteRemoteCommandListener::messageReceiverName(), m_identifier.toUInt64(), *this);
-    connection.connection().send(Messages::GPUConnectionToWebProcess::CreateRemoteCommandListener(m_identifier), { });
+    ensureGPUProcessConnection();
 }
 
 RemoteRemoteCommandListener::~RemoteRemoteCommandListener()
 {
-    if (auto* gpuProcessConnection = m_process.existingGPUProcessConnection()) {
-        gpuProcessConnection->messageReceiverMap().removeMessageReceiver(*this);
-        gpuProcessConnection->connection().send(Messages::GPUConnectionToWebProcess::ReleaseRemoteCommandListener(m_identifier), 0);
+    if (m_gpuProcessConnection) {
+        m_gpuProcessConnection->messageReceiverMap().removeMessageReceiver(*this);
+        m_gpuProcessConnection->connection().send(Messages::GPUConnectionToWebProcess::ReleaseRemoteCommandListener(m_identifier), 0);
     }
 }
 
-void RemoteRemoteCommandListener::gpuProcessConnectionDidClose(GPUProcessConnection&)
+GPUProcessConnection& RemoteRemoteCommandListener::ensureGPUProcessConnection()
 {
-    // FIXME: Should this relaunch the GPUProcess and re-create the RemoteCommandListener?
+    if (!m_gpuProcessConnection) {
+        m_gpuProcessConnection = makeWeakPtr(m_process.ensureGPUProcessConnection());
+        m_gpuProcessConnection->addClient(*this);
+        m_gpuProcessConnection->messageReceiverMap().addMessageReceiver(Messages::RemoteRemoteCommandListener::messageReceiverName(), m_identifier.toUInt64(), *this);
+        m_gpuProcessConnection->connection().send(Messages::GPUConnectionToWebProcess::CreateRemoteCommandListener(m_identifier), { });
+    }
+    return *m_gpuProcessConnection;
 }
 
+void RemoteRemoteCommandListener::gpuProcessConnectionDidClose(GPUProcessConnection& gpuProcessConnection)
+{
+    gpuProcessConnection.removeClient(*this);
+    gpuProcessConnection.messageReceiverMap().removeMessageReceiver(*this);
+    m_gpuProcessConnection = nullptr;
+
+    // FIXME: GPUProcess will be relaunched/RemoteCommandListener re-created when calling updateSupportedCommands().
+    // FIXME: Should we relaunch the GPUProcess pro-actively and re-create the RemoteCommandListener?
+}
+
 void RemoteRemoteCommandListener::didReceiveRemoteControlCommand(WebCore::PlatformMediaSession::RemoteControlCommandType type, const PlatformMediaSession::RemoteCommandArgument& argument)
 {
     client().didReceiveRemoteControlCommand(type, argument);
@@ -86,7 +99,7 @@
     for (auto command : supportedCommands)
         commands.uncheckedAppend(command);
 
-    m_process.ensureGPUProcessConnection().connection().send(Messages::RemoteRemoteCommandListenerProxy::UpdateSupportedCommands { WTFMove(commands), m_currentSupportSeeking }, m_identifier);
+    ensureGPUProcessConnection().connection().send(Messages::RemoteRemoteCommandListenerProxy::UpdateSupportedCommands { WTFMove(commands), m_currentSupportSeeking }, m_identifier);
 }
 
 }

Modified: trunk/Source/WebKit/WebProcess/GPU/media/RemoteRemoteCommandListener.h (279583 => 279584)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteRemoteCommandListener.h	2021-07-06 16:00:16 UTC (rev 279583)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteRemoteCommandListener.h	2021-07-06 16:02:24 UTC (rev 279584)
@@ -61,12 +61,16 @@
     // Messages
     void didReceiveRemoteControlCommand(WebCore::PlatformMediaSession::RemoteControlCommandType, const WebCore::PlatformMediaSession::RemoteCommandArgument&);
 
+    // WebCore::RemoteCommandListener
     void updateSupportedCommands() final;
 
+    GPUProcessConnection& ensureGPUProcessConnection();
+
     WebProcess& m_process;
     RemoteRemoteCommandListenerIdentifier m_identifier;
     WebCore::RemoteCommandListener::RemoteCommandsSet m_currentCommands;
     bool m_currentSupportSeeking { false };
+    WeakPtr<GPUProcessConnection> m_gpuProcessConnection;
 };
 
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to