Commit Graph
8508 Commits
Author SHA1 Message Date
Karl Seguin df913ec8a5 Merge pull request #3131 from lightpanda-io/gc-hint-heuristics
perf: Reduce memory pressure notification to v8
2026-08-05 08:43:17 +08:00
Karl Seguin a7ea65e680 Merge pull request #3128 from lightpanda-io/element-bare-tag
mem: Switch Element's _type to a bare tag
2026-08-05 08:42:55 +08:00
Karl Seguin 714e6095ed lower gc limit just for the CI... 2026-08-04 17:13:03 +08:00
Karl Seguin 7840005916 lower gc limit just for the CI... 2026-08-04 15:06:17 +08:00
Karl Seguin a2c4aa0020 lower gc limit just for the CI... 2026-08-04 14:30:52 +08:00
Karl Seguin 6e72c43fa2 remove dead context guard...trying to pass CI regression tests 2026-08-04 12:55:26 +08:00
Karl Seguin 83e47447b5 perf: Reduce memory pressure notification to v8
Only notify v8 of memory pressure when (a) there's memory to claim and (b)
there are dead context.

Also clean up code that relied on undefined behavior which might have left
local scopes un-freed and caused a v8 leak.
2026-08-04 12:18:31 +08:00
muki e143533987 Merge pull request #2631 from lightpanda-io/sqlite-cache
Sqlite Cache Backend
2026-08-03 18:39:11 -07:00
Muki Kiboigo 7d6299895f fix minor compilation issues 2026-08-03 18:26:58 -07:00
Muki Kiboigo bf35489192 add content_type column in Cache 2026-08-03 18:26:58 -07:00
Muki Kiboigo 573c1f8a9a use real seconds value for migrations applied_at 2026-08-03 18:26:58 -07:00
Muki Kiboigo ea0a45c713 add format for SqliteCachePath 2026-08-03 18:26:58 -07:00
Muki Kiboigo 0b74224b15 use CachePutRequest for puts instead of CacheMetadata 2026-08-03 18:26:57 -07:00
Muki Kiboigo 65448bbde6 clear old non-Vary headers on renew 2026-08-03 18:26:13 -07:00
Muki Kiboigo 6c56144ef9 rework get to be strictly deferred 2026-08-03 18:26:12 -07:00
Muki Kiboigo d16408d2d8 add transaction begin types 2026-08-03 18:17:44 -07:00
Muki Kiboigo 84405ad930 remove cache eviction path from HttpClient 2026-08-03 18:17:44 -07:00
Muki Kiboigo a03471a1ce add test for no validators behavior 2026-08-03 18:17:44 -07:00
Muki Kiboigo 8dc2488835 always defer conn.rollback after tx begin 2026-08-03 18:17:44 -07:00
Muki Kiboigo 65593179ea early exit on SqliteCache.get on expired without validators 2026-08-03 18:17:44 -07:00
Muki Kiboigo 3bfec6d7ff skip body dupe on expired without validators on Cache.get 2026-08-03 18:17:43 -07:00
Muki Kiboigo 04e93cd592 check vary before we dupe in SqliteCache.get 2026-08-03 18:17:43 -07:00
Muki Kiboigo 94c029ff32 get rid of file variant in CachedData 2026-08-03 18:17:43 -07:00
Muki Kiboigo a96543052c manually delete and reinsert 2026-08-03 18:17:43 -07:00
Muki Kiboigo 671b110aa2 loadBody can return null 2026-08-03 18:17:43 -07:00
Muki Kiboigo b2727a1ab4 remove Storage and FsCache 2026-08-03 18:17:43 -07:00
Muki Kiboigo 4d59b61a33 remove primary key on url name 2026-08-03 18:17:43 -07:00
Muki Kiboigo 047280e0d6 use strict tables 2026-08-03 18:17:43 -07:00
Pierre Tachoire 1308639a9f cap delta-seconds values per RFC 9111
Huge max-age/Age header values previously either panicked in the
i64 casts when storing metadata, or were silently truncated to their
first 8 digits by the fixed-size lowercase buffer in
CacheControl.parse. Cap them at 2^31 as RFC 9111 §1.2.2 prescribes
and compare directives case-insensitively without truncation.
2026-08-03 18:17:42 -07:00
Muki Kiboigo 0f2957cda2 add SqliteCache as default local impl 2026-08-03 18:17:40 -07:00
Karl Seguin d5807bf8a0 mem: Switch Element's _type to a bare tag
Follows https://github.com/lightpanda-io/browser/pull/3104. Also applies to Html
and Svg. A div chain shrinks by 24 bytes.
2026-08-04 08:05:24 +08:00
Karl Seguin 5f88b33ed6 Merge pull request #3118 from lightpanda-io/refactor-http-client-headers
refactor: rework how httpclient headers work
2026-08-04 06:42:10 +08:00
Karl Seguin f5c40da81c Merge pull request #3111 from lightpanda-io/cdp-json-protocol
cdp: add /json/protocol endpoint
2026-08-04 06:41:55 +08:00
Karl Seguin aecb3ac459 Merge pull request #3105 from lightpanda-io/string-align
mem: rework string.String to be align(8)
2026-08-04 06:41:43 +08:00
Karl Seguin df11a6e4af Merge pull request #3104 from lightpanda-io/node-bare-tag
mem: Switch Node's _type to a bare tag
2026-08-04 06:41:26 +08:00
Karl Seguin ccc0a988a3 Merge pull request #3103 from lightpanda-io/scheduler
Rework scheduler
2026-08-04 06:41:11 +08:00
Karl Seguin 940796d4da Merge pull request #3101 from lightpanda-io/script-cacheable-log
chore: remove cacheable field from ScriptManager log
2026-08-04 06:40:53 +08:00
Karl Seguin 1d5a25bf4e remove reference to generator (didn't like it, don't want to include it) 2026-08-03 18:48:40 +08:00
Karl Seguin fd2e6a8512 refactor: rework how httpclient headers work
Adding headers to an HTTP request was a bit awkward due to my desire to avoid
having an intermediate representation (e.g. an ArrayList(Header)). Going
straight to a curl slist avoids double-copying the headers (first to Zig, then
to curl).

But the CORS work (https://github.com/lightpanda-io/browser/pull/3002) showcases
that this micro-optimization simply isn't worth it, since it needs that
intermediate representation anyways.

And, this change isn't just for CORS. Headers have been a silly pain in the past
like unclear ownership, and messy APIs used in _a lot_ of places (WebBotAuth,
WebSocket, Fetch, ...)

This new approach stores headers on the transfer in an ArrayList. The API is:

```
const transfer = try client.newRequest(.{...}, owner);
{
    errdefer transfer.deinit();
    try transfer.addHeader("Over", "9000", .{});
}
try transfer.submit();
```

This:
1 - Eliminates ambiguity about errdefer cleanup responsibility
2 - Eliminates a bunch of stringZ concat that Frame, Config, CDP were doing
3 - Transfer.arena is now available for headers
2026-08-03 18:26:32 +08:00
Karl Seguin f4783d8fcc cdp: add /json/protocol endpoint
https://krabarena.com/claims/browserless-exposes-57-cdp-domains-for-discovery-lightpanda-s-endpoint-is-a-404
2026-08-03 15:51:42 +08:00
Karl Seguin 876ff8400b mem: rework string.String to be align(8)
Moves from packed to extern which causes alignment to drop from 16 to 8. Paired
with https://github.com/lightpanda-io/browser/pull/3104 this results in a -8
bytes per Text node.
2026-08-03 13:07:28 +08:00
Karl Seguin 7db42891a7 mem: Switch Node's _type to a bare tag
Alignment allowing (1) this reduces Node size by 8 bytes. It also aligns with
previous cdata changes with the end-goal to have the entire Node chain adopt
bare tags.

(1) string.String is 16-byte aligned, so Text doesn't shrink with this change.
Hopefully this can be addressed separately.
2026-08-03 12:19:41 +08:00
Karl Seguin 3b9359dc98 Rework scheduler
This does 2 scheduler-related changes. The first is that the high/low priority
queues are gone. These were misleading and hinted at some type of ordering. The
point was strictly to help us decide when do we consider a page "done" and that
some tasks SHOULD hold up the page (high priority) and some pages SHOULD NOT
(low priority).

So, when adding a task, `low_priority == true` is now `blocks_done == false`.
But it isn't just a rename:

1 - There two queues are merged, and we keep a blocking count
2 - Past a certain timer depth, blocks_done == true, so it protects against more
    cases than just the previous RAF

The other change relates to the Scheduler's implementation. While low/high have
been merged into a single PriorityQueue, "immediate" and "front" tasks get their
own distinct queue (so we now have 3). This is an optimization for the very
common case where run_at = 0 - it can be a plain FIFO.

Rather than comparing tasks on run_at (u64) and sequence (u64), the key (u64)
merges the two.
2026-08-02 20:14:34 +08:00
Karl Seguin 596d236551 chore: remove cacheable field from ScriptManager log
Cacheable for ScriptManager means something very specific (should the js.Context
cache the module for subsequent loads). With HTTP caching coming, I'm removing
this field from the ScriptManager logs because (a) it isn't very useful anyways
and (b) it doesn't mean what most people who see it would think it means.
2026-08-02 13:17:29 +08:00
Karl Seguin 70bbdadf4b Merge pull request #3098 from lightpanda-io/page-double-free
uaf: Fix page double-free on navigate failure.
2026-08-02 08:49:18 +08:00
Karl Seguin a4970bfd9b Merge pull request #3097 from lightpanda-io/lp-is_debug-is_test
chore: add lp.IS_DEBUG and lp.IS_TEST
2026-08-02 08:49:04 +08:00
Karl Seguin 634e27c9c6 uaf: Fix page double-free on navigate failure.
This is a classic (for us) issue. Session.initiateRootNavigation errdefer a
number of steps BUT, if the frame.navigate() call reaches libcurl's event-loop,
then those errdefer can conflict with the `frameErrorCallback`. Who's
responsible for cleaning up? It depends where the failure happened.

So the cleanup is now more defensive. Page.destroying guards against multiple
calls to Session.queuePageDestruction and initiateRootNavigation no longer
assumes that the new Page is in the pages collection.

I believe this is the cause of the "release overflow" for `Selection` that is
infrequent but has been seen for a long time.
2026-08-01 17:41:19 +08:00
Karl Seguin 6a83881634 chore: add lp.IS_DEBUG and lp.IS_TEST
Change all users to builtin.mode and built.is_test
2026-08-01 09:15:18 +08:00
Karl Seguin 5125912a04 Merge pull request #3095 from lightpanda-io/webcrypto-wpt
wpt: improve webcrypto WPT results
2026-08-01 08:04:48 +08:00
Karl Seguin b40bf98651 Merge pull request #3094 from lightpanda-io/webapi-scheduler
webapi: Add Scheduler (window and worker)
2026-08-01 08:04:26 +08:00