MovingBlocks / DestinationSol

Official continuation of Destination Sol, the great fun little arcade space shooter from http://sourceforge.net/projects/destinationsol/ Modules live at https://github.com/DestinationSol/
Apache License 2.0
325 stars 122 forks source link

fix: fix Android textures bug #629

Closed BenjaminAmos closed 2 years ago

BenjaminAmos commented 2 years ago

Description

When the game is closed using the back button on Android, the activity containing it is disposed. The runtime VM and all static variables are not disposed though, so lingering references remained in the SpriteManager cache to textures that didn't exist anymore. The SpriteManager cache is now cleared when the game's activity is destroyed.

I also added some further code to properly dispose of gestalt-managed textures, since the reason why textures appeared to be randomly swapped was because the underlying sprites referenced invalid OpenGL handles that had not been cleaned-up properly. By correctly disposing of these textures upon activity destruction, the invalid handles now show black rectangles instead.

A bit more context on the Android activity lifecycle (which is exposed by libGDX through the SolApplication#pause and SolApplication#destroy methods) can be found here.

Testing

Follow the testing instructions found in #558. The game should now appear normally, rather than with randomly-swapped textures.

Notes