Commit Graph

8486 Commits

Author SHA1 Message Date
Muki Kiboigo
9cff938dbb fix minor compilation issues 2026-08-02 00:08:49 -07:00
Muki Kiboigo
dcc0d30331 add content_type column in Cache 2026-08-02 00:08:49 -07:00
Muki Kiboigo
79e5ce66a0 use real seconds value for migrations applied_at 2026-08-02 00:08:49 -07:00
Muki Kiboigo
95fbe5a3d9 add format for SqliteCachePath 2026-08-02 00:08:49 -07:00
Muki Kiboigo
5b1f4d0382 use CachePutRequest for puts instead of CacheMetadata 2026-08-02 00:08:47 -07:00
Muki Kiboigo
af525f7576 clear old non-Vary headers on renew 2026-08-02 00:08:29 -07:00
Muki Kiboigo
1a856ec16d rework get to be strictly deferred 2026-08-02 00:08:29 -07:00
Muki Kiboigo
918ebc87b5 add transaction begin types 2026-08-02 00:08:29 -07:00
Muki Kiboigo
b6752f7069 remove cache eviction path from HttpClient 2026-08-02 00:08:29 -07:00
Muki Kiboigo
923e595831 add test for no validators behavior 2026-08-02 00:08:29 -07:00
Muki Kiboigo
5133be0be6 always defer conn.rollback after tx begin 2026-08-02 00:08:29 -07:00
Muki Kiboigo
dbfe651540 early exit on SqliteCache.get on expired without validators 2026-08-02 00:08:29 -07:00
Muki Kiboigo
db3ab17fe6 skip body dupe on expired without validators on Cache.get 2026-08-02 00:08:28 -07:00
Muki Kiboigo
83e7ae1770 check vary before we dupe in SqliteCache.get 2026-08-02 00:08:28 -07:00
Muki Kiboigo
8082f2d701 get rid of file variant in CachedData 2026-08-02 00:08:28 -07:00
Muki Kiboigo
d0d33871d6 manually delete and reinsert 2026-08-02 00:08:28 -07:00
Muki Kiboigo
47886228f3 loadBody can return null 2026-08-02 00:08:28 -07:00
Muki Kiboigo
8c44591fa0 remove Storage and FsCache 2026-08-02 00:08:28 -07:00
Muki Kiboigo
f656456510 remove primary key on url name 2026-08-02 00:08:28 -07:00
Muki Kiboigo
d8be6748ee use strict tables 2026-08-02 00:08:27 -07:00
Pierre Tachoire
dae03cf9ba 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-02 00:08:27 -07:00
Muki Kiboigo
129061d627 add SqliteCache as default local impl 2026-08-02 00:08:25 -07: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
Karl Seguin
2b70736b06 Merge pull request #3093 from lightpanda-io/element-proto-removal
mem: remove _proto field from most Node types
2026-08-01 08:04:11 +08:00
Karl Seguin
9809cbb9fb Merge pull request #3092 from lightpanda-io/arena-optimizations
mem: improve ArenaPool usage
2026-08-01 08:03:58 +08:00
Karl Seguin
ba1980da84 Merge pull request #3091 from lightpanda-io/blob-mem-tweak
mem: improve memory efficiency of blob
2026-08-01 08:03:43 +08:00
Karl Seguin
b415cbe944 wpt: improve webcrypto WPT results
Adds a proper QuoteExceededError WebApi.

Handles more invalid parameters.

The most significant change is that types which return a promise don't return
an error, they reject. This is an issue that we run into a lot, and this
commit has started to work on a more generic (i.e. in the bridge) solution.
2026-07-31 18:19:58 +08:00
Karl Seguin
0672fad797 webapi: Add Scheduler (window and worker)
This is a new API, but it's in all browser (nightly in Firefox). It's
essentially a more powerful api than setTimeout, it has priority and
cancellation.
2026-07-31 17:23:33 +08:00
Karl Seguin
c52cba3858 mem: remove _proto field from most Node types
Continues the work started in https://github.com/lightpanda-io/browser/pull/3070

Removes the _proto field from intermediary (non-leaf) elements and uses the
relative positioning from the contiguous allocation. With the work done in
previous commit, this is pretty mechanical.

This essentially saves 8 bytes per type. Pretty small, but now Node->* is
consistently designed 1 way. Empty leaf nodes are still an issue, and the _proto
remains in them (for now). It's an issue because, if it's truly empty, the leaf
can have the same address as the parent or a sibling. This is something we
used to have problems with (hence some types have a _pad: bool). Solvable, but
separately.
2026-07-31 15:31:31 +08:00
Karl Seguin
2bd9848c07 mem: improve ArenaPool usage
1 - Add a metric to track the number of inlight arenas from the pool
2 - Script now use 2 arenas:
    - An initial (small) one for the script
    - A sized one for the body
    Should result in less pressure on our limited .large arenas
3 - DOMPoint and DOMPointRO are now arena free (they live on the slab only)
4 - TextDecoder no longer accumulate garbage in its arena
5 - Response object is much better at picking its arena size, rather than just
    using a .large
2026-07-31 14:36:22 +08:00
Karl Seguin
8c7706f6a1 mem: improve memory efficiency of blob
This figures out the size of Blob/File to chose a better arena, potentially
avoiding holding a .large arena (which we have limited) for small data.

This happens to circumvent an allocation bug in std.Io.Writer.Allocating that
can over-reserve memory.

It also removes some page: *Page parameters in favor of *js.Execution which I
think should always be preferred (for no other reason that going from
Execution -> Page is easy, but going from Page -> Execution is more complicated
so we should just always use Execution).
2026-07-31 11:38:03 +08:00
Karl Seguin
392bb4c772 Merge pull request #3088 from lightpanda-io/improve-test-output-and-logs
tests: improve test output and test log handling
2026-07-31 11:01:53 +08:00
Karl Seguin
c726b022e8 tests: improve test output and test log handling
1 - TEST_VERBOSE is now off by default
2 - There's a afterEach callback that is automatically run after each tests, it:
     a - clears the log filters
     b - resets the test arena
3 - LogFilter replace with
     a - testing.silenceLog(&.{...scopes...}); to silence all logs for the given
         scopes.
     b - testing.expectLog(&.{...scopes}); to set log expectations, 1 per log.
         The goal here isn't so much to expect logs (though, you can do that),
         but rather to silence an expected # of logs, without silencing more.
2026-07-31 07:30:25 +08:00
Karl Seguin
6d824c880e Merge pull request #3087 from lightpanda-io/fix-options-set-value-uaf
fix: potential UAF when option's value is programmatically set
2026-07-31 07:23:50 +08:00
Karl Seguin
93922f7a0e Merge pull request #3086 from lightpanda-io/arena-type
mem: arena allocation metric + report zig->v8 memory usage hints
2026-07-31 07:23:33 +08:00
Karl Seguin
31d730a7c4 Merge pull request #3089 from lightpanda-io/zig-memory-report
mem: add metric for arena allocations
2026-07-30 18:12:33 +08:00
Karl Seguin
a06f8f2161 mem: add metric for arena allocations
Report memory held by arenas which are waiting on v8 finalization to v8. This
acts as a hint to the v8 GC, so that it knows about external memory which is
being held up by it.

This is opt-in, code needs to getArena() -> getPinnedArena() and then needs to
report() where it makes sense (e.g. no point reporting XHR memory if the Zig-
side still needs to instance).
2026-07-30 17:17:32 +08:00
Adrià Arrufat
c2fa38e516 Merge pull request #3075 from lightpanda-io/codex
agent: support subscription auth via Codex
2026-07-30 08:02:11 +02:00
Karl Seguin
5ce274cec4 fix: potential UAF when option's value is programmatically set 2026-07-30 13:53:08 +08:00
Karl Seguin
bdce49a4b5 refactor: Introduce Arena wrapper
Introduces a ArenaAllocator wrappre (lp.Arena). This is groundwork for better
memory tracking and reporting memory usage to v8. This is almost purely a
mechanical change to lay a foundation for a follow up PR that will address
https://github.com/lightpanda-io/browser/issues/3027

Some code became a bit leaner: a pooled arena can release itself (it has a
reference to the ArenaPool).

Some code became uglier: The Frame has a `_local_arena: *lp.Arena` and a
`local_arena: Allocator` (same with call_arena, and same with a few other types)
so that consumers aren't impacted (they continue to use `frame.local_arena`).
2026-07-30 13:02:13 +08:00
Karl Seguin
5f6085fd03 Merge pull request #3085 from lightpanda-io/fix-script-setattribute-src
Fix script setattribute src
2026-07-30 11:30:28 +08:00
Karl Seguin
edcd9eabf4 Merge pull request #3084 from lightpanda-io/max-timer-test
test: add max-timers test
2026-07-30 09:53:58 +08:00
Karl Seguin
961da45ece Ignore empty Script.src values
Don't hold an map entry over attributeChange callback, since we can now execute
JavaScript which could invalidate the map.
2026-07-30 09:49:47 +08:00
Karl Seguin
3a4e6febad test: add max-timers test 2026-07-30 08:03:17 +08:00
Karl Seguin
5aa1f0619c Merge pull request #3081 from lightpanda-io/script-event
webapi: Fix script load/error events
2026-07-30 08:00:44 +08:00