[webkit-changes] [WebKit/WebKit] d1fb58: Unthrottled IPC::Connection loses messages when co...

Kimmo Kinnunen noreply at github.com
Wed Jan 31 12:45:01 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d1fb58818ff3474566c2a82032c9e7431dd8c617
      https://github.com/WebKit/WebKit/commit/d1fb58818ff3474566c2a82032c9e7431dd8c617
  Author: Kimmo Kinnunen <kkinnunen at apple.com>
  Date:   2024-01-31 (Wed, 31 Jan 2024)

  Changed paths:
    M Source/WebKit/Platform/IPC/Connection.cpp
    M Source/WebKit/Platform/IPC/Connection.h
    M Source/WebKit/Platform/IPC/StreamClientConnection.cpp
    M Source/WebKit/Platform/IPC/StreamClientConnection.h
    M Tools/TestWebKitAPI/Tests/IPC/ConnectionTests.cpp
    M Tools/TestWebKitAPI/Tests/IPC/StreamConnectionTests.cpp

  Log Message:
  -----------
  Unthrottled IPC::Connection loses messages when connection is closed
https://bugs.webkit.org/show_bug.cgi?id=268362
rdar://121910136

Reviewed by Matt Woodrow.

When IPC::Connection::invalidate() would be called, some of the messages
already sent might have been lost:
1. Unsent messages due to outgoing messages buffering
2. Messages not delivered at the recipient because message delivery
   would check isValid()

Fix 1. by adding a blocking IPC::Connection::flushSentMessages()
that will wait until send list flips to zero.
The flushSentMessages() call is distinct from invalidate() to preserve
the ability to call invalidate() in non-blocking manner.

Fix 2. by not checking for isValid() but for m_client / m_syncState.

isValid() flips immediately in the IPC receive queue when OS signals
that the connection was closed.
m_client, m_syncState flips to nullptr when client signals that
they do not want to receive messages anymore, via invalidate().
By contract, IPC::Connection invalidates itself after Client::didClose(),
too.

Fixes mostly upcoming GPUP cases where one connection is closed, but
not the whole per-WP session (GPUConnectionToWebProcess). The
individual connections might carry important messages up until
the disconnection, so all must be played back before handling the
connection closing.

* Source/WebKit/Platform/IPC/Connection.cpp:
(IPC::Connection::flushSentMessages):
(IPC::Connection::connectionDidClose):
(IPC::Connection::sendOutgoingMessages):
(IPC::Connection::dispatchMessage):
* Source/WebKit/Platform/IPC/Connection.h:
* Source/WebKit/Platform/IPC/StreamClientConnection.cpp:
(IPC::StreamClientConnection::flushSentMessages):
* Source/WebKit/Platform/IPC/StreamClientConnection.h:
* Tools/TestWebKitAPI/Tests/IPC/ConnectionTests.cpp:
(TestWebKitAPI::TEST_P):
* Tools/TestWebKitAPI/Tests/IPC/StreamConnectionTests.cpp:
(TestWebKitAPI::TEST_P):

Canonical link: https://commits.webkit.org/273851@main




More information about the webkit-changes mailing list