Black pictures after a playing time

Good to know it works now. :slight_smile:

Atwood Yen wrote:

James Chen wrote:
> I mean you have to checkout a new branch based on the cocos2d-x/master branch.
> Then,
> […]
>
Dear James…
>
I tried, The bug was gone on my HTC New One, We will try another devices later.
Thanks for you help!
>
Still expecting new version!
>
BR.
>
Atwood

Dear James…
I tried the new 2.1.5, Black pictures bug is fix, But the background music can’t be resume.
I add these code in AppDelegate.cpp already.

void AppDelegate::applicationDidEnterBackground()
{
:
CocosDenshion::SimpleAudioEngine::shareEngine()->pauseBackgroundMusic();
}

void AppDelegate::applicationWillEnterForeground()
{
:
CocosDenshion::SimpleAudioEngine::shareEngine()->resumeBackgroundMusic();
}

But the background music did not resume, and I try target platform 2.3 , 3.1 & 4.03, all not work!

Atwood Yen wrote:

Dear James…
I tried the new 2.1.5, Black pictures bug is fix, But the background music can’t be resume.
I add these code in AppDelegate.cpp already.
>
void AppDelegate::applicationDidEnterBackground()
{
:
CocosDenshion::SimpleAudioEngine::shareEngine()->pauseBackgroundMusic();
}
>
void AppDelegate::applicationWillEnterForeground()
{
:
CocosDenshion::SimpleAudioEngine::shareEngine()->resumeBackgroundMusic();
}
>
But the background music did not resume, and I try target platform 2.3 , 3.1 & 4.03, all not work!

Was this issue reported ? Could you provide the issue URL or the thread in the forum? Did the issue appear from v2.1.4 ?

James Chen wrote:

Was this issue reported ? Could you provide the issue URL or the thread in the forum? Did the issue appear from v2.1.4 ?

Someone report this issue before…

http://www.cocos2d-x.org/boards/6/topics/15810

But I tried the Marina’s way (add onWindowFocusChanged) still not work.
and I go back to 2.1.4, found the background music didn’t resume too.

On Android ?

modify Cocos2dxActivity.java

    private void resumeGame() {
        mIsRunning = true;
        Cocos2dxHelper.onResume();
        this.mGLSurfaceView.onResume();
    }

    private void pauseGame() {
        mIsRunning = false;
        Cocos2dxHelper.onPause();
        this.mGLSurfaceView.onPause();
    }

    private boolean mIsRunning = false;
    private boolean mIsOnPause = false;

    @Override
    protected void onResume() {
        super.onResume();
        mIsOnPause = false;
    }

    @Override
    protected void onPause() {
        super.onPause();
        mIsOnPause = true;
        if (mIsRunning) {
            pauseGame();
        }
    }

    @Override
    public void onWindowFocusChanged(final boolean hasWindowFocus) {
        super.onWindowFocusChanged(hasWindowFocus);
        if (hasWindowFocus && !mIsOnPause) {
            resumeGame();
        }
    }

I’m having a similar issue where i only get a black screen when the app went to the background on the Kindle Fire. (However sounds/music/touch still work)
The app is build with Cocos2dx 2.1.5 and on a samsung tablet i can enter/leave the app without problems.
Also when trying to build an app with cocos2dx 2.0.4, the issue doesn’t appear on the kindle.

The huge list of constant errors i get while debugging are basically these two:
D/cocos2d-x debug info(9687): OpenGL error 0x0501 in …/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 584
D/cocos2d-x debug info(9687): OpenGL error 0x0502 in …/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 584

I have tried quite a few solutions mentioned in this thread but it doesn’t seem like any of them help. :frowning:

YuLei Liao wrote:

On Android ?
>
modify Cocos2dxActivity.java
>
[…]

Dear YuLei…

Thank you for your help!
I try your code, but still not work for my HTC new One.
This problem didn’t happen when I use 1.0.1-x-0.13.0-beta (Same HTC new One),
But I already convert all my source code to 2.1.4 or 2.1.5,
So, someone help me, please !

Same problem with Kindle Fire HD and 2.1.4 & 2.1.5 . Screen goes black when the app comes back from the background.
With these errors
D/cocos2d-x debug info(9687): OpenGL error 0x0501 in …/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 584
Seems like it is not as easy problem to be solved, because the patch in 2.1.5 didn’t work (at least for the Kindle Fire HD).
I was looking if there was a workaround,
something along these lines:

void AppDelegate::applicationWillEnterForeground()
{
sharedDirector~~>stopAnimation;
sharedDirector~~>release();
sharedDirector->runWithScene (OptionsScene::scene());

In the hope that throwing the old one away and creating a new CCDirector would solve the problem.
But the problem remains the same.

Is there a workaround solution possible along these lines?

Remco dd wrote:

I’m having a similar issue where i only get a black screen when the app went to the background on the Kindle Fire. (However sounds/music/touch still work)
The app is build with Cocos2dx 2.1.5 and on a samsung tablet i can enter/leave the app without problems.
Also when trying to build an app with cocos2dx 2.0.4, the issue doesn’t appear on the kindle.
>
The huge list of constant errors i get while debugging are basically these two:
D/cocos2d-x debug info(9687): OpenGL error 0x0501 in …/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 584
D/cocos2d-x debug info(9687): OpenGL error 0x0502 in …/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 584
>
I have tried quite a few solutions mentioned in this thread but it doesn’t seem like any of them help. :frowning:

I was experiencing this on both the Kindle Fire and 7" Fire HD, but after upgrading to 2.1.5 they all seem to be resolved.

Was this for a new project or an updated one? If an updated one, did you also update ~/proj.android/jni/hellocpp/main.cpp? I found that when I commented out the else stuff like it was in 2.1.4 I got these repeated errors.

replacement code:

void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv*  env, jobject thiz, jint w, jint h)
{
    if (!CCDirector::sharedDirector()->getOpenGLView())
    {
        CCEGLView *view = CCEGLView::sharedOpenGLView();
        view->setFrameSize(w, h);

        AppDelegate *pAppDelegate = new AppDelegate();
        CCApplication::sharedApplication()->run();
    }
    else
    {
        ccGLInvalidateStateCache();
        CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
        ccDrawInit();
        CCTextureCache::reloadAllTextures();
        CCNotificationCenter::sharedNotificationCenter()->postNotification(EVENT_COME_TO_FOREGROUND, NULL);
        CCDirector::sharedDirector()->setGLDefaultValues();
    }
}

Justin Hawkwood wrote:

Remco dd wrote:
> I’m having a similar issue where i only get a black screen when the app went to the background on the Kindle Fire. (However sounds/music/touch still work)
> The app is build with Cocos2dx 2.1.5 and on a samsung tablet i can enter/leave the app without problems.
> Also when trying to build an app with cocos2dx 2.0.4, the issue doesn’t appear on the kindle.
>
> The huge list of constant errors i get while debugging are basically these two:
> D/cocos2d-x debug info(9687): OpenGL error 0x0501 in …/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 584
> D/cocos2d-x debug info(9687): OpenGL error 0x0502 in …/…/…/cocos2dx/sprite_nodes/CCSprite.cpp draw 584
>
> I have tried quite a few solutions mentioned in this thread but it doesn’t seem like any of them help. :frowning:
>
I was experiencing this on both the Kindle Fire and 7" Fire HD, but after upgrading to 2.1.5 they all seem to be resolved.
>
Was this for a new project or an updated one? If an updated one, did you also update ~/proj.android/jni/hellocpp/main.cpp? I found that when I commented out the else stuff like it was in 2.1.4 I got these repeated errors.
>
replacement code:
[…]

Thanks! I was indeed upgrading and this totally fixed my issue :slight_smile: I guess upgrading cocos2dx involves a bit more than i thought.

Hello,

Our testers reported that the black screen problem persists on 2.1.5… :frowning:

Also, some more information here:
http://www.cocos2d-x.org/boards/6/topics/34674

@Jesus Bosch
What happened? Did you update to v2.1.5 and forgot to update corresponding main.cpp?
And did you rebuild cocos2d-x java lib, which is in cocos2dx/platform/android/?

Minggo Zhang wrote:

@Jesus Bosch
What happened? Did you update to v2.1.5 and forgot to update corresponding main.cpp?
And did you rebuild cocos2d-x java lib, which is in cocos2dx/platform/android/?

I had the v2.1.3 now I downloaded v2.1.5 I updated project with the new lib and the method of main.cpp as here follows, is that all I have to do ?

void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
{
if (!CCDirector::sharedDirector()->getOpenGLView())
{
CCEGLView view = CCEGLView::sharedOpenGLView;
view->setFrameSize;
AppDelegate
pAppDelegate = new AppDelegate();
CCApplication::sharedApplication()->run();
}
else
{
ccGLInvalidateStateCache();
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
ccDrawInit();
CCTextureCache::reloadAllTextures();
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVENT_COME_TO_FOREGROUND, NULL);
CCDirector::sharedDirector()->setGLDefaultValues();
}
}

@Valenti Casas
Yep. That’s all.
And make sure you refer to cocos2dx java lib, not copy these java files into your own proj.android directory.

Minggo Zhang wrote:

@Valenti Casas
Yep. That’s all.
And make sure you refer to cocos2dx java lib, not copy these java files into your own proj.android directory.

Thank you very much

Hi,
Is this black screen issue got fixed in `cocos2d-x-2.2`. Will upgrading the framework, help?
Thanks

Saiyasodharan R wrote:

Hi,
Is this black screen issue got fixed in `cocos2d-x-2.2`. Will upgrading the framework, help?
Thanks

In my case it fixed most of the occurrences.

Minggo Zhang wrote:

And make sure you refer to cocos2dx java lib, not copy these java files into your own proj.android directory.

Minggo or someone else, why is better refer cocos2dx java lib than copy the java file into the project?

thanks
Don

If you copy cocos2dx java lib to your project, you need to maintain these files at all your project.
one day, if you make a change or add a new function in cocos2dx’s java file, you will know the reason.

And I upgrade to 2.2.1 now, The new situation on my HTC new one is my game will crash directly when I try to test my game via eclipse ADB,
But work fine if I run directly (not via Eclipse & ADB). and another device (Like Motorola MZ604 and ASUS pad…) will run normal via eclipse ADB.
I don’t know what’s the reason, But HTC new one is Android 4.3 and resolution is 1920 * 1080.

does this fix on 2.2.0 ? the ccsprite texture error’s when app enter forceground from background. .