Commit Graph
4932 Commits
Author SHA1 Message Date
Karl Seguin b9bef22bbf Merge pull request #1912 from lightpanda-io/css-improvements-fix
StyleManager: restore dirty state on rebuild allocation failure
2026-03-19 10:25:09 +08:00
Adrià Arrufat b2a996e5c7 StyleManager: restore dirty state on rebuild allocation failure 2026-03-19 11:13:04 +09:00
Karl Seguin f594b033bf Merge pull request #1897 from lightpanda-io/css-improvements-perf
Introduce StyleManager
2026-03-19 07:10:35 +08:00
Karl Seguin 10e379e4fb fix clamping 2026-03-19 07:00:26 +08:00
Karl Seguin c1bb27c450 better encapsulate arena reset 2026-03-19 06:53:08 +08:00
Karl SeguinandAdrià Arrufat dda5e2c542 Apply suggestions from code review
Co-authored-by: Adrià Arrufat <1671644+arrufat@users.noreply.github.com>
2026-03-19 06:47:40 +08:00
Karl Seguin e29778d72b Introduce StyleManager
A Page now has a StyleManager. The StyleManager currently answers two questions:
1 - Is an element hidden
2 - Does an element have pointer-events == none

This is used in calls such as element.checkVisibility which, on some pages, can
be called tens of thousands of times (often through other methods, like
element.getBoundingClientRect). This _can_ be a bottleneck.

The StyleManager keeps a list of rules. The rules include the selector,
specificity, and properties that we care about. Rules in a stylesheet that
contain no properties of interest are ignored. This is the first and likely
most significant optimization. Presumably, most CSS rules don't have a
display/visibility/opacity or pointer-events property.

The list is rules is cached until stylesheets are modified or delete. When this
happens, the StyleManager is flagged as "dirty" and rebuilt on-demand in the
next query.  This is our second major optimization.

For now, to check if an element is visible, we still need to scan all rules.
But having a pre-build subset of all the rules is a first step.

The next step might be to optimize the matching, or possibly optimizing common
cases (e.g. id and/or simple class selector)
2026-03-18 17:52:57 +08:00
Adrià Arrufat 43a70272c5 Merge branch 'main' into css-improvements 2026-03-16 10:25:35 +09:00
Adrià Arrufat ddd34dc57b Merge pull request #1836 from mvanhorn/osc/1822-fix-axvalue-integer-string
fix: serialize AXValue integer as string per CDP spec
2026-03-16 09:55:54 +09:00
Karl Seguin 265c5aba2e Merge pull request #1850 from navidemad/fix/cdp-websocket-timeout-during-navigation
Fix CDP WebSocket connection dying during complex page navigation
2026-03-16 08:41:36 +08:00
Adrià Arrufat 21fc6d1cf6 cdp: explain buffer size for int serialization 2026-03-16 09:41:28 +09:00
Karl Seguin 1a7fe6129c Merge pull request #1847 from lightpanda-io/blob_fixes
Fix issues with blobs
2026-03-16 08:34:38 +08:00
Karl Seguin 37462a16c5 Merge pull request #1853 from lightpanda-io/fix-ignore-partition-key
Fix ignore partition key
2026-03-16 08:19:09 +08:00
Karl Seguin 323ec0046c zig fmt 2026-03-16 07:36:14 +08:00
Karl Seguin dc7c6984fb Merge pull request #1852 from lightpanda-io/fix-domparser-error-doc
Fix domparser error doc
2026-03-16 07:35:50 +08:00
Karl Seguin 92f7248a16 Merge pull request #1851 from lightpanda-io/fix-fetch-error-reject
Fix fetch error reject
2026-03-16 07:35:38 +08:00
Karl Seguin 1ec3e156fb Fix partitionKey ignore PR
Fixes https://github.com/lightpanda-io/browser/pull/1821 so that it compiles
2026-03-16 07:28:14 +08:00
Karl Seguin 1121bed49b remove test that I guess isn't reliable (CI?) 2026-03-16 07:20:57 +08:00
Karl Seguin 0eb43fb530 Fix test
Fixes test associated with https://github.com/lightpanda-io/browser/pull/1827
2026-03-16 07:16:27 +08:00
Karl Seguin 1f50dc38c3 Merge pull request #1845 from navidemad/fix-cdp-unknown-domain-disconnect
fix(cdp): don't kill WebSocket on unknown domain/method errors
2026-03-16 07:14:18 +08:00
Karl Seguin a9d044ec10 revert domparser test change that belongs to a different PR 2026-03-16 07:11:06 +08:00
Navid EMADandClaude Opus 4.6 1bdf464ef2 Fix CDP WebSocket connection dying during complex page navigation
The CDP timeout handler in httpLoop had two compounding bugs:

1. Unit mismatch: timestamp(.monotonic) returns seconds, but
   ms_remaining is in milliseconds. The comparison and subtraction
   mixed units.

2. Double-counting: In the .done branch, elapsed was computed as
   absolute time since last_message, but last_message was never
   updated in this branch. Each iteration subtracted the growing
   total elapsed seconds from an already-decremented ms_remaining.

During complex page loads, Session._wait() returns .done rapidly
(due to JS macrotask execution, background tasks, or errors). Each
rapid .done return subtracted the growing elapsed (seconds) from
ms_remaining (milliseconds), draining it to zero in ~2 seconds
instead of the configured 10-second timeout.

Fix: use milliTimestamp() for consistent units, update last_message
in the .done branch for incremental elapsed tracking, and use >= for
correct boundary comparison.

Fixes #1849

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 23:07:23 +01:00
katie-lpd a70da0d176 Update README.md 2026-03-15 16:57:09 +01:00
katie-lpd 8c52b8357c Update README.md 2026-03-15 16:33:53 +01:00
Karl Seguin 0243c6b450 Fix issues with blobs
https://github.com/lightpanda-io/browser/pull/1775 made blobs finalizable and
https://github.com/lightpanda-io/browser/pull/1795 made it possible to navigate
from blobs (important for WPT tests). This fixes a number of issues related to
both.

First, weak/strong ref'ing a value now uses the resolved value. When registering
a finalizer, we use the resolved value (the most specific type in the prototype
chain). For this reason, when toggling a weak/strong ref, we have to use the
same resolved value. This solves a segfault where a File is created, but
extended as a Blob (e.g. in createObjectURL).

Next, two issues were fixed when navigating to an invalid blob. First, the frame
is properly removed from the parent list on frame navigation error. Second,
on frame navigation error, we don't stop _all_ other navigations, we just log
the error and move on to the next frame.
2026-03-15 21:03:55 +08:00
Adrià Arrufat f7071447cb Merge pull request #1834 from evalstate/mcp-ping
feat(mcp): add ping request handling
2026-03-15 18:15:51 +09:00
Halil Durak c038bfafa1 Merge pull request #1772 from lightpanda-io/nikneym/failing-body-onload-tests
Add failing `body.onload` tests
2026-03-15 10:58:39 +03:00
sjhddh 4d60f56e66 test: add test case for fetch throwing TypeError on network errors 2026-03-15 07:26:18 +00:00
sjhddh 56d3cf51e8 test: update empty xml parse error case in domparser.html 2026-03-15 07:25:47 +00:00
sjhddh 3013e3a9e6 fix(net): fetch() should reject with a TypeError on network errors 2026-03-15 07:25:47 +00:00
Navid EMADandClaude Opus 4.6 fe9b2e672b fix(test): update tests to match new CDP error handling behavior
processMessage no longer returns Zig errors when dispatchCommand fails —
it sends a CDP error response and continues. Update all expectError calls
to use processMessage + expectSentError instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 05:52:20 +01:00
Navid EMADandClaude Opus 4.6 a2e66f85a1 fix(cdp): don't kill WebSocket on unknown domain/method errors
When a CDP command with an unrecognized domain (e.g. `NonExistent.method`)
was sent, the error response was correctly returned but the connection
died immediately after. This happened because dispatch() re-returned the
error after sending the error response, which propagated up through
processMessage() → handleMessage() where `catch return false` closed
the WebSocket connection.

Now the error is only propagated if sendError itself fails (e.g. broken
pipe). Otherwise dispatch() returns normally and the read loop continues.

Fixes #1843

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 04:36:47 +01:00
Karl Seguin a9b9cf14c3 Merge pull request #1841 from lightpanda-io/reject_error
Improve ergonomics around rejecting a promise with a proper JS error
2026-03-15 10:19:24 +08:00
Karl Seguin d4b941cf30 zig fmt 2026-03-15 10:06:20 +08:00
Karl Seguin 4b6bf29b83 Improve ergonomics around rejecting a promise with a proper JS error 2026-03-15 09:55:13 +08:00
Matt Van Horn 5bc00045c7 fix: serialize AXValue integer as string per CDP spec
The CDP Accessibility spec defines AXValue.value as always being a
string, but integer values were serialized as JSON numbers. This
breaks CDP clients with strict deserialization (e.g., Rust serde).

Fixes #1822
2026-03-14 14:09:49 -07:00
evalstate 93ea95af24 feat(mcp): add ping request handling 2026-03-14 17:48:29 +00:00
Adrià Arrufat f0c9c262ca Merge branch 'main' into css-improvements 2026-03-14 20:36:50 +09:00
Karl Seguin 42bb2f3c58 Merge pull request #1823 from lightpanda-io/remove_double_free
Remove frame double-free on navigate error
2026-03-14 19:36:27 +08:00
Adrià Arrufat 3fde349b9f webapi): reorder css function params and merge pointer events 2026-03-14 20:31:00 +09:00
Adrià Arrufat 55a9976d46 css: CSSStyleSheet.replace() should resolve to the stylesheet 2026-03-14 20:30:00 +09:00
Adrià Arrufat 66a86541d1 css: handle top-level semicolons in parser 2026-03-14 20:30:00 +09:00
Adrià Arrufat bc19079dad css: add unit tests for RulesIterator 2026-03-14 20:30:00 +09:00
Adrià Arrufat 351e44343d css: make CSSStyleSheet.insertRule index optional 2026-03-14 20:30:00 +09:00
Adrià ArrufatandKarl Seguin e362a9cbc3 webapi.Element: use dot notation
Co-authored-by: Karl Seguin <karlseguin@users.noreply.github.com>
2026-03-14 20:29:54 +09:00
Adrià ArrufatandKarl Seguin e2563e57f2 webapi.Element: make getCssProperties private
Co-authored-by: Karl Seguin <karlseguin@users.noreply.github.com>
2026-03-14 20:18:51 +09:00
Adrià ArrufatandKarl Seguin df5e978247 tests: remove warning
Co-authored-by: Karl Seguin <karlseguin@users.noreply.github.com>
2026-03-14 19:54:43 +09:00
hobostayandClaude Opus 4.6 68337a6989 Fix compilation errors: add missing log import and remove duplicate
- Add missing `const log = @import("../../log.zig");` in network.zig
- Remove duplicate `log` declaration inside setCdpCookie in storage.zig
  (already declared at file scope)

Fixes compilation errors:
- src/cdp/domains/network.zig:124:9: error: use of undeclared identifier 'log'
- src/cdp/domains/storage.zig:135:15: error: local constant shadows declaration of 'log'

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 17:32:48 +08:00
sjhddh a204f40968 fix(dom): return parsererror document on XML parse failure 2026-03-14 08:36:06 +00:00
Karl Seguin fe3faa0a5a Merge pull request #1825 from sjhddh/fix-tracking-allocator-resize
fix: only increment TrackingAllocator reallocation_count on successful resizes
v0.2.6
2026-03-14 15:48:49 +08:00