Skip to content

Commit

Permalink
GPUConnectionToWebProcess should return whether or not a particular r…
Browse files Browse the repository at this point in the history
…eceiver was able to handle a message not just that it was forwarded

https://bugs.webkit.org/show_bug.cgi?id=264815
rdar://118397083

Reviewed by Chris Dumez.

Currently GPUConnectionToWebProcess just returns true as soon as it
forwards a message to a receiver; completely ignoring whether it was
handled correctly or not. This is preventing us from detecting
deserialization failures for these messages. This change returns the
forwards the return result of the handler instead, aligning behavior
with NetworkConnectionToWebProcess and others.

* LayoutTests/ipc/send-invalid-sync-message-empty-reply-check-exception-expected.txt:
* LayoutTests/ipc/send-invalid-sync-message-empty-reply-check-exception.html:
* Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp:
(WebKit::GPUConnectionToWebProcess::dispatchSyncMessage):

Canonical link: https://commits.webkit.org/270778@main
  • Loading branch information
gavin-apple authored and cdumez committed Nov 15, 2023
1 parent 121addd commit 6fae1cc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

PASS Sending sync message with incorrect parameters must throw error
PASS Sending sync message to the UI process with incorrect parameters must throw error
PASS Sending sync message to the GPU process with incorrect parameters must throw error

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@
assert_throws_js(TypeError,
() => { IPC.sendSyncMessage("UI", 0, IPC.messages.IPCTester_SyncPingEmptyReply.name, defaultTimeout, []); },
`failed sync message must throw error`);
}, "Sending sync message with incorrect parameters must throw error");
}, "Sending sync message to the UI process with incorrect parameters must throw error");

promise_test(async t => {
if (!window.IPC)
return;

assert_throws_js(TypeError,
() => { IPC.sendSyncMessage("GPU", 0, IPC.messages.IPCTester_SyncPingEmptyReply.name, defaultTimeout, []); },
`failed sync message must throw error`);
}, "Sending sync message to the GPU process with incorrect parameters must throw error");

</script>
</body>
36 changes: 12 additions & 24 deletions Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -938,61 +938,50 @@ bool GPUConnectionToWebProcess::dispatchSyncMessage(IPC::Connection& connection,
{
#if ENABLE(VIDEO)
if (decoder.messageReceiverName() == Messages::RemoteMediaPlayerManagerProxy::messageReceiverName()) {
remoteMediaPlayerManagerProxy().didReceiveSyncMessageFromWebProcess(connection, decoder, replyEncoder);
return true;
return remoteMediaPlayerManagerProxy().didReceiveSyncMessageFromWebProcess(connection, decoder, replyEncoder);
}
if (decoder.messageReceiverName() == Messages::RemoteMediaPlayerProxy::messageReceiverName()) {
remoteMediaPlayerManagerProxy().didReceiveSyncPlayerMessage(connection, decoder, replyEncoder);
return true;
return remoteMediaPlayerManagerProxy().didReceiveSyncPlayerMessage(connection, decoder, replyEncoder);
}
#endif
#if ENABLE(ENCRYPTED_MEDIA)
if (decoder.messageReceiverName() == Messages::RemoteCDMFactoryProxy::messageReceiverName()) {
cdmFactoryProxy().didReceiveSyncMessageFromWebProcess(connection, decoder, replyEncoder);
return true;
return cdmFactoryProxy().didReceiveSyncMessageFromWebProcess(connection, decoder, replyEncoder);
}

if (decoder.messageReceiverName() == Messages::RemoteCDMProxy::messageReceiverName()) {
cdmFactoryProxy().didReceiveSyncCDMMessage(connection, decoder, replyEncoder);
return true;
return cdmFactoryProxy().didReceiveSyncCDMMessage(connection, decoder, replyEncoder);
}

if (decoder.messageReceiverName() == Messages::RemoteCDMInstanceProxy::messageReceiverName()) {
cdmFactoryProxy().didReceiveSyncCDMInstanceMessage(connection, decoder, replyEncoder);
return true;
return cdmFactoryProxy().didReceiveSyncCDMInstanceMessage(connection, decoder, replyEncoder);
}

if (decoder.messageReceiverName() == Messages::RemoteCDMInstanceSessionProxy::messageReceiverName()) {
cdmFactoryProxy().didReceiveSyncCDMInstanceSessionMessage(connection, decoder, replyEncoder);
return true;
return cdmFactoryProxy().didReceiveSyncCDMInstanceSessionMessage(connection, decoder, replyEncoder);
}
#endif
#if USE(AUDIO_SESSION)
if (decoder.messageReceiverName() == Messages::RemoteAudioSessionProxy::messageReceiverName()) {
audioSessionProxy().didReceiveSyncMessage(connection, decoder, replyEncoder);
return true;
return audioSessionProxy().didReceiveSyncMessage(connection, decoder, replyEncoder);
}
#endif
#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
if (decoder.messageReceiverName() == Messages::RemoteLegacyCDMFactoryProxy::messageReceiverName()) {
legacyCdmFactoryProxy().didReceiveSyncMessageFromWebProcess(connection, decoder, replyEncoder);
return true;
return legacyCdmFactoryProxy().didReceiveSyncMessageFromWebProcess(connection, decoder, replyEncoder);
}

if (decoder.messageReceiverName() == Messages::RemoteLegacyCDMProxy::messageReceiverName()) {
legacyCdmFactoryProxy().didReceiveSyncCDMMessage(connection, decoder, replyEncoder);
return true;
return legacyCdmFactoryProxy().didReceiveSyncCDMMessage(connection, decoder, replyEncoder);
}

if (decoder.messageReceiverName() == Messages::RemoteLegacyCDMSessionProxy::messageReceiverName()) {
legacyCdmFactoryProxy().didReceiveSyncCDMSessionMessage(connection, decoder, replyEncoder);
return true;
return legacyCdmFactoryProxy().didReceiveSyncCDMSessionMessage(connection, decoder, replyEncoder);
}
#endif
#if HAVE(AVASSETREADER)
if (decoder.messageReceiverName() == Messages::RemoteImageDecoderAVFProxy::messageReceiverName()) {
imageDecoderAVFProxy().didReceiveSyncMessage(connection, decoder, replyEncoder);
return true;
return imageDecoderAVFProxy().didReceiveSyncMessage(connection, decoder, replyEncoder);
}
#endif
#if ENABLE(WEBGL)
Expand All @@ -1002,8 +991,7 @@ bool GPUConnectionToWebProcess::dispatchSyncMessage(IPC::Connection& connection,
#endif
#if ENABLE(IPC_TESTING_API)
if (decoder.messageReceiverName() == Messages::IPCTester::messageReceiverName()) {
m_ipcTester.didReceiveSyncMessage(connection, decoder, replyEncoder);
return true;
return m_ipcTester.didReceiveSyncMessage(connection, decoder, replyEncoder);
}
#endif
return messageReceiverMap().dispatchSyncMessage(connection, decoder, replyEncoder);
Expand Down

0 comments on commit 6fae1cc

Please sign in to comment.