Skip to content

Antenna sample: make the circles in slices so the page does not freeze on load - #75

Merged
wf9a5m75 merged 1 commit into
developfrom
fix/antenna-states-in-slices
Nov 13, 2026
Merged

wf9a5m75 merged 1 commit into
developfrom
fix/antenna-states-in-slices

Conversation

@wf9a5m75

Copy link
Copy Markdown
Contributor

On a Pixel 5a, demo-react's antenna-horizons page froze for several seconds after loading.

Cause
The freeze isn't the decoding of the data: decodeAntennas takes 72 ms at 6× CPU throttling. It's creating the 723,800 CircleStates in one go.

  • In Node, 723,800 createCircleState calls take 3.0 s, against 61 ms for plain objects with the same fields.
  • Each state defines its own enumerable accessors, which keeps { ...state } working.

Change

  • The states are made in slices of up to 12 ms, with setTimeout(0) between them, so the page can draw and respond meanwhile.
  • The Loading overlay stays up while they are made.
  • <Circles> receives the full list once, as before.

Measured: desktop Chrome with 6× CPU throttling (about a Pixel 5a), main-thread long tasks during the first load:

  • Before: one 17.3 s task.
  • After: the longest is 3.1 s; the rest are 0.2–1.2 s.

The remaining 3.1 s is the SDK's synchronous hand-over of the list to <Circles> (applyDiff / add). That can be improved separately in js-sdk-core and js-sdk-react.

A worker doesn't help here: CircleStates carry methods and subscriptions and cannot be made in one and passed back, and the part a worker could do (decoding) is small.

Not merged: the 0.4.1 release is in progress on develop.

…eze on load

Making 723,800 CircleStates took seconds on a phone in one go (each state carries
its own accessors); decoding the data was a small part of it. They are now made
12 ms at a time with the page free to draw between slices, behind the Loading
overlay.
@wf9a5m75
wf9a5m75 merged commit 271ad15 into develop Nov 13, 2026
3 checks passed
@wf9a5m75
wf9a5m75 deleted the fix/antenna-states-in-slices branch November 13, 2026 14:12
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.

1 participant