I have an app that displays a UIImage in a UIImageView in a UIScrollView in a UITableViewCell. I update the image using Quartz to draw a line, a circle or square and some text.
What I'm experiencing is very random crashes on the device that according to the crash log occurs in QuartzCore. I can't reproduce the crashes on the simulator.
I've checked a lot of examples and I think I am doing this correctly (but probably not or I wouldn't have the crashes).
The drawing occurs in the main thread. I create the CG Context with:
Then I finish up with
Here's the crash log
What I'm experiencing is very random crashes on the device that according to the crash log occurs in QuartzCore. I can't reproduce the crashes on the simulator.
I've checked a lot of examples and I think I am doing this correctly (but probably not or I wouldn't have the crashes).
The drawing occurs in the main thread. I create the CG Context with:
Code:
UIGraphicsBeginImageContext(myImageView.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
// draw a circle
CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 1.0);
CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 1.0);
CGContextFillEllipseInRect(context, CGRectMake(col1-wAdj, row1-hAdj, kTinyPointDotSize, kTinyPointDotSize));
// drawing a label
CGContextSetRGBStrokeColor(context, red, green, blue, 1.0);
CGContextSetRGBFillColor(context, red, green, blue, 1.0);
CGContextSetLineWidth(context, 1.0);
[commonName drawAtPoint:CGPointMake(lblCol, lblRow) withFont:[UIFont fontWithName:@"Helvetica-Bold" size:12.0]];
CGPoint s = CGPointMake(col1, row1);
CGPoint e = CGPointMake(lblCol+lblColAdj, lblRow+10);
CGContextMoveToPoint(context, s.x, s.y);
CGContextAddLineToPoint(context, e.x, e.y);
CGContextStrokePath(context);
Then I finish up with
Code:
myImageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Here's the crash log
Code:
Incident Identifier: 67518862-9F63-4813-829C-A22D8F4305FC
CrashReporter Key: c9c3f3ea41d4ce68c2386f5d6a8826a09205fc70
Process: TcmAid [176]
Path: /var/mobile/Applications/5164034F-14F1-416C-AD6A-862EF7FD085E/TcmAid.app/TcmAid
Identifier: TcmAid
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2009-12-24 08:58:46.773 -0800
OS Version: iPhone OS 3.1.2 (7D11)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000a
Crashed Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x00003ebc objc_msgSend + 20
1 CoreFoundation 0x00059e82 CFGetRetainCount + 118
2 QuartzCore 0x0000b700 CA::release_root_if_unused(_CALayer*, _CALayer*, void*) + 8
3 QuartzCore 0x0000b670 x_hash_table_remove_if + 76
4 QuartzCore 0x0000b410 CA::Transaction::commit() + 184
5 QuartzCore 0x000135d4 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 84
6 CoreFoundation 0x0000f82a __CFRunLoopDoObservers + 466
7 CoreFoundation 0x00057340 CFRunLoopRunSpecific + 1812
8 CoreFoundation 0x00056c18 CFRunLoopRunInMode + 44
9 GraphicsServices 0x0000436c GSEventRunModal + 188
10 UIKit 0x00003c28 -[UIApplication _run] + 552
11 UIKit 0x00002228 UIApplicationMain + 960
12 TcmAid 0x00002c3a main (main.m:24)
13 TcmAid 0x00002bac start + 44
Thread 1:
0 libSystem.B.dylib 0x000014b8 mach_msg_trap + 20
1 libSystem.B.dylib 0x00004094 mach_msg + 60
2 CoreFoundation 0x00057002 CFRunLoopRunSpecific + 982
3 CoreFoundation 0x00056c18 CFRunLoopRunInMode + 44
4 WebCore 0x000846f0 RunWebThread(void*) + 412
5 libSystem.B.dylib 0x0002b7b0 _pthread_body + 20
Thread 2:
0 libSystem.B.dylib 0x000014b8 mach_msg_trap + 20
1 libSystem.B.dylib 0x00004094 mach_msg + 60
2 CoreFoundation 0x00057002 CFRunLoopRunSpecific + 982
3 CoreFoundation 0x00056c18 CFRunLoopRunInMode + 44
4 Foundation 0x0005a998 +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 172
5 Foundation 0x00053ac6 -[NSThread main] + 42
6 Foundation 0x00001d0e __NSThread__main__ + 852
7 libSystem.B.dylib 0x0002b7b0 _pthread_body + 20
Thread 0 crashed with ARM Thread State:
r0: 0x003ab080 r1: 0x31973544 r2: 0x00818a00 r3: 0x32668ea8
r4: 0x00000002 r5: 0x384201b0 r6: 0x002f1ca0 r7: 0x2ffff1d4
r8: 0x00818a00 r9: 0x000eb195 r10: 0x33e866f8 r11: 0x0000000d
ip: 0x385b72b8 sp: 0x2ffff1bc lr: 0x32da6e89 pc: 0x32668ebc
cpsr: 0x000f0010
Binary Images:
0x1000 - 0x15afff +TcmAid armv6 <f88ba058f46c2da943b7adf1d57037a7> /var/mobile/Applications/5164034F-14F1-416C-AD6A-862EF7FD085E/TcmAid.app/TcmAid
0x26e000 - 0x26ffff +libremoteoainject.dylib armv6 <8dd8b62ea097c801af829010772f9658> /Developer/Library/PrivateFrameworks/DTInstrumentsServer.framework/libremoteoainject.dylib
0x2e3000 - 0x2e4fff dns.so armv6 <957f94410f77a351749ac39d2b4b4abe> /usr/lib/info/dns.so
0x2fe00000 - 0x2fe26fff dyld armv6 <c6ca391c0094661f9a5ae82920fb6afb> /usr/lib/dyld
0x301a0000 - 0x301a6fff MBX2D armv6 <ab6868f9679e912165063f2229b26b64> /System/Library/PrivateFrameworks/MBX2D.framework/MBX2D
0x301c4000 - 0x3037efff CoreGraphics armv6 <724ca87c683dfc06a7b8de93ad7529ab> /System/Library/Frameworks/CoreGraphics.framework/CoreGraphics
0x303ce000 - 0x3047bfff WebKit armv6 <0c25498f719543dfe237b3d5ad2b41f4> /System/Library/PrivateFrameworks/WebKit.framework/WebKit
0x3058b000 - 0x305bffff Security armv6 <9b4c89ffb90e39d912571072fc4571db> /System/Library/Frameworks/Security.framework/Security
0x305c2000 - 0x305c3fff IOMobileFramebuffer armv6 <410c46b0db15595f49443de4b0f96bc1> /System/Library/PrivateFrameworks/IOMobileFramebuffer.framework/IOMobileFramebuffer
0x30a03000 - 0x30a0dfff libkxld.dylib armv6 <d66542fdb9913ce038758d76d3d0c3f0> /usr/lib/system/libkxld.dylib
0x30a53000 - 0x30a54fff CoreSurface armv6 <b9adb2b0f4bed29f5256929a4aac6144> /System/Library/PrivateFrameworks/CoreSurface.framework/CoreSurface
0x30ab3000 - 0x30ae7fff SystemConfiguration armv6 <dabbf79e438842248b8d8f572c3654b6> /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration
0x30afe000 - 0x30b0cfff libz.1.dylib armv6 <fe7af855ed11fa43582ae7320ea4b679> /usr/lib/libz.1.dylib
0x30bf0000 - 0x319e1fff UIKit armv6 <02702efa29385ec77b4fad6771ea9fea> /System/Library/Frameworks/UIKit.framework/UIKit
0x31bb5000 - 0x31bc0fff GraphicsServices armv6 <c3aca9de10fd0878505c53bef91702ab> /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices
0x31bd3000 - 0x31cc9fff libxml2.2.dylib armv6 <0c9d767c5ea2052102d5364b731774a4> /usr/lib/libxml2.2.dylib
0x31d68000 - 0x31e69fff libicucore.A.dylib armv6 <48d461b0b7e4c3c34fdd8906e43a9c48> /usr/lib/libicucore.A.dylib
0x31f05000 - 0x31f72fff CFNetwork armv6 <0c45ba25308645c6e0e6a0934c8ecc98> /System/Library/Frameworks/CFNetwork.framework/CFNetwork
0x31fbb000 - 0x3210ffff AudioToolbox armv6 <449419ad6f59bbfef367d329152d8466> /System/Library/Frameworks/AudioToolbox.framework/AudioToolbox
0x321cd000 - 0x32228fff CoreAudio armv6 <cd08933a4f7fdab879f5a9a2a0ad2bab> /System/Library/Frameworks/CoreAudio.framework/CoreAudio
0x32285000 - 0x322dffff libsqlite3.dylib armv6 <d0b78bf167d303cb11c7351784af7be9> /usr/lib/libsqlite3.dylib
0x324ab000 - 0x324e5fff libvDSP.dylib armv6 <cf9cc6079374718dce29cba9de48b993> /System/Library/PrivateFrameworks/Accelerate.framework/Frameworks/vecLib.framework/libvDSP.dylib
0x32665000 - 0x32708fff libobjc.A.dylib armv6 <70da12c30a834268531d6fc845833f9b> /usr/lib/libobjc.A.dylib
0x3272d000 - 0x32853fff libSystem.B.dylib armv6 <b9a8f3b6eff2d3bd2b8bce13e6559dcb> /usr/lib/libSystem.B.dylib
0x32990000 - 0x329aefff libresolv.9.dylib armv6 <be380b5054e27754c41ae8a33bae3f57> /usr/lib/libresolv.9.dylib
0x32afa000 - 0x32b1dfff libRIP.A.dylib armv6 <e14d5666f3f164e734735a718c710dd7> /System/Library/Frameworks/CoreGraphics.framework/Resources/libRIP.A.dylib
0x32b3e000 - 0x32b8bfff IOKit armv6 <0c1722088423026dbc67adb8a83c4b8b> /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
0x32d4d000 - 0x32df9fff CoreFoundation armv6 <bb0a4b864e5807d2d0fb3211b9633603> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
0x32e15000 - 0x32e25fff libbsm.0.dylib armv6 <050c16b1a6ea7e4e3c80556a2f9c746e> /usr/lib/libbsm.0.dylib
0x32e2f000 - 0x32e56fff AppSupport armv6 <5c2d41e8c22380b938e7a3194adff14e> /System/Library/PrivateFrameworks/AppSupport.framework/AppSupport
0x32e85000 - 0x32e91fff CoreVideo armv6 <5ff949c6e178ed567a3516fec7a336fb> /System/Library/PrivateFrameworks/CoreVideo.framework/CoreVideo
0x32ebd000 - 0x32ec3fff StoreKit armv6 <43b24892c90b39fbf4cd59a8e9eafdb8> /System/Library/Frameworks/StoreKit.framework/StoreKit
0x32ec4000 - 0x33617fff WebCore armv6 <7621be5a489bafd9129ec542ee5faf6a> /System/Library/PrivateFrameworks/WebCore.framework/WebCore
0x3384b000 - 0x33855fff MobileCoreServices armv6 <976de01a455ee09d192898dc306043e2> /System/Library/Frameworks/MobileCoreServices.framework/MobileCoreServices
0x33856000 - 0x3385ffff SpringBoardServices armv6 <ee6107a837d8ef6fcd012522ba03fa6f> /System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices
0x33860000 - 0x338cafff libstdc++.6.dylib armv6 <3fa3413ae26f5e206c8a2ee46fb04bfb> /usr/lib/libstdc++.6.dylib
0x33924000 - 0x3395efff CoreTelephony armv6 <c6fff6661b9edb14db12c52525e3bb51> /System/Library/PrivateFrameworks/CoreTelephony.framework/CoreTelephony
0x3395f000 - 0x33963fff IOSurface armv6 <5eb19b9643e17c51321283ba4a598d22> /System/Library/PrivateFrameworks/IOSurface.framework/IOSurface
0x33be6000 - 0x33ce3fff JavaScriptCore armv6 <b075dbc5464fe7a390977b818b9e20e5> /System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore
0x33cf0000 - 0x33cf0fff vecLib armv6 <c8a08b45effd5eb35a476a969628e52d> /System/Library/PrivateFrameworks/Accelerate.framework/Frameworks/vecLib.framework/vecLib
0x33d02000 - 0x33d02fff Accelerate armv6 <21e1dc9fad96f0d51afbeb7f7e006aaf> /System/Library/PrivateFrameworks/Accelerate.framework/Accelerate
0x33e57000 - 0x33e75fff AddressBook armv6 <314d6d5c19d8a41144176a9772aeeb8e> /System/Library/Frameworks/AddressBook.framework/AddressBook
0x33e7b000 - 0x33f25fff QuartzCore armv6 <ed15a92103e0e93ff9be1ae6422945d5> /System/Library/Frameworks/QuartzCore.framework/QuartzCore
0x33f29000 - 0x34021fff Foundation armv6 <666e9e488f83b9e196aa70a6b44fdc93> /System/Library/Frameworks/Foundation.framework/Foundation
0x34041000 - 0x34058fff OpenGLES armv6 <0c5c914ead991e607b89d480e4215fe8> /System/Library/Frameworks/OpenGLES.framework/OpenGLES
0x34059000 - 0x34106fff ImageIO armv6 <e89e18aafd3192967ec92cced4d9565c> /System/Library/PrivateFrameworks/ImageIO.framework/ImageIO
0x34112000 - 0x3414ffff libCGFreetype.A.dylib armv6 <50e793fc4b4de6b598be29d591a31f0d> /System/Library/Frameworks/CoreGraphics.framework/Resources/libCGFreetype.A.dylib
0x342f9000 - 0x34337fff CoreText armv6 <d2f43e4a532b83e42561da6f05376b7b> /System/Library/PrivateFrameworks/CoreText.framework/CoreText
0x34358000 - 0x3435efff liblockdown.dylib armv6 <6fe2483fe67d4fc5c932ae02a64501c2> /usr/lib/liblockdown.dylib
0x3435f000 - 0x34367fff libgcc_s.1.dylib armv6 <6673f222acee5f3a208169712387862a> /usr/lib/libgcc_s.1.dylib