Black pictures after a playing time

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. .

@yaxinhoo yes… The upgrade fixed it…

@saiy2k no ,i use 2.2.0 , but i got the error too.

it its the same as:


http://www.cocos2d-x.org/issues/3669

can anyone tell me which version fix it?

Thanks man, this was my case too. I use cocos2d-x 3.2 and was having this issue when trying to show a fail popup when Android IAP was not successful. In addition to your answer I want to mention that using cocos2dx thread to draw, you should have been meant GLThread which is different from Android UI thread. So we have to do something like this:

private void SendMessageWithParametersInGLThread(final String functionName, final JSONObject parameters) {
	((AppActivity)mContext).runOnGLThread(new Runnable() {
	  public void run() {
                       // here I use EasyNDK and mContext = AppActivity.this;
		  AndroidNDKHelper.SendMessageWithParameters(functionName, parameters);
	  }
	});
}

I am bumping into this now as well. I am just now assuming that this is due to out-of-memory after awhile. I haven’t looked at memory usage of my app yet, it’s likely that it leaks. I use huge background images :stuck_out_tongue:

can you please share this fix in cocos2dx 2.2.6