Bug? [SOLVED - NOT A BUG!] xCustomListView bug exposed when using large numbers of panels?

Andris

Active Member
Licensed User
Longtime User
I have a B4i project that uses xCustomListView and was certain it was working great ... except for occasional weird crashes. I've finally figured out that it's related to the number of panels that I add to clvFolder, an xCustomListView object. With large numbers of panels, the app crashes after loading clvFolder a few times. This happens even though I make sure clvFolder is redimensioned and cleared. With 100 panels, a crash occurs after 9 loadings of clvFolder; with 200 panels, after 5 loadings; with 500, after 2 loadings. Most times, I would only load 10-20 panels and the problem wouldn't show up, but I suspect that it would after 50-100 iterations of loading. So at this point it feels like some kind of memory allocation problem - maybe a bug, unless it's something in my code?

I've put together an app which simulates the problem and have attached it below. To install and run it yourself, you'll have to change the package name in Build Configurations so that you can use the hosted builder. Many thanks in advance if you decide to take a look at it. This has been driving me crazy for a few days now :mad:.
 

Attachments

  • xclvbug.zip
    83.6 KB · Views: 272

Andris

Active Member
Licensed User
Longtime User
First step is to load the images once and reuse them.
I've commented the code that loads the images and tested it in release mode. It didn't crash with lists of several thousands of items.

If you need to work with large lists then you should use lazy loading and reuse the layouts.
Thanks Erel! Great news.
 
Last edited:

Andris

Active Member
Licensed User
Longtime User
First step is to load the images once and reuse them.
I've commented the code that loads the images and tested it in release mode. It didn't crash with lists of several thousands of items.

If you need to work with large lists then you should use lazy loading and reuse the layouts.

Update: I intend to rewrite with lazy loading. However, just to duplicate what you did, I commented out the following four image load lines:
B4X:
    Select Case vwtype 
        Case "chk"
'            imgoff.Bitmap=LoadBitmap(File.DirAssets,"chk_off(half).png")
'            imgon.Bitmap=LoadBitmap(File.DirAssets,"chk_on_yel(half).png")
        Case "rb"
'            imgoff.Bitmap=LoadBitmap(File.DirAssets,"rb_off(half).png")
'            imgon.Bitmap=LoadBitmap(File.DirAssets,"rb_on_yel(half).png")
        Case Else
    End Select

The result is that with 1000 panels, the app still crashes, on the third time that I tap Show CLV. You say yours didn't crash with thousands of items. I wonder what the difference is? Perhaps because of the iPhone 6?
 

Andris

Active Member
Licensed User
Longtime User
Have you tested it in release mode?
Yes, absolutely.
However, I just noticed that there is an additional image load that I didn't comment out:
B4X:
     img.ContentMode=img.MODE_FILL
'    img.Bitmap=LoadBitmap(File.DirAssets, "expansionfolder_fwd_wht_half.png")
After commenting this 5th line, I get no crashes, even with thousands!

Thanks for all your help Erel. Now that I realize that the image loading took such a toll with resources and have studied up on lazy loading, I'm ready to rewrite in the correct way. :)
 
Top