can demystify crash report?
there's no exception name or reason, , backtrace shows crash happening on line 0 of file contains init method crashed. what?
incident identifier: todo crashreporter key: todo hardware model: iphone7,2 process: appname [1112] path: /private/var/mobile/containers/bundle/application/2632c5d7-6a07-4002-a27b-d547e9a7345c/appname.app/appname identifier: com.app.name version: 67 code type: arm-64 parent process: launchd [1] date/time: 2015-06-26 18:20:18 +0000 os version: iphone os 8.3 (12f70) report version: 104 exception type: sigtrap exception codes: trap_brkpt @ 0x10008c370 crashed thread: 0 application specific information: *** terminating app due uncaught exception '', reason: '' the first couple symbolicated lines of crashed thread:
0 appname 0x000000010008c370 init (article, $metatype) (articleimageprovider.swift:0) 1 appname 0x000000010006b0c4 sharearticleactivityviewcontroller (article, track) (basicarticlesharingcontroller.swift:28) 2 appname 0x0000000100063198 sharepressed () (detailsviewcontroller.swift:202) 3 appname 0x00000001000600c8 sharepressed () (detailsviewcontroller.swift:200) 4 appname 0x00000001000bfa8c sharepressed () (contentnavview.swift:108) 5 appname 0x000000010022f4b4 __55-[ascontrolnode sendactionsforcontrolevents:withevent:]_block_invoke (ascontrolnode.m:360) 6 appname 0x000000010022f21c -[ascontrolnode sendactionsforcontrolevents:withevent:] (ascontrolnode.m:381) 7 appname 0x000000010022e5b8 -[ascontrolnode touchesended:withevent:] (ascontrolnode.m:191) 8 appname 0x000000010026185c -[_asdisplayview touchesended:withevent:] (_asdisplayview.mm:173) 9 uikit 0x0000000187613d8c forwardtouchmethod + 260 10 uikit 0x00000001874b0a2c -[uiwindow _sendtouchesforevent:] + 696 11 uikit 0x00000001874a9f68 -[uiwindow sendevent:] + 680 12 uikit 0x000000018747d18c -[uiapplication sendevent:] + 260 13 uikit 0x000000018771e324 _uiapplicationhandleeventfromqueueevent + 15420 14 uikit 0x000000018747b6a0 _uiapplicationhandleeventqueue + 1712 here's code:
// attach action button in contentnavview sharebutton.addtarget(self, action: "sharepressed", forcontrolevents: ascontrolnodeevent.touchupinside) /* snip */ // implementation of contentnavview#sharepressed() func sharepressed() { delegate.sharepressed() } // implementation of detailsviewcontroller#sharepressed() func sharepressed() { if let cell = currentcell { let activityviewcontroller = basicarticlesharingcontroller.sharearticleactivityviewcontroller(cell.article) self.view.window?.rootviewcontroller?.presentviewcontroller(activityviewcontroller, animated: true, completion: nil) } } // implementation of basicarticlesharingcontroller#sharearticleactivityviewcontroller(::) initializer class func sharearticleactivityviewcontroller(article: article, track: bool = true) -> uiactivityviewcontroller { var article = coredatamanager.sharedmanager.managedobjectcontextforcurrentthread().objectwithid(article.objectid) as! article let activities = [ articleimageprovider(article: article), // crash when calling init? articlelinkprovider(article: article) ] /* snip */ } // implementation of init that's crashing. apparently swift reports class crashes, not line crashes, here's implementation thought wasn't relevant. final public class articleimageprovider: uiactivityitemprovider { let articleobjectid: nsmanagedobjectid init(article: article) { self.articleobjectid = article.objectid let article: article = coredatamanager.sharedmanager.managedobjectcontextforcurrentthread().objectwithid(article.objectid) as! article let thumbnailcut = article.headlineimage?.cutwithshape(.landscape) if let path = thumbnailcut?.localurl?.path { if let image = uiimage(contentsoffile: path) { super.init(placeholderitem: image) } else { super.init(placeholderitem: uiimage()) } } else { super.init(placeholderitem: uiimage()) } } /* snip */ }
so, few things learned here:
objectwithid:returnsnsmanagedobject. that's it. there's no guarantee object you're sending message return object of same type receiver, testing returned object safest way handle this. corollary that, scopingnsfetchrequests reduce or eliminate threading issues managed objects paramount concern , eliminate problem altogether.- there fewer signal traps in compiled swift code, getting crash report apple or crittercism (through
nsthread#callstacksymbolsor other api) return same junk i'm showing here. best can infer lexical scope that's cause of crash , comb code possible errors. we're stuck having until swift matures. - use implicitly unwrapped optionals sparingly.
Comments
Post a Comment