ScrollView Speed

I’m just curious if this is just the way scrollview works or of it’s a corona limitation.

 

I’ve got a scrollview that I’m using as an image gallery, basically like the example in the corona business sample app .  Although I modified the sample app to put all the thumbnails inside a scrollview.  

 

I then added a button that loops through around 200 images and inserts those into scrollview.  All local images inside the resource directory.  When I hit the button to load the images into scrollview the app (or scrollview that is) just freezes and wont let me scroll until the images have all been loaded.  I have also done this with simple display.newRect’s and it has the same hitching/freezing

 

Can scrollview not scroll while objects are being placed inside it?  Is this a scrollview issue or is it something with how I’m coding?

 

Here’s the for loop I’m using to place images inside the scrollview:

for i = 1, #photoFiles do --[[this is the sample code for using newRect instead of memory heavy image photosThumbnails[i] = display.newRect( 0, 0, 80, 80 ) photosThumbnails[i].strokeWidth = 3 photosThumbnails[i]:setFillColor( 0.5 ) --]] photosThumbnails[i] = display.newImage(photoFiles[i]) local aspectRatio = photosThumbnails[i].width / photosThumbnails[i].height local scale if aspectRatio \> 1 then -- landscape photo scale = 80 / photosThumbnails[i].height else scale = 80 / photosThumbnails[i].width end photosThumbnails[i]:scale(scale,scale) photosThumbGroups[i] = display.newGroup() photosThumbnails[i].x = groupOffset --col \* 80 + 40 photosThumbnails[i].y = groupOffset --row \* 80 + 40 + 70 photosThumbGroups[i]:insert(photosThumbnails[i]) photosThumbGroups[i].x = col \* 80 + 40 photosThumbGroups[i].y = row \* 80 + 40 + 70 photosThumbGroups[i]:setMask(thumbnailMask) photosThumbGroups[i].maskX = groupOffset photosThumbGroups[i].maskY = groupOffset photosThumbGroups[i].index = i photosThumbGroups[i]:addEventListener("touch", showPhoto) col = col + 1 if col \> 3 then row = row + 1 col = 0 end scrollView:insert(photosThumbGroups[i])

Hi @InductiveIdeas,

This may be a simple limitation of loading a large batch of images (textures) into texture memory. How large are these files, both in file size and pixel dimensions?

Many developers use a more gradual method of loading images into a scrollView type element, only placing them into the element when they are (near) to moving on screen, and removing those which have moved sufficiently off screen.

Hope this helps,

Brent

Thanks for the quick response Brent.  

I’m using pretty small images for my test, the images are 100 wide by 100 or less tall (depending on aspect ratio).  I’ve also compressed them to where they are around 11kb or less.  

I don’t think its the loading of the texture memory because I’ve now tested with these tiny images and with the newRect’s instead of images (which I assume uses less memory than an image). 

Even if I were to load the images as they come and go from view, I’d still have this lag time when the new images are being placed into the scrollview.  The lag time seems to be based on the for loop placing the images.

Another example is if I fling the scrollview and let it scroll from momentum and then load more images as its moving it stops immediately until the new images are placed.  I can press other buttons and do other functions while the scrollview is still moving so I know the for loop and loading into scrollview lag are linked somehow.

Ah, I just did a bit more digging on the forum and found someone else posting about part of this bug:

http://forums.coronalabs.com/topic/53169-adding-objects-to-scrollview-while-its-decelerating-after-touch-event-bug/?hl=scrollview

The issue in that post is specifically about touch events though, I think their’s another problem with just loading into scrollview as well, not just on touch events.

It doesn’t look like anyone created a bug yet so I’m going to submit one now.

I’ve posted a bug about this:

Case 38480

Thank you for filing a bug report! I still have this issue.

Basically, if the scrollview is scrolling (with or without touch input) and you add an object to the scrollview, the momentum stops. If you aren’t touching, it comes to an abrupt stop, if you are touching and let go while flicking, it stops instead of scrolling. Kind of silly, especially since scrollviews could be expected to carry a lot of content.

Hi @InductiveIdeas,

This may be a simple limitation of loading a large batch of images (textures) into texture memory. How large are these files, both in file size and pixel dimensions?

Many developers use a more gradual method of loading images into a scrollView type element, only placing them into the element when they are (near) to moving on screen, and removing those which have moved sufficiently off screen.

Hope this helps,

Brent

Thanks for the quick response Brent.  

I’m using pretty small images for my test, the images are 100 wide by 100 or less tall (depending on aspect ratio).  I’ve also compressed them to where they are around 11kb or less.  

I don’t think its the loading of the texture memory because I’ve now tested with these tiny images and with the newRect’s instead of images (which I assume uses less memory than an image). 

Even if I were to load the images as they come and go from view, I’d still have this lag time when the new images are being placed into the scrollview.  The lag time seems to be based on the for loop placing the images.

Another example is if I fling the scrollview and let it scroll from momentum and then load more images as its moving it stops immediately until the new images are placed.  I can press other buttons and do other functions while the scrollview is still moving so I know the for loop and loading into scrollview lag are linked somehow.

Ah, I just did a bit more digging on the forum and found someone else posting about part of this bug:

http://forums.coronalabs.com/topic/53169-adding-objects-to-scrollview-while-its-decelerating-after-touch-event-bug/?hl=scrollview

The issue in that post is specifically about touch events though, I think their’s another problem with just loading into scrollview as well, not just on touch events.

It doesn’t look like anyone created a bug yet so I’m going to submit one now.

I’ve posted a bug about this:

Case 38480

Thank you for filing a bug report! I still have this issue.

Basically, if the scrollview is scrolling (with or without touch input) and you add an object to the scrollview, the momentum stops. If you aren’t touching, it comes to an abrupt stop, if you are touching and let go while flicking, it stops instead of scrolling. Kind of silly, especially since scrollviews could be expected to carry a lot of content.