简体   繁体   中英

Crash during drawAtPoint, code works on iPad Air, iPad simulator, crashes on iPad 1 and iPad mini

I have some code that's trying to render a png to a graphics context. The code works fine in all simulators, and works fine on an iPad Air. But when I run it on an iPad mini or an iPad one, I see the following crash when running it while hooked up to xCode:

ImageIO`ImageIO_ABGR_TO_ARGB_8Bit: 0x36f27c70: push {r4, r5, r6, r7, lr} 0x36f27c72: add r7, sp, #0xc 0x36f27c74: push.w {r8, r10, r11} 0x36f27c78: ldr r1, [r0] 0x36f27c7a: ldr r2, [r0, #0xc] 0x36f27c7c: cmp.w r2, r1, lsl #2 0x36f27c80: blo 0x36f27d06 ; ImageIO_ABGR_TO_ARGB_8Bit + 150 0x36f27c82: ldr r3, [r0, #0x18] 0x36f27c84: lsls r2, r1, #0x2 0x36f27c86: cmp r3, r2 0x36f27c88: blo 0x36f27d06 ; ImageIO_ABGR_TO_ARGB_8Bit + 150 0x36f27c8a: ldr r2, [r0, #0x4] 0x36f27c8c: cmp r2, #0x0 0x36f27c8e: beq 0x36f27d06 ; ImageIO_ABGR_TO_ARGB_8Bit + 150 0x36f27c90: bic lr, r1, #0x7 0x36f27c94: ldr r3, [r0, #0x8] 0x36f27c96: ldr.w r12, [r0, #20] 0x36f27c9a: sub.w r4, r1, lr 0x36f27c9e: asrs r5, r1, #0x3 0x36f27ca0: mov r6, r12 0x36f27ca2: mov r8, r3 0x36f27ca4: cbz r5, 0x36f27cbe ; ImageIO_ABGR_TO_ARGB_8Bit + 78 0x36f27ca6: mov r8, r3 0x36f27ca8: mov r9, r5 0x36f27caa: mov r6, r12 0x36f27cac: vld4.8 {d0, d1, d2, d3}, [r8]! 0x36f27cb0: vswp d0, d2 0x36f27cb4: vst4.8 {d0, d1, d2, d3}, [r6]! <<--- crash on this line 0x36f27cb8: subs.w r9, r9, #0x1

Here is the code that generates the crash:

NSString* imgFile = @"ShotZones.png";
UIImage* img = [UIImage imageNamed:imgFile];
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
float scaleShotZoneFeetToPixels = img.size.width / shotZoneCourtSizeInFeet.x;
CGRect courtRect = {{0, 0}, img.size};
CGFloat scaleFactor = screenWidth / courtRect.size.width;
UIGraphicsBeginImageContext(img.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextScaleCTM(context, scaleFactor, scaleFactor);
[img drawAtPoint: courtRect.origin];

It crashes (in a separate thread), on the call to drawAtPoint. When stepping through the code, all the computed values are the same as when running in the xCode simulator, the UIImage is not null, etc. Is this due to limited processing power or limited memory on the iPad? Any thoughts as to how to fix?

Thanks!

  • Dave

Ok, I got it to work. It was the resolution of the image. I decreased it by a factor of 4 and now it works. I assume the device ran out of memory. If anyone knows how to configure the simulator to simulate the memory capacity of an iPad 1 or mini, I'd appreciate it. I'd like to be able to debug/test in the simulator as much as possible!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM