简体   繁体   English

在drawAtPoint期间崩溃,代码在iPad Air,iPad模拟器上工作,在iPad 1和iPad mini上崩溃

[英]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. 我有一些代码试图将png渲染到图形上下文。 The code works fine in all simulators, and works fine on an iPad Air. 该代码在所有模拟器中均能正常运行,在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: 但是,当我在iPad mini或iPad上运行它时,在连接到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. 它在调用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? 单步执行代码时,所有计算值都与在xCode模拟器中运行时相同,UIImage不为null,等等。这是由于处理能力有限还是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. 我将其降低了4倍,现在可以使用了。 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. 如果有人知道如何配置模拟器以模拟iPad 1或mini的存储容量,我将不胜感激。 I'd like to be able to debug/test in the simulator as much as possible! 我希望能够在模拟器中进行尽可能多的调试/测试!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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