Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9b445a294f40f95a9e2b99c5261027f0f0608de4
      
https://github.com/WebKit/WebKit/commit/9b445a294f40f95a9e2b99c5261027f0f0608de4
  Author: Kimmo Kinnunen <[email protected]>
  Date:   2026-08-13 (Thu, 13 Aug 2026)

  Changed paths:
    M Source/WebKit/Platform/IPC/Connection.h
    M Source/WebKit/Platform/IPC/Encoder.h
    M Source/WebKit/Platform/IPC/cocoa/ConnectionCocoa.mm
    M Source/WebKit/Platform/IPC/cocoa/MachMessage.cpp
    M Source/WebKit/Platform/IPC/cocoa/MachMessage.h
    M Source/WebKit/Scripts/IPCTestingHeaders-input.xcfilelist
    M Source/WebKit/Scripts/IPCTestingHeaders-output.xcfilelist
    M Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
    M Tools/TestWebKitAPI/CMakeLists.txt
    M Tools/TestWebKitAPI/SourcesCocoa.txt
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    A Tools/TestWebKitAPI/Tests/IPC/MachMessageTests.cpp
    R Tools/TestWebKitAPI/Tests/WebKit/WKWebView/IPCSharedMemoryFallback.mm

  Log Message:
  -----------
  Move mach message send/receive to MachMessage, simplify the implementation
https://bugs.webkit.org/show_bug.cgi?id=321446
rdar://184538684

Reviewed by Chris Dumez.

Move mach message send and receive code to MachMessage::sendEncoder(),
MachMessage::receive(), MachMessage::send(). This allows future commits
use the functionaliy in stream IPC implementation without Connection.

Simplify, make more consistent and remove functionality.

Before:
Body as SHM codepath to avoid MACH_SEND_TOO_LARGE, 308536@main
(rdar://60344809).

After:
Remove body as SHM codepath. This was dead code, aqs XNU does not return
MACH_SEND_TOO_LARGE for large bodies.  Previously big encoder bodies
were already encoded as out-of-line attachment. This would leave large
amounts of  attachment descriptors as the code-path to generate too
large bodies. However, this would need enormous amount of attachments,
which XNU rejects.

Instead, implement support for sending out-of-line attachments.
This way wwe can send more attachments than 127 without
MACH_SEND_TOO_LARGE.

Before:
Large amount of attachments would seem to induce messages larger than
4096. This needed message buffer resize codepaths on send and receive.
This was dead code, as XNU would not allow WebKit to send such messages.

After:
Use the OOL attachments feature to guarantee that all messages can be
sent and received without heap allocations, with the message in
the stack local 4096 byte buffer (+ trailer in receive part).

This simplifies by removing the heap buffer fallbacks in send and
receive.

Before:
Three message type ids: inline body, out-of-line body, shm body.

After:
One message type id: webkitMachMessageID. The descriptors of a message say
what is in the message, the id and the descriptors can no longer
disagree.

* Source/WebKit/Platform/IPC/Connection.h:
* Source/WebKit/Platform/IPC/Encoder.h:
(IPC::Encoder::attachmentCount const):
* Source/WebKit/Platform/IPC/cocoa/ConnectionCocoa.mm:
(IPC::Connection::platformInvalidate):
(IPC::Connection::platformCanSendOutgoingMessages const):
(IPC::Connection::sendOutgoingMessage):
(IPC::Connection::resumeSendSource):
(IPC::Connection::receiveSourceEventHandler):
* Source/WebKit/Platform/IPC/cocoa/MachMessage.cpp:
(IPC::sendMessage):
(IPC::sendResult):
(IPC::MachMessage::MachMessage):
(IPC::MachMessage::~MachMessage):
(IPC::MachMessage::adoptPseudoReceived):
(IPC::MachMessage::sendEncoder):
(IPC::MachMessage::send):
(IPC::MachMessage::receive):
* Source/WebKit/Platform/IPC/cocoa/MachMessage.h:
* Source/WebKit/Scripts/IPCTestingHeaders-input.xcfilelist:
* Source/WebKit/Scripts/IPCTestingHeaders-output.xcfilelist:
* Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm:
* Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
* Tools/TestWebKitAPI/CMakeLists.txt:
* Tools/TestWebKitAPI/SourcesCocoa.txt:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/IPC/MachMessageTests.cpp: Added.
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/IPCSharedMemoryFallback.mm: 
Removed.

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to