0
votes

I am developing a 2d game using LibGdx framework , when i press HOME button and then resume the game it freezes for 3-4 secs as the textures are being reloaded . I have used AssetManager to load the TextureAtlas & then getting the images by findRegion . I referred to documentation for "Texture" (http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/Texture.html) and it mentions that " If the OpenGL context is lost all managed textures get invalidated. This happens when a user switches to another application or receives an incoming call. Managed textures get reloaded automatically.". I am confused what to avoid this delay !!

Kindly Help Thanks

1
are you sure this is causing the delay? Try logging the time before and after the onResume() texture loadsrbennett485
How long does it take for your app to start from scratch (kill any background instance in your task manager, and then start).P.T.
It doesnot take time to start , only after i start my gameplay & go to home screen , while resuming the game there's a delayRaoChin2

1 Answers

0
votes

There will always be a delay on resuming the game.

This is because on android if you press home button or switch to another app a so called context loss occures.

When a context loss occurs on Android, it means that the operating system has decided to forcefully free the memory that was occupied with your loaded assets.

When you switch back to the game you need to reload these assets again to prevent the game from crashing and this reloading is reason for the delay.