display.capture is blank/white when returning from device sleep

On android 2.3, galaxy s, corona build 2013.1135

When you have a display.capture object on screen, then the device goes to suspend state… when returning from suspend state the display.capture object turns completely white.

Is there a fix or workaround for this? (besides disabling sleep/suspend)

Example code:

local myObject1 = display.newRect( 50, 50, 100, 150 ) myObject1:setFillColor(255, 0, 0); local function captureWithDelay() local capture = display.capture( myObject1 ) end timer.performWithDelay( 1500, captureWithDelay )

Why not save the capture to file right after it is called?  I’m guessing by not doing so the object is lost when the phone goes to sleep.

I’m going to try that next, it’s not a needed step for my purposes though.

I thought since it’s a display object it would/should behave like any other display object. Seems like a bug to me.

I submitted something similar to this as a bug quite a few builds ago.  http://forums.coronalabs.com/topic/16225-mail-on-android-attachment-not-ok/page-3

I never found out if the bug was fixed or not in my case…  it was on any Android device.  Apple devices did not have this issue.  So for me unfortunately i never got a work around in place.  i released my app for apple only.

I will bring it up on the newest daily build here and try and see if the same problem persists.  

Hi all,

I checked with the engineers on this, and I received the following summary:

Basically, when an Android app gets suspended, all OpenGL textures get dumped to clear memory for the next app’s textures. When an app gets resumed, all images and text have to get reloaded into OpenGL. This is a nuance of the Android operating system, not applicable to iOS.

Regarding your specific issue, if you do a “display.capture()”, your screenshot only exists in memory as a texture, which will be lost once you suspend the app. This means that there is no capture image file to load from when resuming your app. If you want your screen capture to “survive” a suspend/resume, you’ll need to use “display.save()” instead. This way, Corona has an image file to load from when resuming, thus recovering the captured image.

The advantage of the “display.capture()” API is that it’s faster than “display.save()” because it does not involve writing to file.  The capture is done completely in memory. The disadvantage is what I’ve noted up above: the capture image does not survive a suspend/resume. So, “display.capture()” is best used for short live capture image, such as for screen transition effect.

Hope this helps,

Brent

Why not save the capture to file right after it is called?  I’m guessing by not doing so the object is lost when the phone goes to sleep.

I’m going to try that next, it’s not a needed step for my purposes though.

I thought since it’s a display object it would/should behave like any other display object. Seems like a bug to me.

I submitted something similar to this as a bug quite a few builds ago.  http://forums.coronalabs.com/topic/16225-mail-on-android-attachment-not-ok/page-3

I never found out if the bug was fixed or not in my case…  it was on any Android device.  Apple devices did not have this issue.  So for me unfortunately i never got a work around in place.  i released my app for apple only.

I will bring it up on the newest daily build here and try and see if the same problem persists.  

Hi all,

I checked with the engineers on this, and I received the following summary:

Basically, when an Android app gets suspended, all OpenGL textures get dumped to clear memory for the next app’s textures. When an app gets resumed, all images and text have to get reloaded into OpenGL. This is a nuance of the Android operating system, not applicable to iOS.

Regarding your specific issue, if you do a “display.capture()”, your screenshot only exists in memory as a texture, which will be lost once you suspend the app. This means that there is no capture image file to load from when resuming your app. If you want your screen capture to “survive” a suspend/resume, you’ll need to use “display.save()” instead. This way, Corona has an image file to load from when resuming, thus recovering the captured image.

The advantage of the “display.capture()” API is that it’s faster than “display.save()” because it does not involve writing to file.  The capture is done completely in memory. The disadvantage is what I’ve noted up above: the capture image does not survive a suspend/resume. So, “display.capture()” is best used for short live capture image, such as for screen transition effect.

Hope this helps,

Brent

We are finding (using build 2187) that if we attempt to use display.save() when the app is getting suspended, the screen goes black (OpenGL context completely lost?) when the app resumes.  We’re surmising that capture.save() is taking too long and causing issues.

Has anyone found a clean solution for this or is using capture.save() working for other people here?

We are finding (using build 2187) that if we attempt to use display.save() when the app is getting suspended, the screen goes black (OpenGL context completely lost?) when the app resumes.  We’re surmising that capture.save() is taking too long and causing issues.

Has anyone found a clean solution for this or is using capture.save() working for other people here?