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
Vector tile performance #7549
Comments
It's simply the number of canvas instructions. OpenLayers uses Canvas 2D, whereas Mapbox and Google Maps use WebGL. Google Maps also uses a technique similar to our default renderMode ('hybrid'). Any reason why you're not using the standard render mode? |
I see. I wanted the improved aesthetics of the 'vector' mode, which doesn't have the scaled images. I noticed that hybrid mode still has issues with stutter if you have loadTilesWhileInteracting turned on, which I like to use for other types of layers (WMS). But all in all, what I'm looking for might not be achievable with the Canvas renderer? |
The frame rate drop while loading tiles is something we might be able to improve in the future. For the rendering itself, we already do all the known optimizations. You might want to have a look at the ol-mapbox-style package, which creates optimized style functions from Mapbox Style documents. That should give you decent performance, although of course a bit slower than mapbox-gl-js, and with the scaled images of the hybrid mode. In the end, if all you're interested in is super fast vector tile rendering, mapbox-gl-js will probably better suit your needs than OpenLayers. |
Thank you for the information. It's not all I'm interested in, and I'm happy with openlayers overall, but I can't deny that mapbox's rendering speed is very attractive. I'll take a look at your suggestions. I think this can be closed. |
I've also wondered why OpenLayers are slower in vector maps operations. I take for granted that it isn't possible to improve the speed (much), but what I think could be improved it the responsiveness. What currently happens is that map doesn't react to user commands, like zoom or drag, even for several seconds (subject to map size and device speed), which results in a terrible user experience. One of the main reasons seems to be the code in CanvasTileLayerRenderer.renderFrame(), where this.drawTileImage() is called in a loop. This can block JS for a long time. I wonder, isn't is possible to break this loop when taking too long (like ~18ms or so) and leave the rendering to continue later, when JS has chance to process input events, etc.? |
We did some experiments in that direction already @jirihajek, and now we conditionally break out of That said, we're open for improvement suggestions here. So if you can provide a pull request with your desired change, it will be gladly accepted. I am reopening this issue to track progress. Another note along these lines: I have started experimenting with OffscreenCanvas, also with the goal to avoid UI blocking tasks in the main thread. See #10828 for the result. |
Wow, the OffscreenCanvas example is really impressive! With some more optimizations and particularly wider browser support this seems to be the way to go. I haven't had time to look into the breaking render loop optimizations mentioned above and to be honest, given the OffscreenCanvas performance, I'd say it doesn't make much sense to do so. I wonder though, until this is fully working solution, has anyone considered mixed usage of MapBox with OL? The idea is to use MapBox to quickly render the vector layer map and use OL to render all the rest, then mix this in a single canvas to be shown. I haven't found such an implementation and wonder whether anyone has an insight, whether this is possible and makes sense. Thanks! |
There is an example showing just that: https://openlayers.org/en/master/examples/mapbox-layer.html But this relies on a Mapbox-gl-js undocumented API, so it will stay "experimental" until Mapbox-gl-js offers a safer way of syncing maps. Use at your own risk! |
Indeed, not sure how I'd missed this one, seems to be working fine. I don't see any problem to use this, apart from the mentioned possible issue with future MapBox upgrades. Thanks! |
This is indeed very appealing in terms of performance. I wonder though, is there a way to use this technique with other projections than EPSG:3857 ? Thanks! |
No, maybe in the future: mapbox/mapbox-gl-js#3184 |
Unfortunately OpenLayers performance is not great with VectorTiles. This is because it uses a canvas object to render these tiles, whereas MapBox uses WebGL: openlayers/openlayers#7549
I think it would be nice to use hybrid mode when zoomed out and vector mode when zoomed in:
Currently this probably could be simulated by defining two layers with min/maxResolution:
Render mode could be changed to
|
Good suggestion, @cns-solutions-admin. We could also automatically switch modes, depending on the time spent in the previous animation frame. Because complexity of tiles not always correlates with zoom levels. |
With #13461 merged and released in v7 we will hopefully get a WebGL based vector tile renderer in the near future. That should improve performance drastically. |
Hi, is there any update on a WebGL based vector tile renderer for openlayers? This would be a game-changer. Thanks! |
An experimental renderer is in since #14445 🙂 There is currently ongoing work on webgl rendering in OpenLayers as part of a sponsoring by BSW-Hamburg and Landesbetrieb Geoinformation und Vermessung Hamburg. |
ol-debug.js
, notol.js
) that shows the issue.I am experimenting with mapbox vector tiles and renderMode: 'vector'. However, in certain zoom levels the frame rate of the map drops dramatically. Mapbox itself achieves better performance, and similar maps in google maps perform very well. I have no idea how they do it, but I was wondering if anyone has any leads or have investigated this issue.
I created a code pen to show the issue: https://codepen.io/anon/pen/GOazbE?&editors=1110
I did some profiling and noticed most time is spent in ol.render.canvas.Replay.
The text was updated successfully, but these errors were encountered: