Commit Graph

8417 Commits

Author SHA1 Message Date
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
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
5aa1f0619c Merge pull request #3081 from lightpanda-io/script-event
webapi: Fix script load/error events
2026-07-30 08:00:44 +08:00
Karl Seguin
512379f423 Merge pull request #3080 from lightpanda-io/timer-limit
webapi: Increase max timer count
2026-07-30 07:59:23 +08:00
Karl Seguin
bbf50dc250 Merge pull request #3079 from lightpanda-io/dedupe-svg-css
chore: dedupe SVG / CSS code
2026-07-30 07:58:38 +08:00
Karl Seguin
96498fa321 Merge pull request #3078 from lightpanda-io/propagate-execution-terminating
crash: Capture ExecutionTerminated and propagate it
2026-07-30 07:58:23 +08:00
Karl Seguin
a39274bfae Merge pull request #3077 from lightpanda-io/collections-followup
fix: collection bugs
2026-07-30 07:58:08 +08:00
Karl Seguin
bac560fae3 Merge pull request #3070 from lightpanda-io/explicit-proto
design: add explicit Proto declaration to every type
2026-07-30 07:57:54 +08:00
Karl Seguin
c853ebc57b Merge pull request #2969 from lightpanda-io/nikneym/req-res-form-data
webapi: add `Request#formData` and `Response#formData`
2026-07-29 20:40:04 +08:00
Karl Seguin
3a56f7eea2 webapi: Fix script load/error events
1 - inline scripts don't fire anything
2 - load fires even on a JS throw

https://github.com/lightpanda-io/browser/pull/1629, so that is now removed.

Tested the behavior extensively in chrome/firefox (new test files) and matched
our implementation to those tests.

Fixes https://github.com/lightpanda-io/browser/issues/3069
2026-07-29 18:09:11 +08:00
Halil Durak
844c8d0846 update tests 2026-07-29 12:51:49 +03:00
Halil Durak
dff92a6fb5 FormData: std.Io.Clock.now -> lp.datetime.milliTimestamp 2026-07-29 12:51:49 +03:00
Halil Durak
f4a98a9e68 header_parser: de-inline everything 2026-07-29 12:51:49 +03:00
Halil Durak
50076f538a header_parser: Cursor.skipSpaces now skips HTAB 2026-07-29 12:51:49 +03:00
Halil Durak
7d0524073c header_parser: allow HTAB in header values 2026-07-29 12:51:48 +03:00
Halil Durak
7b29ec4a1a header_parser: simplify broadcast 2026-07-29 12:51:48 +03:00
Halil Durak
4c96f3edef FormData: changes after rebase 2026-07-29 12:51:48 +03:00
Halil Durak
de3877a6ae update tests 2026-07-29 12:51:48 +03:00
Halil Durak
2ca2c44faf simd.zig -> network/header_parser.zig
Also migrates to `Cursor` API of `header_parser`.
2026-07-29 12:51:47 +03:00
Halil Durak
91bcc28b7c update license years 2026-07-29 12:51:47 +03:00
Halil Durak
af45e00a94 Mime: move ContentTypeIterator to Mime 2026-07-29 12:51:47 +03:00
Halil Durak
af143e82d0 body_init: remove dead code 2026-07-29 12:51:47 +03:00
Halil Durak
4dfb365d2b change how we identify and parse FormData in Request and Response 2026-07-29 12:51:46 +03:00
Halil Durak
69c05031fd simd: update tests 2026-07-29 12:51:46 +03:00
Halil Durak
7ed9ac2cdb simd: add ContentTypeIterator type
Allows parsing `Content-Type` header value with ease.
2026-07-29 12:51:46 +03:00
Halil Durak
4d612b7517 simd: remove dead parseHttpHeaders function 2026-07-29 12:51:45 +03:00
Halil Durak
34de819aca update tests 2026-07-29 12:51:45 +03:00
Halil Durak
da417dd126 Response: add Response#formData 2026-07-29 12:51:45 +03:00
Halil Durak
03b1e611bd update tests 2026-07-29 12:51:45 +03:00
Halil Durak
50d942f807 Request: add Request#formData 2026-07-29 12:51:44 +03:00
Halil Durak
0c93b50748 FormData: introduce new ways to create FormData objects
Adds `initFromUrlEncoded` and `initFromMultipart`; which are required for `Request#formData`.
2026-07-29 12:51:44 +03:00
Halil Durak
e3fbd745a7 introduce simd.zig
Idea is to have reusable parsing utilities here; not sure on the name, we can surely go for something else.
2026-07-29 12:51:44 +03:00
Halil Durak
07f7366d73 FormData: add parseUrlEncoded
Introduces another url decoder also, we may like to unite these at some point.
2026-07-29 12:51:44 +03:00
Karl Seguin
49844b1015 webapi: Increase max timer count
Previously limited to 512. Airbnb uses 600+. Increase the max for one-shot to
2048, but keep 512 for repeating timers.
2026-07-29 17:45:02 +08:00
Karl Seguin
36cbf1747d Dedupe PointLIst and TransformList
Add an ugly mixin. Ensures the two implementations are the same.
2026-07-29 15:56:00 +08:00
Karl Seguin
93d2305041 Angle/Lenght value setter unit
Length.setValue should preserve the existing unit. Angle.setValue should use
degrees (copying what Chrome/Firefox do).
2026-07-29 15:37:11 +08:00
Karl Seguin
2781ce174e chore: dedupe unit parsing found in CSS and SVG 2026-07-29 15:23:37 +08:00
Karl Seguin
8023f6e1da crash: Capture ExecutionTerminated and propagate it
Prevent re-entering JavaScript when watch/cdp-detection terminates the execution
This can result in a V8 DCHECK failure.
2026-07-29 14:53:02 +08:00
Karl Seguin
c6afbdd224 remove _proto from Element 2026-07-29 10:34:03 +08:00
Karl Seguin
c78c8b7e22 remove _proto from Node and CData 2026-07-29 10:34:03 +08:00
Karl Seguin
a1a8fb6dc3 design: TaggedOpaque fromJS is now offset based
As part of the ongoing effort to remove the `_proto: *Parent` field,
TaggedOpaque.fromJS is now offset based. Technically this should perform better
since we're no longer walking through pointers. But the real goal is that we
can now start removing _proto fields.

But, for fromJS to be offset-based, we had to make sure every prototype chain
was a contiguous allocation. The Factory did this, but not everything used the
factory. Now, everything does. This change alone, without the fromJS change,
made every WebAPI allocation more consistent.
2026-07-29 10:34:03 +08:00
Karl Seguin
678971e320 design: rework cdata _type field
Ultimately, our goal is to remove the `_proto: *Field`. That would save 24
bytes per Text node (or Element, ...). Large websites have 20K+ nodes, so we're
talking 300-500KB savings.

ef756b0c96 was the first phase of this. This is
the second, and it's targetting at CData for a simple reason: CData currently
has an optimization that makes removal of `_proto: *Field` difficult: it
directly embeds its empty types (most notably, Text). Zig's @offsetOf doesn't
work on tagged unions, so we'd have to jump through hoops to figure it out (it
is doable though). Also, CData has a "incorrect" flattened CDATASection
specifically so that Text doesn't inherit a _type union..so that's another
problem.

The solution is to move to bare unions, which allows us to use our Factory
to control the layout of the CData and thus have predictable offsets.

CData is now an inconsistent with the rest, but, at the very least, all Node
types will move in this direction.
2026-07-29 10:34:03 +08:00
Karl Seguin
d5183da540 design: add explicit Proto declaration to every type
This is groundwork for eventually removing the _proto: *X` field from some
types (in order to save 8 bytes per, e.g. Node). For now, all `_proto: *X`
fields are untouched, BUT, all compile-time chain walking now happens against
this new declaration.
2026-07-29 10:34:01 +08:00
Karl Seguin
a2459b62d4 fix: collection bugs
Builds on top of the excellent https://github.com/lightpanda-io/browser/pull/3072

1 - HTMLAllCollection now composes NodeLive to get the performance benefit
2 - NodeLive now also optimizes for same-index access, e.g. x[i].a, x[i].b.
3 - NodeLive and RadioNodeList now don't lose their position when different
    operations types are mixed (e.g. next() wit getAtIndex())
2026-07-29 07:20:48 +08:00
Karl Seguin
5bbec625d0 Merge pull request #3068 from lightpanda-io/node-children-design
mem: optimize node child list
2026-07-29 06:45:51 +08:00
Karl Seguin
53ad5f53f6 Merge pull request #3067 from lightpanda-io/dead-imports
chore: remove unused imports
2026-07-29 06:45:30 +08:00
Karl Seguin
0c32de315f Merge pull request #3066 from lightpanda-io/svg-cleanup
webapi: SVG cleanup
2026-07-29 06:45:15 +08:00
Karl Seguin
1414a7d549 Merge pull request #3072 from staylor/fix/htmlcollection-indexed-walk
Keep ascending live collection reads linear
2026-07-28 19:46:14 +08:00
Adrià Arrufat
c9f7a11e42 Merge pull request #3073 from lightpanda-io/agent-tool-cap
agent: reduce tool output cap to 64KB except for extract
2026-07-28 09:44:39 +02:00