Skip to content

fix: prevent browser freeze when tessellating >50k vertices (#8219 )#8555

Open
Nixxx19 wants to merge 3 commits intoprocessing:mainfrom
Nixxx19:nityam/tessellation-freeze-fix
Open

fix: prevent browser freeze when tessellating >50k vertices (#8219 )#8555
Nixxx19 wants to merge 3 commits intoprocessing:mainfrom
Nixxx19:nityam/tessellation-freeze-fix

Conversation

@Nixxx19
Copy link

@Nixxx19 Nixxx19 commented Feb 22, 2026

Resolves #8219

Summary

  • Adds a one‑time confirmation prompt before tessellating very large TESS shapes (>50,000 vertices) to avoid browser freezes in libtess during _triangulate().
  • Cancel: skips tessellation and draws nothing for that shape (no TRIANGLE_FAN fallback), keeping behavior explicit and predictable.
  • OK: remembers the choice for the lifetime of the renderer via _largeTessellationAcknowledged and tessellates normally without prompting again.
  • Respects p5.disableFriendlyErrors / minified builds: when friendly errors are disabled, tessellation always runs with no prompt.

Tests

  • Adds / updates WebGL unit tests in test/unit/webgl/p5.RendererGL.js to cover:
    • Prompting once for large shapes and including the vertex count in the message.
    • Skipping tessellation entirely on cancel (no TRIANGLE_FAN fallback).
    • Only prompting once per renderer when the user approves.
    • Skipping the prompt when p5.disableFriendlyErrors is true.
    • Normal tessellation behavior for shapes below the 50k‑vertex threshold.

Screenshot

Screenshot 2026-03-17 at 4 20 38 PM

PR Checklist

  • npm run lint passes
  • Inline reference is included / updated (not applicable – bug fix only)
  • Unit tests are included / updated

@welcome
Copy link

welcome bot commented Feb 22, 2026

🎉 Thanks for opening this pull request! For guidance on contributing, check out our contributor guidelines and other resources for contributors!
🤔 Please ensure that your PR links to an issue, which has been approved for work by a maintainer; otherwise, there might already be someone working on it, or still ongoing discussion about implementation. You are welcome to join the discussion in an Issue if you're not sure!
🌸 Once your PR is merged, be sure to add yourself to the list of contributors on the readme page !

Thank You!

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.

Browser freeze when creating >65k vertices in draw() loop (no validation or warning)

1 participant