Repository navigation
Antenna sample: make the circles in slices so the page does not freeze on load - #75
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
decodeAntennastakes 72 ms at 6× CPU throttling. It's creating the 723,800CircleStates in one go.createCircleStatecalls take 3.0 s, against 61 ms for plain objects with the same fields.{ ...state }working.Change
setTimeout(0)between them, so the page can draw and respond meanwhile.<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:
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.