mapbox / mapbox/mapbox-gl-js

What is the expected behaviour of isTileClipped

Open
#5,672 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

refactoring :building_construction:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

It's not clear to me how exactly isTileClipped is supposed to work, the only documentation I found was:

https://github.com/mapbox/mapbox-gl-js/blob/3a9a308e0a2212f212f5790707621c407023a9df/src/source/source.js#L31

The drawing of the tiles to the stencil buffer is only performed when isTileClipped:

https://github.com/mapbox/mapbox-gl-js/blob/3a9a308e0a2212f212f5790707621c407023a9df/src/render/painter.js#L383

However, it seems like the most common drawing code (fill/line/symbol) expects there to have been the tile stencil written, and there is no error checking:

https://github.com/mapbox/mapbox-gl-js/blob/3a9a308e0a2212f212f5790707621c407023a9df/src/render/draw_line.js#L111

This means if you are naïve like me and set isTileClipped to false to allow your tiles to overdraw, then you will get really erratic behaviour from undefined being returned from the _tileClippingMaskIDs lookup in enableTileClippingMask (or whatever else might have happened depending on other sources in the drawing). Would be nice to perhaps make this an error (check that _tileClippingMaskIDs exists and that the entry on _tileClippingMaskIDs also exists), but it seems like perhaps the behaviour could also be to only enable the clipping masks when isTileClipped is true, which I think then should give the behaviour to allow lines / etc to draw outside of their tile...

I'd be happy to write a patch for it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked sections in src/source/source.js, src/render/painter.js, and src/render/draw_line.js, then trace enableTileClippingMask and the _tileClippingMaskIDs lookup. Determine the intended behavior when isTileClipped is false, including whether clipping should be skipped or treated as an error. Done means the behavior is defined and the resulting tile drawing is no longer erratic.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
computer-graphics, frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.