codenameone / CodenameOne

Cross-platform framework for building truly native mobile apps with Java or Kotlin. Write Once Run Anywhere support for iOS, Android, Desktop & Web.

Home Page:https://www.codenameone.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IOS resource exhaustion problem

ddyer0 opened this issue · comments

commented

The symptom is that the app crashes with no warning or useful debug info

I've only got this to occur on IOS, on physical devices, not on Android, Codename1 simulator, or Xcode simulator.
It appears to be some kind of resource exhaustion problem. The crash is SIGABRT at this line from GLUIImage.m,
where "imageData" appears to be null, which indicates that the "malloc" at the head of the method failed.

    CGContextTranslateCTM(context, 0, p2h);
    CGContextScaleCTM(context, 1, -1);
    CGColorSpaceRelease(colorSpace);
    CGContextClearRect(context, CGRectMake(0, 0, p2w, p2h));
    //CGContextSetRGBStrokeColor(context, 1, 0, 0, 1);
    //CGContextSetRGBFillColor(context, 0, 1, 0, 1);
    //CGContextFillRect(context, CGRectMake(0, p2h - h, w, h));
    //CGContextStrokeRect(context, CGRectMake(0, 0, w, p2h));
    CGContextDrawImage(context, CGRectMake(0, p2h - h, w, h), img.CGImage);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, p2w, p2h, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData);
    GLErrorLog;

I don't understand the immediate context - 'getTexture' shouldn't be involved in drawing my
images, so perhaps the whole environment is already corrupt in some way. I totally believe
that there's a resource exhaustion problem as the immediate cause of the crash. As a first step
I'd be very happy if there were a java-level exception instead of a hard crash.

2023-09-14 18:11:00.800368-0700 Develop[2046:146042] [Unknown process name] CGSImageDataLock: Cannot allocate memory
dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib:/Developer/Library/PrivateFrameworks/GPUTools.framework/libglInterpose.dylib:/usr/lib/libMTLCapture.dylib
(lldb)
(lldb) bt

  • thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001be05abbc libsystem_kernel.dylib__pthread_kill + 8 frame #1: 0x00000001de6c4844 libsystem_pthread.dylibpthread_kill + 208
    frame #2: 0x000000018eb9d6ac libsystem_c.dylibabort + 124 frame #3: 0x00000001c48735f0 libGFXShared.dylibgfxAllocateTextureLevel + 204
    frame #4: 0x00000001c47a0de4 GLEngine<redacted> + 1116 frame #5: 0x00000001079c48c4 libglInterpose.dylibtex_image2D(__GLIContextRec*, unsigned int, int, unsigned int, int, int, int, unsigned int, unsigned int, void const*) + 320
    frame #6: 0x00000001c485af14 OpenGLES`glTexImage2D + 80
    • frame #7: 0x0000000100d431d8 Develop-[GLUIImage getTexture:texHeight:](self=<unavailable>, _cmd=<unavailable>, texWidth=<unavailable>, texHeight=<unavailable>) at GLUIImage.m:107:9 frame #8: 0x00000001039086e4 Develop-[DrawImage execute](self=, _cmd=) at DrawImage.m:143:15
      frame #9: 0x0000000100a74ee0 Develop-[ExecutableOp executeWithClipping](self=<unavailable>, _cmd=<unavailable>) at ExecutableOp.m:60:5 frame #10: 0x0000000101ed092c Develop-[CodenameOne_GLViewController drawFrame:](self=, _cmd=, rect=(origin = (x = , y = ), size = (width = , height = ))) at CodenameOne_GLViewController.m:2714:17
      frame #11: 0x0000000101ed158c Develop__61-[CodenameOne_GLViewController flushBuffer:x:y:width:height:]_block_invoke(.block_descriptor=<unavailable>) at CodenameOne_GLViewController.m:2985:9 frame #12: 0x0000000107385fc8 libdispatch.dylib_dispatch_client_callout + 16
      frame #13: 0x00000001073958f0 libdispatch.dylib_dispatch_async_and_wait_invoke + 160 frame #14: 0x0000000107385fc8 libdispatch.dylibdispatch_client_callout + 16
      frame #15: 0x00000001073948ac libdispatch.dylib_dispatch_main_queue_drain + 928 frame #16: 0x00000001073944fc libdispatch.dylibdispatch_main_queue_callback_4CF + 40
      frame #17: 0x000000018446c014 CoreFoundation<redacted> + 12 frame #18: 0x00000001844294f8 CoreFoundation + 2544
      frame #19: 0x000000018443c174 CoreFoundationCFRunLoopRunSpecific + 572 frame #20: 0x00000001a4d77988 GraphicsServicesGSEventRunModal + 160
      frame #21: 0x0000000186c3ea88 UIKitCore<redacted> + 1080 frame #22: 0x00000001869d7f78 UIKitCoreUIApplicationMain + 336
      frame #23: 0x0000000102d9b478 Developcom_codename1_impl_ios_IOSNative_initVM__(threadStateData=<unavailable>, instanceObject=<unavailable>) at IOSNative.m:350:18 frame #24: 0x0000000101f9deac Developcom_codename1_impl_ios_IOSImplementation_postInit
      (threadStateData=, __cn1ThisObject=) at com_codename1_impl_ios_IOSImplementation.m:1023:5
      frame #25: 0x0000000101b5d1d8 Developvirtual_com_codename1_impl_CodenameOneImplementation_postInit__(threadStateData=<unavailable>, __cn1ThisObject=<unavailable>) at com_codename1_impl_CodenameOneImplementation.m:14527:5 frame #26: 0x00000001003c1fe8 Developcom_codename1_ui_Display_init___java_lang_Object(threadStateData=, __cn1Arg1=) at com_codename1_ui_Display.m:1277:5
      frame #27: 0x000000010230aa80 Developdev_boardspace_DevelopStub_main___java_lang_String_1ARRAY(threadStateData=<unavailable>, __cn1Arg1=<unavailable>) at dev_boardspace_DevelopStub.m:290:23 frame #28: 0x000000010230aae4 Developmain(argc=, argv=) at dev_boardspace_DevelopStub.m:299:5
      frame #29: 0x00000001071a84d0 dyld`start + 444
      (lldb)
commented

Irrespective of the larger question of why malloc fails, given that it does fail in this case, you
ought to throw some sort of java-level exception, rather than allow a SIGABORT to occur