Skip to content

fix(editor): wrap debug SVG shapes with ShapeCullingProvider#8101

Merged
steveruizok merged 3 commits intomainfrom
mitja/fix-debug-svg-crash
Feb 28, 2026
Merged

fix(editor): wrap debug SVG shapes with ShapeCullingProvider#8101
steveruizok merged 3 commits intomainfrom
mitja/fix-debug-svg-crash

Conversation

@MitjaBezensek
Copy link
Copy Markdown
Contributor

@MitjaBezensek MitjaBezensek commented Feb 26, 2026

Closes #8100

The ShapesWithSVGs component (used when Debug SVG is enabled) renders <Shape> without a <ShapeCullingProvider> ancestor. Since the Shape component calls useShapeCulling(), this throws: "useShapeCulling must be used within ShapeCullingProvider". The ShapesToDisplay component already had this provider but ShapesWithSVGs was missing it.

This wraps ShapesWithSVGs content with <ShapeCullingProvider>, <CullingController>, and the Safari reflow workaround — matching what ShapesToDisplay already does.

Change type

  • bugfix

Test plan

  1. Open tldraw and create some shapes on the canvas
  2. Open the debug menu and enable Debug mode
  3. Enable Debug SVG
  4. Verify the app no longer crashes and SVG debug copies appear below each shape

Release notes

  • Fix crash when enabling Debug SVG with shapes on the canvas.

Note

Low Risk
Low risk: localized change to canvas shape rendering that mainly affects debug-only Debug SVG mode and reuses existing culling logic.

Overview
Fixes a crash when enabling Debug SVG by ensuring shapes rendered in that mode are wrapped in ShapeCullingProvider (so useShapeCulling() always has a provider).

Simplifies the canvas rendering path by replacing the separate ShapesWithSVGs/ShapesToDisplay branches with a single ShapesLayer that toggles debug SVG copies internally while still running CullingController and the Safari reflow workaround.

Written by Cursor Bugbot for commit aba4a4e. This will update automatically on new commits. Configure here.

@huppy-bot huppy-bot bot added the bugfix Bug fix label Feb 26, 2026
@vercel
Copy link
Copy Markdown

vercel bot commented Feb 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
examples Ready Ready Preview Feb 27, 2026 0:41am
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
analytics Ignored Ignored Preview Feb 27, 2026 0:41am
tldraw-docs Ignored Ignored Preview Feb 27, 2026 0:41am
chat-template Skipped Skipped Feb 27, 2026 0:41am
tldraw-shader Skipped Skipped Feb 27, 2026 0:41am
workflow-template Skipped Skipped Feb 27, 2026 0:41am

Request Review

@MitjaBezensek MitjaBezensek added the dotcom-hotfix-please ⚙️ Triggers tldraw.com production deploy after merge label Feb 26, 2026
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@MitjaBezensek MitjaBezensek force-pushed the mitja/fix-debug-svg-crash branch from 109201e to aba4a4e Compare February 27, 2026 12:39
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
🔵 In progress
View logs
branching-chat-template aba4a4e Feb 27 2026, 12:39 PM

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Feb 27, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
branching-chat-template aba4a4e Commit Preview URL

Branch Preview URL
Feb 27 2026, 12:42 PM

@steveruizok steveruizok added this pull request to the merge queue Feb 28, 2026
Merged via the queue into main with commit e69acb6 Feb 28, 2026
23 checks passed
@steveruizok steveruizok deleted the mitja/fix-debug-svg-crash branch February 28, 2026 13:57
huppy-bot bot pushed a commit that referenced this pull request Feb 28, 2026
Closes #8100

The `ShapesWithSVGs` component (used when Debug SVG is enabled) renders
`<Shape>` without a `<ShapeCullingProvider>` ancestor. Since the `Shape`
component calls `useShapeCulling()`, this throws: "useShapeCulling must
be used within ShapeCullingProvider". The `ShapesToDisplay` component
already had this provider but `ShapesWithSVGs` was missing it.

This wraps `ShapesWithSVGs` content with `<ShapeCullingProvider>`,
`<CullingController>`, and the Safari reflow workaround — matching what
`ShapesToDisplay` already does.

### Change type

- [x] `bugfix`

### Test plan

1. Open tldraw and create some shapes on the canvas
2. Open the debug menu and enable **Debug mode**
3. Enable **Debug SVG**
4. Verify the app no longer crashes and SVG debug copies appear below
each shape

### Release notes

- Fix crash when enabling Debug SVG with shapes on the canvas.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low risk: localized change to canvas shape rendering that mainly
affects debug-only `Debug SVG` mode and reuses existing culling logic.
> 
> **Overview**
> Fixes a crash when enabling **Debug SVG** by ensuring shapes rendered
in that mode are wrapped in `ShapeCullingProvider` (so
`useShapeCulling()` always has a provider).
> 
> Simplifies the canvas rendering path by replacing the separate
`ShapesWithSVGs`/`ShapesToDisplay` branches with a single `ShapesLayer`
that toggles debug SVG copies internally while still running
`CullingController` and the Safari reflow workaround.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
aba4a4e. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
huppy-bot bot added a commit that referenced this pull request Feb 28, 2026
This is an automated hotfix for dotcom deployment.

Original PR: #8101
Original Author: @MitjaBezensek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Bug fix dotcom-hotfix-please ⚙️ Triggers tldraw.com production deploy after merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debug SVG crashes app when shapes exist (useShapeCulling must be used within ShapeCullingProvider)

3 participants