Is there a limit to the number of pictures that can be displayed on the iPad at one time?

I’m building a childrens picture book that has 43 pages, (one picture for the left page and one for the right page). It runs fine in the simulator but when I build it for the iPad it doesn’t. If I remove several pages from the main.lua code (they are still included in the build) and build it with the code loading 23 of the pages it runs fine on the iPad. If I add one more page in the code it loads but when you try to “turn” a page it crashes. It doesn’t run at all with 24 pages. I tried saving the pictures at a lower resolution with the exact same results. The size of the build is 9.8mb. This size remains the same whether I include the files in the main.lua code or not. Is there a limit to the number of pictures that can be displayed on the iPad at one time? Is this a restriction of corona or the iPad itself? [import]uid: 6397 topic_id: 1279 reply_id: 301279[/import]

I’m a little confused on how your app works. Are you trying to load all the pages at once, right when the app starts up? If so, that’s probably not the best way to do it. You need to conserve memory. I would just load the page you’re on and maybe the next page and previous page. And then make sure you get pages that aren’t next/current/previous out of memory when they aren’t being used. But I couldn’t really get how you were doing it out of your post so I might have misunderstood. [import]uid: 6678 topic_id: 1279 reply_id: 3452[/import]

Well… this may be related:

http://developer.anscamobile.com/forum/2010/06/18/memory-management-displaynewimage-broken

And still no answer from the devs about that topic.

If there is really a bug (or design flaw) you will not be able to do what you want to do there till this gets fixed… [import]uid: 6928 topic_id: 1279 reply_id: 3457[/import]

I’ve forwarded this long to the right dev to take a look at. [import]uid: 3 topic_id: 1279 reply_id: 3459[/import]

I am loading all the images at startup but I don’t think it’s a memory issue. The app is a little over 9mb in size using the higher compression (smaller file size) jpeg images. Also it didn’t make any difference using the lower compression (larger file size by almost 2x) jpeg images, the app still fails after 23 images. I looked at the link that OderWat posted and although I don’t completely understand it, it seems to me he is loading a lot more images than I am before he has a problem. [import]uid: 6397 topic_id: 1279 reply_id: 3462[/import]

Your compression level of the images does not matter… they get decoded and stored in texture memory using the same amount of ram…

My little experiment crashes after about ~30 images on the iPhone where the images get scaled to screen resolution automatically by Corona. So it is comparable to your case.

Do you have a chance to test it with “Instruments” and check out the console log?

In my test it works on the iPad… (asking you to test it on another device was stupid… lol)

May you try the code I posted in the Bug Section on your device?

If my code runs … and your app not… you may have some other problem (like not freeing references to the images).

BTW: I too do not really understand how you “load” the pictures. It sounds as if you encode them into lua files which would be … strange :slight_smile: [import]uid: 6928 topic_id: 1279 reply_id: 3464[/import]

It sounds like @tarenberg is loading images that display the left and right pages of a book and it crashes after 23 images. It would be nice to see some code on how the images are being managed (loading/unloading). Are the image objects removed or just made invisible? The fact that it fails on the iPad suggests that it may be a different problem than what @OderWat found.

I’m assuming when you say that it fails after 23 images you mean when you try to display the 23rd image. Have you tried removing references to the previous images so you only have the previous page, current page, and next pages images loaded?

Tom [import]uid: 6119 topic_id: 1279 reply_id: 3467[/import]

@tarenberg If you are trying to preload all 43 images at startup, then the iPhone will crash your app b/c of the long startup time. You’ll also hit a texture memory limit b/c the uncompressed memory is what matters.

I would recommend following @fogview’s suggestion. Minimize the working set of images. It doesn’t have to be as little as 3 like he suggests, but it certainly can’t be 43.

As noted on the thread @oderwat points to, we are investigating some longer-term solutions to make this less of a manual process. [import]uid: 26 topic_id: 1279 reply_id: 3472[/import]

Thanks to everyone for all the help on this project!

I am loading images that display left and right pages. Originally I was loading all the images into 2 arrays, oddPages and evenPages. Even pages were placed at the right side of the display using the top/left reference point, with their xscale set to 0.0001. Odd pages were stacked on top of each other. This way when I “turn the page” the next odd page is already displayed below.

Now I’m placing the images on the display as needed ie: page 2 on the left side of the display and page 3 on the right (page 1 is the book cover). When Pages 2 and 3 are showing I display pages 5 and 6.

Right now my problem is when I display pages 5 and 6, page 5 is displayed on top of page 3 (because it is displayed after page 3). Is there any way to move page 5 onto the display below page 3?

What I’m trying to say is page 5 shows before page 3 has been turned.

I hope this makes some sense to somebody :-b

Here is the code snippet:

[code]
local page = 1

– Next Page -----------------------------------------------------------------------------
function nextPage()
media.playEventSound( pgTurn ) – Sound of page turning
transition.to( image[page + 1], { xScale=1, x=0, time=turnSpeed } ) – Even page
transition.to( image[page], { xScale=0, x=halfW, time=turnSpeed } ) – Odd page
–transition.to( image[page], { x=0, time=turnSpeed, delay=500} ) – Odd page

if ( page ~= ttlPgs ) the – If page is not last page
page = page + 2

– Add next odd page
image[page] = display.newImage(pages[page], halfW, 0) – Display Odd page
image[page]:setReferencePoint(display.TopLeftReferencePoint) – Use the top left reference

– Add next even page
image[page + 1] = display.newImage(pages[page + 1], fullW, 0) – Display Even page
image[page + 1]:setReferencePoint(display.TopLeftReferencePoint)-- Use the top left reference
image[page + 1].xScale = 0.00001 – Set the width to 0

local s=display:getCurrentStage()
s:remove(image[page - 4])
image[page - 4] = nil
s:remove(image[page - 5])
image[page - 5] = nil
end
end
[/code] [import]uid: 6397 topic_id: 1279 reply_id: 3496[/import]

Seeing your code I think it could very much relate to my bug report (which does not happen in real world applications as I just learned!)

http://developer.anscamobile.com/forum/2010/06/18/memory-management-displaynewimage-broken

Good luck … :frowning:

“As noted on the thread @oderwat points to, we are investigating some longer-term solutions to make this less of a manual process.” … Still nobody from the Corona team could show me the “manual” process… [import]uid: 6928 topic_id: 1279 reply_id: 3513[/import]

I’ve resolved my display issue by putting the odd pages in a group. I’m able to control the display order that way. Removing the previous 2 images that make up a display view and loading the next 2 images while current images are being displayed has resolved my memory issue with no noticeable difference to the page flip animation, ie: while pages 5 & 6 are displayed, 3 & 4 are removed and 7 & 8 are loaded.

Thank you everyone for you help. [import]uid: 6397 topic_id: 1279 reply_id: 3517[/import]

Gratz… Glad it worked out for you!

Would you be so kind and elaborate on the change?

The last source you send does load (and view) images 3&4 and remove 1&2 at once, right?

How do you preload 7 & 8 while do you still show 5 & 6 ?

Do you remove them directly from the Stage after you issue the “newImage()” [import]uid: 6928 topic_id: 1279 reply_id: 3518[/import]

Sorry I didn’t get back to you sooner, have been on vacation and decided to leave all my electronics at home. A truly relaxing vacation, (the wife heartily approved).

Here’s the final source code for the forward page flip routine. Still have to do the reverse page flip.

– Page Flip Functions -------------------------------------------------------------------
local page = 1

– Next Page -----------------------------------------------------------------------------
function nextPage()
if ( page < ttlPgs - 1) then – If page is not last page
media.playSound( pgTurn ) – Sound of page turning
transition.to( image[page + 1], { xScale=1, x=0, time=turnSpeed } ) – Even page
transition.to( image[page], { xScale=0, x=halfW, time=turnSpeed } ) – Odd page
transition.to( image[page], { x=-10, time=turnSpeed, delay=500} ) – Odd page

page = page + 2
– Check for interaction buttons

– Add next odd page
image[page] = display.newImage(pages[page], halfW, 0) – Display Odd page
image[page]:setReferencePoint(display.TopLeftReferencePoint) – Use the top left reference
oddPgs:insert( 1, image[page] )

– Add next even page
image[page + 1] = display.newImage(pages[page + 1], fullW, 0) – Display Even page
image[page + 1]:setReferencePoint(display.TopLeftReferencePoint) – Use the top left reference for positioning
image[page + 1].xScale = 0.00001 – Set the width to 0

local s=display:getCurrentStage()
s:remove(image[page - 4])
image[page - 4] = nil
s:remove(image[page - 5])
image[page - 5] = nil
end
end

[import]uid: 6397 topic_id: 1279 reply_id: 3751[/import]

Just to let you know that you can use the “code” tags to format your code in this forum. Add “code” and “/code” before and after your code block (substitute “” for the quotes).

-Tom [import]uid: 6119 topic_id: 1279 reply_id: 3756[/import]

Oops! Was rushing to get my reply out and forgot the code tags. Here’s the code again properly formatted:

[code]
– Page Flip Functions -------------------------------------------------------------------
local page = 1

– Next Page -----------------------------------------------------------------------------
function nextPage()
if ( page < ttlPgs - 1) then – If page is not last page
media.playSound( pgTurn ) – Sound of page turning
transition.to( image[page + 1], { xScale=1, x=0, time=turnSpeed } ) – Even page
transition.to( image[page], { xScale=0, x=halfW, time=turnSpeed } ) – Odd page
transition.to( image[page], { x=-10, time=turnSpeed, delay=500} ) – Odd page

page = page + 2
– Check for interaction buttons

– Add next odd page
image[page] = display.newImage(pages[page], halfW, 0) – Display Odd page
image[page]:setReferencePoint(display.TopLeftReferencePoint) – Use the top left reference
oddPgs:insert( 1, image[page] )

– Add next even page
image[page + 1] = display.newImage(pages[page + 1], fullW, 0) – Display Even page
image[page + 1]:setReferencePoint(display.TopLeftReferencePoint) – Use the top left reference for positioning
image[page + 1].xScale = 0.00001 – Set the width to 0

local s=display:getCurrentStage()
s:remove(image[page - 4])
image[page - 4] = nil
s:remove(image[page - 5])
image[page - 5] = nil
end
end
[/code] [import]uid: 6397 topic_id: 1279 reply_id: 3758[/import]