tangrams / tangram

WebGL map rendering engine for creative cartography
https://tangram.city
MIT License
2.21k stars 290 forks source link

Why do you prune iles? #760

Closed sheikh-iffi closed 4 years ago

sheikh-iffi commented 4 years ago

TANGRAM VERSION: 20.1

I have a question. Why do you guys discard tiles which are far from current zoom or out of view port. pruneTilesForView Isn't it better to retain those tiles since one may want to go back to his previous selected location. In current scenario, tangram would download those tiles again. Or it has to do something with the performance?

bcamper commented 4 years ago

Tile retain a significant amount of memory. If you were to let them grow unbounded, eventually your browser tab will crash (or at the least you are not being responsible as an app); mobile device browsers are particularly strict about this. As you can see from the linked code, there is logic to retain tiles based on factors including how far away they are in zoom or pan from current location. There's always room to tweak that behavior, but Tangram is an inherently high-memory-use application.

Re: "download those tiles again", in some cases the underlying data for the tile is cached and preprocessed but the styling info may not be, and in others, while it is technically a network request, the response should be cached and essentially a no op.