iOS Question Error loading many images

angel_

Well-Known Member
Licensed User
Longtime User
The error occurs when loading around 500 images in a large panel. The images have a resolution of 1024x1024 but I resize it to a smaller size maybe 50x50

B4X:
Dim Escala As Float = GetDeviceLayoutValues.NonnormalizedScale
img.Bitmap = xui.LoadBitmapResize(Path, Name, mWidth * Escala, mHeight * Escala, True)
img.Bitmap = xui.LoadBitmapResize(Path, Name, mWidth * Escala, mHeight * Escala, True)

I also tried this with the same error but I think the error occurs later:
B4X:
img.Bitmap = xui.LoadBitmapResize(Path, Name, mWidth, mHeight, True)

B4X:
Error occurred on line: 148 (clsMyApp)
Error loading image.
Stack Trace: (
  CoreFoundation       F3021642-E3C0-33F8-9911-DD303A6056D0 + 1157612
  libobjc.A.dylib      objc_exception_throw + 56
  CoreFoundation       F3021642-E3C0-33F8-9911-DD303A6056D0 + 120016
  MyApp            -[B4IBitmap innerInit::] + 372
  MyApp            -[B4IBitmap Initialize::] + 844
  MyApp            -[B4IBitmap InitializeResize:::::] + 140
  MyApp            -[B4ICommon LoadBitmapResize:::::] + 192
  MyApp            -[B4IXUI LoadBitmapResize:::::] + 136
  CoreFoundation       F3021642-E3C0-33F8-9911-DD303A6056D0 + 1175856
  CoreFoundation       F3021642-E3C0-33F8-9911-DD303A6056D0 + 8656
 MyApp            +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1608
 MyApp            -[B4IShell runMethod:] + 448
 MyApp            -[B4IShell raiseEventImpl:method:args::] + 1648
 MyApp            -[B4IShellBI raiseEvent:event:params:] + 1580
 MyApp            +[B4IDebug delegate:::] + 80
 MyApp            -[b4i_clsMyApp _crearview:] + 236
 MyApp            -[b4i_clsMyApp _agregar::::::::::] + 5164
 MyApp            -[b4i_m03_codigos _abrir:::::] + 11552
 MyApp            -[b4i_m03_codigos _zoom:] + 1296
 MyApp            -[b4i_m03_codigos _cargar::] + 2420
 MyApp            -[ResumableSub_b4xmainpage_AA_AbrirArchivo resume::] + 3536
 CoreFoundation       F3021642-E3C0-33F8-9911-DD303A6056D0 + 1175856
 CoreFoundation       F3021642-E3C0-33F8-9911-DD303A6056D0 + 8656
 MyApp            +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1608
 MyApp            -[B4IShell runMethod:] + 448
 MyApp            -[B4IShell raiseEventImpl:method:args::] + 2172
 MyApp            -[B4IShellBI raiseEvent:event:params:] + 1580
 MyApp            -[B4IDelegatableResumableSub resume::] + 380
 MyApp            -[B4I checkAndRunWaitForEvent:event:params:] + 516
 MyApp            -[B4IShellBI raiseEvent:event:params:] + 1436
 MyApp            __33-[B4I raiseUIEvent:event:params:]_block_invoke + 60
 libdispatch.dylib    AF27E74C-BE4A-3364-BB27-AED9916CE02D + 393880
 libdispatch.dylib    AF27E74C-BE4A-3364-BB27-AED9916CE02D + 397952
 libdispatch.dylib    AF27E74C-BE4A-3364-BB27-AED9916CE02D + 65628
 CoreFoundation       F3021642-E3C0-33F8-9911-DD303A6056D0 + 632288
 CoreFoundation       F3021642-E3C0-33F8-9911-DD303A6056D0 + 608904
 CoreFoundation       CFRunLoopRunSpecific + 572
 GraphicsServices     GSEventRunModal + 160
 

emexes

Expert
Licensed User
My first thought would be to "paste" the 50x50 thumbnail images into a single large image for display. Or perhaps into one large image per row of images.

I would expect that the Android composition flinger would handle 500 items no worries but on the other hand I've just had a massive wtf moment with Android's SQLLite cursor, so... who knows?!?! :rolleyes:

edit: would you believe that Android SQLite will let you write a say 3 MB photo to a database but not read it back? Sure hope that backup's still working.
 
Last edited:
Upvote 0

angel_

Well-Known Member
Licensed User
Longtime User
1. You can catch this error.
Sorry, I don't understand

2. Are you sure that there is no corrupt image file?
I have the same code and files on Android and it works


If I resize the image, no error appears, like this:
B4X:
img.Bitmap = xui.LoadBitmapResize(Path, Name, 0.1 * mWidth, 0.1 * mHeight, True)


But I I resize with:
B4X:
img.Bitmap = xui.LoadBitmapResize(Path, Name, 0.2 * mWidth, 0.2 * mHeight, True)
B4X:
Error occurred on line: 148 (clsMyApp)
Signal - 11
Stack Trace: (
    "0   MyApp             SignalHandler + 120",
    "1   libsystem_platform.dylib            0x00000001e1bb5d90 3A71914A-C2A7-3514-B519-DF319E7A6E02 + 28048",
    "2   CoreFoundation       F3021642-E3C0-33F8-9911-DD303A6056D0 + 352904",
    "3   CoreFoundation       CFWriteStreamCopyProperty + 148",
    "4   CoreFoundation       F3021642-E3C0-33F8-9911-DD303A6056D0 + 153412",
    "5   MyApp             -[B4IOutputStream ToBytesArray] + 72",
    "6   MyApp             -[B4IBit InputStreamToBytes:] + 208",
    "7   MyApp             -[B4IBitmap innerInit::] + 168",
    "8   MyApp             -[B4IBitmap Initialize::] + 844",
    "9   MyApp             -[B4IBitmap InitializeResize:::::] + 140"
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Try
 img.Bitmap = xui.LoadBitmapResize(Path, Name, 0.2 * mWidth, 0.2 * mHeight, True)
Catch
 Log("Failed to load image: " & LastException)
End Try

It is possible that you are running out of available memory. Don't load more images than are currently displayed.

You can load any number of images if you handle them correctly.
Two examples: https://www.b4x.com/android/forum/threads/b4x-bitmapsasync.119589/#content
 
Upvote 0

angel_

Well-Known Member
Licensed User
Longtime User
B4X:
Try
img.Bitmap = xui.LoadBitmapResize(Path, Name, 0.2 * mWidth, 0.2 * mHeight, True)
Catch
Log("Failed to load image: " & LastException)
End Try
This error appears:
B4X:
Time: 703
SignalHandler 11
Error occurred on line: 136 (clsMyApp)
Signal - 11
Stack Trace: (
    "0   MyApp             SignalHandler + 120",
    "1   libsystem_platform.dylib            0x00000001bcf569ec <redacted> + 40",
    "2   QuartzCore           <redacted> + 204",
    "3   QuartzCore           <redacted> + 204",
    "4   UIKitCore            <redacted> + 156",
    "5   UIKitCore            <redacted> + 800",
    "6   UIKitCore            <redacted> + 124",
    "7   UIKitCore            <redacted> + 44",
    "8   MyApp             -[B4IImageViewWrapper innerInitialize:::] + 116",
    "9   MyApp             -[B4IImageViewWrapper Initialize::] + 112"
)

It is possible that you are running out of available memory. Don't load more images than are currently displayed.
It is a panel that can be dragged (with the images inside), I don't know if it is possible

You can load any number of images if you handle them correctly.
Two examples: https://www.b4x.com/android/forum/threads/b4x-bitmapsasync.119589/#content
Thank you
 
Upvote 0
Top