display.save stutter or lag

Hi,

I am thinking about taking screenshots of key gameplay moments to allow the user to post on social media. I have noticed that when I use display.save there is a noticeable stutter in gameplay. I thought about using display.capture and storing in a variable but think that having 4 or 5 full screen images on the go might eat into texture memory (I want to give the user choice at the end of the level).

Has anyone else faced this issue? Do I have any other options?

Craig

Hi Craig,

I doubt that keeping 4-5 screenshots in memory (display.capture()) would have any significant negative impact (i.e. blow your texture memory out of reasonable bounds). If you got up to like 10, 20, or more, then it might, but a reasonable amount (under 10) should be fine.

Brent

Thanks Brent,

Is there any way of checking if this could become an issue, I would hate to crash app because of to much texture memory being used.

Would be good to be able to check in app and purge if required.

Thanks

Hi Craig,

Yes, you can check it using this API:

https://docs.coronalabs.com/api/library/system/getInfo.html#texturememoryused

However, there’s no really accurate way of telling what the “limit” is per device/GPU. I guess you could make a reasonable estimate based on your “lowest reasonable device” and then purge saved screenshots if it goes above that.

Brent

Just to add to what Brett said, I would definitely add in the low memory event and use that to purge texture memory

function memoryWarning(event) collectgarbage() -- REMOVE SCREENSHOTS from emory return true end Runtime:addEventListener( "memoryWarning", memoryWarning)

Thanks Guys,

I will give this a try.

Craig

Hey Guys,

I am still working at this and am not 100% happy with this.  

On my Samsung S7 each screen capture takes 15Mb (approx) of texture memory, I am not sure what the limit is, but this goes up pretty fast.

Is there any way of reducing the quality of these textures in memory, so that they dont take up as much memory? 

Thanks,

Craig

Hi Craig,

I doubt that keeping 4-5 screenshots in memory (display.capture()) would have any significant negative impact (i.e. blow your texture memory out of reasonable bounds). If you got up to like 10, 20, or more, then it might, but a reasonable amount (under 10) should be fine.

Brent

Thanks Brent,

Is there any way of checking if this could become an issue, I would hate to crash app because of to much texture memory being used.

Would be good to be able to check in app and purge if required.

Thanks

Hi Craig,

Yes, you can check it using this API:

https://docs.coronalabs.com/api/library/system/getInfo.html#texturememoryused

However, there’s no really accurate way of telling what the “limit” is per device/GPU. I guess you could make a reasonable estimate based on your “lowest reasonable device” and then purge saved screenshots if it goes above that.

Brent

Just to add to what Brett said, I would definitely add in the low memory event and use that to purge texture memory

function memoryWarning(event) collectgarbage() -- REMOVE SCREENSHOTS from emory return true end Runtime:addEventListener( "memoryWarning", memoryWarning)

Thanks Guys,

I will give this a try.

Craig

Hey Guys,

I am still working at this and am not 100% happy with this.  

On my Samsung S7 each screen capture takes 15Mb (approx) of texture memory, I am not sure what the limit is, but this goes up pretty fast.

Is there any way of reducing the quality of these textures in memory, so that they dont take up as much memory? 

Thanks,

Craig