Black pictures after a playing time

We’re only having this bug in a device, and we’re having difficulties to reproduce it on others…

We believe is related to losing the context and having many contexts simultaneously open on the device (many games), but doesn’t seem to trigger the error.

We’ve seen that CC_ENABLE_CACHE_TEXTURE_DATA is 0 in android… why? Shouldn’t it be 1?

`Mircea Rila
For issue #1613, I still don’t know its downsites. Some developers report their device can not support this feature, but we still haven’t reproduce it on our >20 different types of android phones.
Can your code works properly on previous cocos2d-x version?

`Jesus Bosch
Do you mean this bug occurs randomly on your device?

@dongdong li
Your situation is different. Others said their games are turn to black screen after sleep/unlock, but you said your game turn to black only with play it for a long time. So again,

  1. Does it occurs randomly?
  2. How to reproduce?

Yes, if we reload the textures when coming from background, it’s all good.
I can now confirm this problem is also reproducible on the Nexus 7 4.2.2, with the same scenario (sleep/resume/rotate screen/unlock/black screen).

Maybe it’s because of the Activity lifecycle - I will try to add more messages to android:configChanges because of this note:

“Note: If your application targets API level 13 or higher (as declared by the minSdkVersion and targetSdkVersion attributes), then you should also declare the”screenSize" configuration, because it also changes when a device switches between portrait and landscape orientations" (http://developer.android.com/guide/topics/manifest/activity-element.html)

I’ll let you know how it works out.

Ok, so in our case, this worked out:
in AndroidManifest.xml, add this:

android:configChanges=“orientation|screenSize|smallestScreenSize”

to your Cocos2D-X activity.

This solved our particular problem on Kindle Fire HD 8.9 and Nexus 7. I hope this helps anyone.

i also have this problem on my andorid device. press the home button, and resume the game,it’s all black

Zhe Wang wrote:

`Mircea Rila
For issue #1613, I still don’t know its downsites. Some developers report their device can not support this feature, but we still haven’t reproduce it on our >20 different types of android phones.
Can your code works properly on previous cocos2d-x version?

`Jesus Bosch
Do you mean this bug occurs randomly on your device?
>
@dongdong li
Your situation is different. Others said their games are turn to black screen after sleep/unlock, but you said your game turn to black only with play it for a long time. So again,

  1. Does it occurs randomly?
  2. How to reproduce?

yep, we will try to prepare a very simple project where it happens and create an issue… but is not easy to reproduce for us, seems more random

Jesus Bosch wrote:

Zhe Wang wrote:
> `Mircea Rila

For issue #1613, I still don’t know its downsites. Some developers report their device can not support this feature, but we still haven’t reproduce it on our >20 different types of android phones.
Can your code works properly on previous cocos2d-x version?

`Jesus Bosch
> Do you mean this bug occurs randomly on your device?
>
> @dongdong li
> Your situation is different. Others said their games are turn to black screen after sleep/unlock, but you said your game turn to black only with play it for a long time. So again,
> 1. Does it occurs randomly?
> 2. How to reproduce?
>
yep, we will try to prepare a very simple project where it happens and create an issue… but is not easy to reproduce for us, seems more random

I’ve met this problem only on older devices like htc desire, samsung galaxy s (android 2.2-2.3).
Maybe it depends on android version?

Mad Max wrote:

Jesus Bosch wrote:
> Zhe Wang wrote:
> > `Mircea Rila

For issue #1613, I still don’t know its downsites. Some developers report their device can not support this feature, but we still haven’t reproduce it on our >20 different types of android phones.
Can your code works properly on previous cocos2d-x version?

`Jesus Bosch
> > Do you mean this bug occurs randomly on your device?
> >
> > @dongdong li
> > Your situation is different. Others said their games are turn to black screen after sleep/unlock, but you said your game turn to black only with play it for a long time. So again,
> > 1. Does it occurs randomly?
> > 2. How to reproduce?
>
> yep, we will try to prepare a very simple project where it happens and create an issue… but is not easy to reproduce for us, seems more random
>
I’ve met this problem only on older devices like htc desire, samsung galaxy s (android 2.2-2.3).
Maybe it depends on android version?

Actually we have seen this bug on other devices with newer android versions such as Samsung galaxy note II, Galaxy tab so i don’t think it’s related to android version

I think it is a bug introduced in the latest Cocos2d-x version.
It’s ignoring the possibility of the context being lost.

Try set your CC_ENABLE_CACHE_TEXTURE_DATA to be 1 on Android and change the main.cpp to post the notification.

Oren Bengigi wrote:

I think it is a bug introduced in the latest Cocos2d-x version.
It’s ignoring the possibility of the context being lost.
>
Try set your CC_ENABLE_CACHE_TEXTURE_DATA to be 1 on Android and change the main.cpp to post the notification.

we tried with this and still happens :frowning:

@dongdong li

Could you reproduce it by using a sample project since we couldn’t reproduce it right now?
I ’ll be happy to help to debug this issue if you provide a demo. Thanks in advance.

I am sorry about that.
The reason i removed the codes for re-loading textures are
* it can save time back to foreground
* it can reduce memory usage
* the game named FishingJoy which has about 200 millions download also use this method as cocos2d-x did, and it haven’t received error report

Of course, i have to reproduce it first and resolve it if it causes problem.

Minggo Zhang wrote:

I am sorry about that.
The reason i removed the codes for re-loading textures are
* it can save time back to foreground
* it can reduce memory usage
* the game named FishingJoy which has about 200 millions download also use this method as cocos2d-x did, and it haven’t received error report
>
Of course, i have to reproduce it first and resolve it if it causes problem.

Hi Minggo,

We have preparated a very simple example. In samsung galaxy s3, open the app, press on the home button of the device, reopen the app. screen becomes totally black.

The code is extremely simple, we just add 3 big images to the scene.

Here is the code:

Thanks @Jesus Bosch, i am downloading the sample.

@Jesus Bosch, i used your sample, and tested it on g10, i9000, s2, s4, note2.
All are not problem.

I am sorry, i don’t have s3.

@Minggo Zhang can you please try to run it with as much apps already open in the background as possible?

thanks

Ok, i will.

@Jesus Bosch
Could you please try this method
* pause game when entering background
* resume it when back to foreground

I think it is result of remove re-loading textures codes.I found it when test my old game,so i am using version 2.1.2.

Minggo Zhang wrote:

I am sorry about that.
The reason i removed the codes for re-loading textures are
* it can save time back to foreground
* it can reduce memory usage
* the game named FishingJoy which has about 200 millions download also use this method as cocos2d-x did, and it haven’t received error report
>
Of course, i have to reproduce it first and resolve it if it causes problem.

@minggo we already do this on the app delegate, are you talking about something different?

// This function will be called when the app is inactive. When comes a phone call,it’s be invoked too
void AppDelegate::applicationDidEnterBackground() {
CCDirector::sharedDirector()->stopAnimation();
}

// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() {
CCDirector::sharedDirector()->startAnimation();
}