WorldWindEarth / WorldWindAndroid

The WorldWind Android "Community Edition" SDK (WWA-CE) includes the library, examples and tutorials for building 3D virtual globe applications for phones and tablets.
https://worldwind.earth/WorldWindAndroid/
Other
16 stars 7 forks source link

Possible memory leak in Tessellator #19

Closed ComBatVision closed 5 years ago

ComBatVision commented 5 years ago

Hello, team.

I have found strange behavior of Tessellator when device rendering works with fast enough FPS. It creates new TerrainTile points cache items for the same tileKey but with different pointBufferSequence and waste all available rendering resource cache, which cause application to crash due to invalid rendering resource cache capacity initialization by default.

The crash itself fixes with PR #18, but the reason of huge amount of tile points cache creation must be clarified.

How to reproduce: If WorldWind is created with placemarks layer only (without background layer, atmosphere layer and without any map layers), then it redraws placemarks only with very high FPS (this approach can be used to output e.g. augmented reality placemarks over the device camera). When you start rotating world wind navigator very frequently (60fps) using device orientation sensors it cause frequent redraw requests. As the result, tessellator is loading terrain tiles to visualize placemarks on the real terrain altitude in different view directions. For some reasons it cause creation of 15000 terrain tile points cache items (13k size each) in rendering resource cache and overflow available application heap. But if you add at least background layer to be visible, than FPS become lower and no memory overflow happened.

I have not dig deep enough into reasons of so intensive terrain tile points cache generation and simply fix the reason of crash in PR #18 (fix cache capacity), but I think something wrong is happening in tessellator. It should not produce 200Mb tiles cache at only 3 seconds of rendering. Why it generates data with different pointBufferSequence and do not reuse same tile cache?