mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 14:43:28 +00:00
When inspector emits a message, to be sent to the client, we copy those bytes a number of times. First, V8 serializes the message to CBOR. Next, it converts it to JSON. We then copy this into a C++ string, then into a Zig slice. We create one final copy (with websocket framing) to add to the write queue. Something similar, but a little less extreme, happens with incoming messages. By supporting CBOR messages directly, we not only reduce the amount of copying, but also leverage our [more tightly scoped and re-used] arenas. CBOR is essentially a standardized MessagePack. Two functions, jsonToCbor and cborToJson have been introduced to take our incoming JSON message and convert it to CBOR and, vice-versa. V8 automatically detects that the message is CBOR and, if the incoming message is CBOR, the outgoing message is CBOR also. While v8 is spec-compliant, it has specific expectations and behavior. For example, it never emits a fixed-length array / map - it's always an infinite array / map (with a special "break" code at the end). For this reason, our implementation is not complete, but rather designed to work with what v8 does and expects. Another example of this is, and I don't understand why, some of the incoming messages have a "params" field. V8 requires this to be a CBOR embedded data field (that is, CBOR embedded into CBOR). If we pass an array directly, while semantically the same, it'll fail. I guess this is how Chrome serializes the data, and rather than just reading the data as-is, v8 asserts that it's encoded in a particularly flavor. Weird. But we have to accommodate that.
23 lines
950 B
Zig
23 lines
950 B
Zig
.{
|
|
.name = .browser,
|
|
.paths = .{""},
|
|
.version = "0.0.0",
|
|
.fingerprint = 0xda130f3af836cea0,
|
|
.dependencies = .{
|
|
.tls = .{
|
|
.url = "https://github.com/ianic/tls.zig/archive/b29a8b45fc59fc2d202769c4f54509bb9e17d0a2.tar.gz",
|
|
.hash = "tls-0.1.0-ER2e0uAxBQDm_TmSDdbiiyvAZoh4ejlDD4hW8Fl813xE",
|
|
},
|
|
.tigerbeetle_io = .{
|
|
.url = "https://github.com/lightpanda-io/tigerbeetle-io/archive/61d9652f1a957b7f4db723ea6aa0ce9635e840ce.tar.gz",
|
|
.hash = "tigerbeetle_io-0.0.0-ViLgxpyRBAB5BMfIcj3KMXfbJzwARs9uSl8aRy2OXULd",
|
|
},
|
|
.v8 = .{
|
|
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/bf7ba696b3e819195f8fc349b2778c59aab81a61.tar.gz",
|
|
.hash = "v8-0.0.0-xddH6xm3AwA287seRdWB_mIjZ9_Ayk-81z9uwWoag7Er",
|
|
},
|
|
//.v8 = .{ .path = "../zig-v8-fork" },
|
|
//.tigerbeetle_io = .{ .path = "../tigerbeetle-io" },
|
|
},
|
|
}
|