Slow Response coming out of sleep mode

Hi. I have an issue with my game in that if the device is put into sleep mode while the game is running, then woken up, the game takes about 1-2 sec to be responsive again. In some cases the QA testing has seen the game terminate because its too unresponsive at this stage. Where should I be looking to see if I can improve the waking up times here?

+1

My problem is more serious~
When resume app from background, it takes up to 30 minuts or more, or never resume …

LG P990/Android 2.2: 10 seconds
HTC G14/Android 4.0: 30 seconds, or never
Huawei Honor: Never

+1

Anyone out there got a fix?

Bump, anyone know where to begin looking for a solution? Resume right now takes around 5 seconds, and since other games resume more/less instant it should be possible to fix I recon.

CCTextureCache reloads all textures in a blocked way, if you have many textures, “force close” might appear.

Currently I have a solution, it works, but not perfect:

  1. modify CCTextrueCache and VolatileTexture, add something like this:

    //save the texture list to be reloaded
    int prepareReloadTextures();
    //reloads 1 texture in each call and returns true if finished
    bool reloadNextTexture();

  2. Create a fullscreen CCNode as a “loading screen”, which shows “Reloading”, and calls reloadNextTexture() repeatly

    #if CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID
    class ReloadingNode : public CCNode {

    bool init() {
    // show something, like a black background with a label “RELOADING…”

     cocos2d::CCTextureCache::sharedTextureCache()->prepareReloadTextures();
     return true;
    

    }

    virtual void onEnter() {
    this->scheduleUpdate();
    CCNode::onEnter();
    }

    void update(cocos2d::ccTime dt) {
    if( !cocos2d::CCTextureCache::sharedTextureCache()->reloadNextTexture() )
    return;

     // reload finished
     this->removeFromParentAndCleanup(true);
    

    }
    }

  3. In main.cpp, there’s a line:

    cocos2d::CCTextureCache::reloadAllTextures();

remove it, and shows ReloadingNode at the top of screen
Make sure it’s the top most node, and won’t be removed before all textures been reloaded.

Good luck~

UPDATE: it’s better to call removeUnusedTextures() before reloading