[pull] main from tldraw:main#540
Merged
Merged
Conversation
Bumps `next` from `15.5.15` to `15.5.16` to pick up fixes for the React/Next.js vulnerabilities disclosed in the [Cloudflare advisory of 2026-05-06](https://developers.cloudflare.com/changelog/post/2026-05-06-react-nextjs-vulnerabilities/). Affected packages in this repo: - `apps/docs` - `templates/chat` - `templates/nextjs` Plain `react` / `react-dom` are not flagged — the advisory only names `react-server-dom-{webpack,parcel,turbopack}`, none of which are in our lockfile. After merge, add `docs-hotfix-please` to redeploy docs. Templates publish only as part of an SDK release or via a manual run of the `Publish templates` workflow. ### Change type - [x] `other` ### Test plan - CI passes (`yarn typecheck`, `yarn lint-current` clean locally) - Docs site builds with `next@15.5.16` ### Release notes - Internal-only: dependency bump for security advisory. ### Code changes | Section | LOC change | | --------------- | ---------- | | Documentation | +1 / -1 | | Templates | +2 / -2 | | Config/tooling | +44 / -44 |
In order to keep `editor.getRenderingShapes()` cheap on busy canvases, this PR caches the sort permutation by id. When the set of ids on the page hasn't changed since the last call (the common case while drawing — only props change, not the id set), we skip `Array.sort(sortById)` and place each entry at its known sorted position in O(N) instead of O(N log N). Tracing on Chrome OS at 300 shapes showed `sortById` self-time at ~2.3 ms per call, ~70 ms/sec during drawing. After this change, the same call takes ~0.1 ms on the cache-hit path (~23× faster). Stacks with the other in-flight perf work: - #8778 — incremental b64 encode and prefix-decode cache - spatial index epoch + `notVisibleShapes` short-circuit (separate PR) ### Correctness `sortById` is a deterministic, stateless string comparator on shape ids. The sorted order of an array is uniquely determined by its set of ids (ids are unique within a page). So if the cached `Map<id, sortedPosition>` has the same size as the new array and every new id is present in the cache, the cached permutation produces exactly the same result as `Array.sort(sortById)`. If any id is missing, or the size differs, we fall through to the slow path: full sort, rebuild cache. ### Change type - [x] `improvement` ### Test plan 1. Draw, drag, and select shapes on a page with many shapes (300+); ordering of overlapping shapes should be unchanged. 2. Add and delete shapes; the sort cache rebuilds on the first call after the id set changes. 3. Check that `<iframe>`-style shapes (e.g. embeds) don't re-mount when sibling shapes update — the DOM-key stability is the whole reason for the sort, and the cache must preserve it. - [x] Unit tests ### Release notes - Faster pointer events on busy canvases — `getRenderingShapes()` skips its sort step when only shape props (not the id set) have changed. ### Code changes | Section | LOC change | | --------------- | ---------- | | Core code | +31 / -1 |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )