Skip to content

Performance & crash fixes for chess.com#8546

Open
awesomekling wants to merge 7 commits intoLadybirdBrowser:masterfrom
awesomekling:chessperf
Open

Performance & crash fixes for chess.com#8546
awesomekling wants to merge 7 commits intoLadybirdBrowser:masterfrom
awesomekling:chessperf

Conversation

@awesomekling
Copy link
Member

Three things here:

  • Remove annoying debug spam in HTMLScriptElement.
  • Use binary search in IndexedDB to prevent 100% CPU churn in WebContent.
  • Fix crash when CSS animation produces guaranteed-invalid value.

It's funny, I figured the sluggishness on chess.com was the chess engine, but it turns out it was just IndexedDB being inefficient 😅

(Although note that the chess engine is still slow, running as Wasm in the WebWorker process.)

@awesomekling awesomekling requested a review from AtkinsSJ as a code owner March 21, 2026 05:22
This is a normal spec-mandated early return, not an error condition.
The already-started flag exists because prepare_script() is called from
multiple paths (attribute changes, child insertions, DOM connection)
and only the first call should proceed.
This is another normal spec early return in prepare_script(), not an
error worth logging.
Instead of appending and re-sorting the entire records vector on every
insert (O(n log n)), use binary search to find the correct insertion
position and insert directly (O(log n) comparisons + O(n) shift).
Use AK::binary_search instead of a linear find_if scan in
has_record_with_key(), taking advantage of the fact that records
are kept sorted by key.
Since records are sorted by key, records matching a key range form a
contiguous block. Use binary search to find the range boundaries and
remove the block in one operation, instead of scanning every record
with is_in_range().
Wrap the SerializationRecord (Vector<u8, 1024>) in an OwnPtr so that
each ObjectStoreRecord is only ~16 bytes instead of ~1040+ bytes.
This makes Vector operations on the records list dramatically cheaper
since memmove now shifts pointers instead of kilobyte-sized buffers.
When a CSS animation keyframe uses var() referencing a nonexistent or
invalid custom property, variable substitution produces a
guaranteed-invalid value. The animation keyframe processing code did not
handle this case, allowing the value to reach compute_opacity() (and
similar functions) which would hit VERIFY_NOT_REACHED().

Fix this by skipping guaranteed-invalid values in
compute_keyframe_values, matching how the regular cascading code treats
them.

This fixes a crash on chess.com.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants