Pre-cache memory into texture memory?

Hi,

I have a Chinese Pineapple Poker game and when the user starts the app all cards, slots, points etc. etc. are drawn outside of the screen so that I later on can move them as it makes the switch between tables 100% smooth instead of removing and redrawing everything.

However, the first time it loads a table it needs to load a lot of stuff (cards, slots, points etc.) and it is a short lag.

So my questions is if it’s possible to preload all the images into the texture memory without putting them on screen to avoid this small lag in the beginning?

https://play.google.com/store/apps/details?id=com.jefecitostudios.pineapp&hl=en

Best regards,

Tomas

You could load them and set the isVisible property to false and only make them visible when you need them displayed. You could also position the images off screen when not displayed.

Hi Tom,

it seems to work better but I still have some problem (might be because of other resources not being loaded, still looking into this).

Do you have a blog post or something describing when images are being pre-cached into texture memory and stuff like that?

Best regards,

Tomas

If I press the Home button and go into a Suspend mode i.e. I do not close the app what happens with the cached display objects?

Best regards,

Tomas

If you suspend and do not exit, the images are still in memory where you left them.

Rob

Hi Rob,

For example I have a lobby and if I close it, press the home button, resumes the app I can see a small lag. So are is it really cached?

I only see this problem the first time with the lobby, after that it flows well.

Even if I wait (for all the network stuff to do it’s job, which has nothing to do with the lobby, it still lags a little bit.

Best regards,

Tomas

Lags can come from many places.  I don’t know what you’re using for a lobby system, but perhaps the lag is connecting to the service and getting all of that setup.

Rob

This is on Android right?  I’m not sure how Android handles things backgrounded.  Let me see if I can get a clarification.

Hi,

Yes, I’m doing these test on a Samsung Galaxy S4.

Best regards,

Tomas

It appears that on Android, that the OS doesn’t keep the memory around when suspended and it has to reconstruct when coming back. 

Rob

Engineering confirmed that Android and Windows Phone both dump memory when suspending and we have to reload everything on resume.  If it’s taking too long, you could always start a activity indicator or have a progress bar.  This is how most big android games handle this.

Rob

You could load them and set the isVisible property to false and only make them visible when you need them displayed. You could also position the images off screen when not displayed.

Hi Tom,

it seems to work better but I still have some problem (might be because of other resources not being loaded, still looking into this).

Do you have a blog post or something describing when images are being pre-cached into texture memory and stuff like that?

Best regards,

Tomas

If I press the Home button and go into a Suspend mode i.e. I do not close the app what happens with the cached display objects?

Best regards,

Tomas

If you suspend and do not exit, the images are still in memory where you left them.

Rob

Hi Rob,

For example I have a lobby and if I close it, press the home button, resumes the app I can see a small lag. So are is it really cached?

I only see this problem the first time with the lobby, after that it flows well.

Even if I wait (for all the network stuff to do it’s job, which has nothing to do with the lobby, it still lags a little bit.

Best regards,

Tomas

Lags can come from many places.  I don’t know what you’re using for a lobby system, but perhaps the lag is connecting to the service and getting all of that setup.

Rob

This is on Android right?  I’m not sure how Android handles things backgrounded.  Let me see if I can get a clarification.

Hi,

Yes, I’m doing these test on a Samsung Galaxy S4.

Best regards,

Tomas

It appears that on Android, that the OS doesn’t keep the memory around when suspended and it has to reconstruct when coming back. 

Rob