Skip to content

Deduplicate consecutive bit-identical vertices within rings to prevent infinite loops in earcutr 0.5.0#134

Merged
balazsdukai merged 1 commit into
3DGI:masterfrom
rijos:fix/dedupvertices
May 21, 2026
Merged

Deduplicate consecutive bit-identical vertices within rings to prevent infinite loops in earcutr 0.5.0#134
balazsdukai merged 1 commit into
3DGI:masterfrom
rijos:fix/dedupvertices

Conversation

@rijos

@rijos rijos commented May 21, 2026

Copy link
Copy Markdown
Contributor

Summary
We discovered that tyler can hang indefinitely when a polygon ring contains consecutive bit-identical vertices. The hang originates in earcutr 0.5.0, which spins forever on such inputs.

This was triggered while processing two adjacent .city.json tiles. The individual tiles were valid on their own, but after merging them the resulting polygon rings contained repeated vertices along the shared edge.

This PR works around the issue downstream by stripping consecutive bit-identical duplicates from each ring (outer and holes) before handing the polygon to earcutr. Only consecutive duplicates within a single ring are merged; vertices shared between rings and non-consecutive repeats are preserved, so polygon topology is unchanged for well-formed inputs.

Follow-up
The root cause is upstream; the merge step is producing geometry that no consumer should have to defend against. I'll open a separate issue to validate the merge output so we catch this at the source rather than papering over it everywhere downstream

@balazsdukai balazsdukai merged commit 2fe5749 into 3DGI:master May 21, 2026
1 check passed
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.

2 participants