mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-23 09:22:30 +00:00
LibWeb: Send IPC messages exceeding socket buffer through shared memory
It turned out that some web applications want to send fairly large messages to WebWorker through IPC (for example, MapLibre GL sends ~1200KiB), which led to failures (at least on macOS) because buffer size of TransportSocket is limited to 128KiB. This change solves the problem by wrapping messages that exceed socket buffer size into another message that holds wrapped message content in shared memory. Co-Authored-By: Luke Wilde <luke@ladybird.org>
This commit is contained in:
parent
bc0ec84100
commit
4b04e97feb
Notes:
github-actions[bot]
2025-04-03 11:56:37 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 4b04e97feb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4201
11 changed files with 173 additions and 18 deletions
|
@ -404,7 +404,7 @@ public:)~~~");
|
|||
static i32 static_message_id() { return (int)MessageID::@message.pascal_name@; }
|
||||
virtual const char* message_name() const override { return "@endpoint.name@::@message.pascal_name@"; }
|
||||
|
||||
static ErrorOr<NonnullOwnPtr<@message.pascal_name@>> decode(Stream& stream, Queue<IPC::File>& files)
|
||||
static ErrorOr<NonnullOwnPtr<@message.pascal_name@>> decode(Stream& stream, IPC::UnprocessedFileDescriptors& files)
|
||||
{
|
||||
IPC::Decoder decoder { stream, files };)~~~");
|
||||
|
||||
|
@ -649,7 +649,7 @@ void generate_proxy_method(SourceGenerator& message_generator, Endpoint const& e
|
|||
}
|
||||
} else {
|
||||
message_generator.append(R"~~~());
|
||||
MUST(m_connection.post_message(move(message_buffer))); )~~~");
|
||||
MUST(m_connection.post_message(@endpoint.magic@, move(message_buffer))); )~~~");
|
||||
}
|
||||
|
||||
message_generator.appendln(R"~~~(
|
||||
|
@ -720,7 +720,7 @@ public:
|
|||
|
||||
static u32 static_magic() { return @endpoint.magic@; }
|
||||
|
||||
static ErrorOr<NonnullOwnPtr<IPC::Message>> decode_message(ReadonlyBytes buffer, [[maybe_unused]] Queue<IPC::File>& files)
|
||||
static ErrorOr<NonnullOwnPtr<IPC::Message>> decode_message(ReadonlyBytes buffer, [[maybe_unused]] IPC::UnprocessedFileDescriptors& files)
|
||||
{
|
||||
FixedMemoryStream stream { buffer };
|
||||
auto message_endpoint_magic = TRY(stream.read_value<u32>());)~~~");
|
||||
|
@ -757,6 +757,11 @@ public:
|
|||
do_decode_message(message.response_name());
|
||||
}
|
||||
|
||||
generator.append(R"~~~(
|
||||
case (int)IPC::LargeMessageWrapper::MESSAGE_ID:
|
||||
return TRY(IPC::LargeMessageWrapper::decode(message_endpoint_magic, stream, files));
|
||||
)~~~");
|
||||
|
||||
generator.append(R"~~~(
|
||||
default:)~~~");
|
||||
if constexpr (GENERATE_DEBUG) {
|
||||
|
@ -898,6 +903,7 @@ void build(StringBuilder& builder, Vector<Endpoint> const& endpoints)
|
|||
#include <LibIPC/File.h>
|
||||
#include <LibIPC/Message.h>
|
||||
#include <LibIPC/Stub.h>
|
||||
#include <LibIPC/UnprocessedFileDescriptors.h>
|
||||
|
||||
#if defined(AK_COMPILER_CLANG)
|
||||
#pragma clang diagnostic push
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue