Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color relief performance #1879

Closed
averas opened this issue Dec 29, 2015 · 8 comments
Closed

Color relief performance #1879

averas opened this issue Dec 29, 2015 · 8 comments

Comments

@averas
Copy link
Contributor

averas commented Dec 29, 2015

I have started "porting" one of my old raster based shaded relief implementations to GL but immediately ran into some indications that performance might be an issue, and hoped that there might be some good insights as to why.

Basically my setup consists of contour lines, color relief and hillshade. So far I've managed to get the contours and color relief working in GL using vector tiles. The contours work fine and as expected; it's when I added the color relief signs of problems showed up.

The color relief is polygonized from rasters and then I dynamically set up layers with filters achieving the following:

color relief

It does work quite well overall, but zooming and panning becomes choppy and CPU runs high as zoom levels increase. I experimented some between having overlapping polygons and masked polygons, and even though I got the impression that the latter was a bit more performant it still runs heavy on my high end Mac.

Any clues as to why this is challenging? It seems to me that Mapbox streets contains similarly complex areas.

Is adding layers very expensive (I have streets+20 in my test)?
Is the fact that I have filters (elevation) on these layers expensive?
Could it be that my polygons are too detailed (I haven't simplified them at all)?
Is there some collision control between these polygons going on?

@averas
Copy link
Contributor Author

averas commented Dec 30, 2015

I've fiddled around some more and it definitely seems like it's the number of layers, not the data itself, that causes performance issues.

@kristfal
Copy link

Hey,

don't have answers to all your questions, but I've been experimenting quite a lot with performance optimizations (in particular on mobile devices).

In general, it seems like the no. 1 rule is to keep the amount of layers in the style.json to a minimum – even if it would mean duplicating vector data in the source, for instance by grouping data layers that has similar fill rendering color into a separate layer.

Beyond that, I'd recommend using the tessellation branch, it does wonders on fill-intensive styles. And a heads up, if you're using custom data, make sure your polygons have the correct winding order with the tessellation branch.

If you could post an example of the style you're making, I could have a look to see if you could shorten it somehow.

On a 💭 , I'd be really happy if some of the mapbox folks could share best practice for creating high-performance styles. For instance, what is the performance hit of antialiasing fills? Does filters have a significant cost? What about opacity for fills, symbols or lines? Line caps? Sprite sheet sizes?

@averas
Copy link
Contributor Author

averas commented Dec 30, 2015

Thanks for your feedback!

Keeping the number of layers as low as possible sounds reasonable, however, until something like #1626 is done I think the only way to achieve a color relief is to have multiple layers with filters for each color step.

I tried out the earcut-final branch, and just as you said, it was substantially more performant for the color relief polygons, actually to a degree where I couldn't tell it was slower than other areas.

@mourner
Copy link
Member

mourner commented Dec 30, 2015

Yes, the number of layers affects rendering performance severely. We're actively pushing towards data-driven styling #1626 to solve this. Another reason might be that polygon fills are currently expensive, and you might get better performance with earcut-final branch. #1606

@mourner mourner closed this as completed Dec 30, 2015
@averas
Copy link
Contributor Author

averas commented Dec 30, 2015

@mourner Yes, on @kristfal 's suggestion I tried out the earcut-final branch and it was a lot more performant. Looking forward to see it merged!

@averas
Copy link
Contributor Author

averas commented Jan 5, 2016

@mourner You wrote that the number of layers affects rendering performance severely.

Just to dig a bit into this - could you briefly elaborate on how rendering cost differs between:

  • A layer with a vector tile source without any data (i.e. still fetching tiles)
  • A layer with a GeoJSON source without any features
  • A layer with source data but with its visibility set to none
  • A layer without source data and its visibility set to none (is this close to equally cheap as no layer at all?)

@mourner
Copy link
Member

mourner commented Jan 5, 2016

@averas performance should be affected by every layer that is rendered (e.g. visible, with data, etc.), because each layer requires a separate set of WebGL draw calls which are expensive.

@averas
Copy link
Contributor Author

averas commented Jan 5, 2016

Cool, thanks.

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

No branches or pull requests

3 participants