Programming

Crash in CGPathApply … again… help!


I’m starting to see these often:

0   libsystem_kernel.dylib        0x3b6f1838 __kill + 8

1   Cyclist                       0x0018ab28 CLSSignalHandler + 188

2   libsystem_c.dylib             0x3b672e90 _sigtramp + 40

3   CoreGraphics                  0x333f2006 CGPathApply + 34

4   QuartzCore                    0x34f6cee2 CA::Render::Path::new_path(CGPath const*, bool) + 114

5   QuartzCore                    0x34ff3972 -[NSObject(CAAnimatableValue) CA_interpolateValue:byFraction:] + 278

6   QuartzCore                    0x34f5ba14 -[CABasicAnimation applyForTime:presentationObject:modelObject:] + 740

7   QuartzCore                    0x34f508a2 CA::Layer::presentation_layer(CA::Transaction*) + 482

8   UIKit                         0x35181bf6 _UIViewEatsTouches + 158

9   UIKit                         0x351818f2 -[UIView(Geometry) hitTest:withEvent:] + 186

10  UIKit                         0x35355fae __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke_0 + 102

11  CoreFoundation                0x33364aec __NSArrayChunkIterate + 360

12  CoreFoundation                0x3335da74 __NSArrayEnumerate + 608

13  CoreFoundation                0x332bfb66 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 58

14  UIKit                         0x35181aba -[UIView(Geometry) hitTest:withEvent:] + 642

15  UIKit                         0x35355fae __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke_0 + 102

16  CoreFoundation                0x33364aec __NSArrayChunkIterate + 360

17  CoreFoundation                0x3335da74 __NSArrayEnumerate + 608

18  CoreFoundation                0x332bfb66 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 58

19  UIKit                         0x35181aba -[UIView(Geometry) hitTest:withEvent:] + 642

20  UIKit                         0x35355fae __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke_0 + 102

21  CoreFoundation                0x33364aec __NSArrayChunkIterate + 360

22  CoreFoundation                0x3335da74 __NSArrayEnumerate + 608

23  CoreFoundation                0x332bfb66 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 58

24  UIKit                         0x35181aba -[UIView(Geometry) hitTest:withEvent:] + 642

25  UIKit                         0x35355fae __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke_0 + 102

26  CoreFoundation                0x33364aec __NSArrayChunkIterate + 360

27  CoreFoundation                0x3335da74 __NSArrayEnumerate + 608

28  CoreFoundation                0x332bfb66 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 58

29  UIKit                         0x35181aba -[UIView(Geometry) hitTest:withEvent:] + 642

30  UIKit                         0x35355fae __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke_0 + 102

31  CoreFoundation                0x33364aec __NSArrayChunkIterate + 360

32  CoreFoundation                0x3335da74 __NSArrayEnumerate + 608

33  CoreFoundation                0x332bfb66 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 58

34  UIKit                         0x35181aba -[UIView(Geometry) hitTest:withEvent:] + 642

35  UIKit                         0x35355fae __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke_0 + 102

36  CoreFoundation                0x33364aec __NSArrayChunkIterate + 360

37  CoreFoundation                0x3335da74 __NSArrayEnumerate + 608

38  CoreFoundation                0x332bfb66 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 58

39  UIKit                         0x35181aba -[UIView(Geometry) hitTest:withEvent:] + 642

40  UIKit                         0x353539d8 __47+[UIWindow _hitTestToPoint:pathIndex:forEvent:]_block_invoke_0 + 120

41  UIKit                         0x351815d0 +[UIWindow _topVisibleWindowPassingTest:] + 140

42  UIKit                         0x35181532 +[UIWindow _hitTestToPoint:pathIndex:forEvent:] + 150

43  UIKit                         0x3516fdfc _UIApplicationHandleEvent + 1260

44  GraphicsServices              0x36e635a0 _PurpleEventCallback + 588

45  GraphicsServices              0x36e631ce PurpleEventCallback + 30

46  CoreFoundation                0x3333e170 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32

47  CoreFoundation                0x3333e112 __CFRunLoopDoSource1 + 134

48  CoreFoundation                0x3333cf94 __CFRunLoopRun + 1380

49  CoreFoundation                0x332afeb8 CFRunLoopRunSpecific + 352

50  CoreFoundation                0x332afd44 CFRunLoopRunInMode + 100

51  GraphicsServices              0x36e622e6 GSEventRunModal + 70

52  UIKit                         0x351c52fc UIApplicationMain + 1116

53  Cyclist                       0x000aecb4 main (main.m:15)

54  libdyld.dylib                 0x3b62bb1c start + 0

 

 

…and I’m not sure why.

 

In this case I can reproduce it, it’s touching a view that’s in the middle of animating.

 

 

Any suggestions?

Programming

I need to know if I’m using API that’s not compatible with an earlier iOS…


OK, so I know all the arguments and I’m bored with them.  The bottom line is I’m totally fed up of doing a huge development on an app, working late, testing, re-testing, fine tuning, re-considering, doubling timescales, trying to get the finest products out there.  Then because I don’t have an army of QAs, equipped with every device going back three years, an incompatibility slips through.  It happened today, I did a swift patch last week and introduced a crash on iOS 5.  Yes, I know I should have tested and there is no substitute for good QA, but… am I alone in feeling let down by XCode?

How quickly do we start getting warnings all over the code when Apple decide that a function is deprecated.  Pretty quickly.  We are all encouraged to move to the newest APIs and code with them, remembering backward compatibility.  But what if we forget?  What if, like me, you set your deployment target to iOS 4.3, run a build, analysis, test.  Is there ANY way of getting XCode to give you a nice little list “here are the thirty places in your code that you’re calling new APIs, which will break at runtime if your client is on an old iOS, make sure you’ve written defensive code around each”.  No.  So much of the compiler framework seems to be there (what does __attribute__(introduced) actually do?) but it’s not there.  So I took a hammer and blowtorch to the problem.

I found the API call which had just let me down and went to the definition.  Sure enough there’s a

NS_AVAILABLE_IOS(6_0) macro written after it.  Why can’t this warn me??

 

I looked that up, it’s in a runtime header:

#define NS_AVAILABLE_IOS(_ios) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_##_ios)

which refers to macros in usr/include/Availability.h:

#define __OSX_AVAILABLE_STARTING(_osx, _ios) __AVAILABILITY_INTERNAL##_ios

and that in turn refers to a macro in AvailabilityInternal.h:

#define __AVAILABILITY_INTERNAL__IPHONE_6_0                    __attribute__((availability(ios,introduced=6.0)))

 

There’s the useless availability attribute (you’d think it would combine with the deployment version defined in the project, right?)

 

So I take a sledgehammer to it, find the actual header file on disk and do this:

//            #define __AVAILABILITY_INTERNAL__IPHONE_6_0                    __attribute__((availability(ios,introduced=6.0)))

#define __AVAILABILITY_INTERNAL__IPHONE_6_0 __attribute__((deprecated))

 

yes, that’s right, I just edited a core header file, Apple would hate me.

 

But it works.  Now I get a slew of “deprecated” warnings all over the project, wherever I’m using functions reserved for iOS 6 or later, and I can find each one, check it, then finally return the header back to normal.  Hopefully this should nix a few of these horror bugs.

Programming

Setting XCode 4.0 Environment Variables from a Script


Looks amazing. Going to try it as soon as I can!

Andrew Bennett's Blog

I have struggled for quite a while with XCode 4, it is excellent for Cocoa development, but if you’re trying to do anything lower level I often find myself pining after XCode 3.x or wanting to use a Makefile or something instead. However there are many advantages to an IDE, like code completion and integrated debugging tools, so it’s always nice to use things how they are designed. However there are some things XCode 4 does not do nicely, this article describes one such thing and the solution I’ve come up with. I don’t think XCode 3.x did this particular thing well either, so perhaps my solution might actually be useful to someone else.

The Problem

Often I want a bit more control over how I compile and link things than XCode allows. Tools like llvm-config allow you to get the compiler settings for your local build of llvm api, which…

View original post 642 more words

Programming

WebTryThreadLock Tried to obtain the web lock from a thread other than the main thread or the web thread


I’ve been seeing more and more of these, usually occurring on some obscure thread, with none of my own code on the stack, leaving me scratching my head.

Today I got the message with a couple of frames of my own code involved, meaning I could start to get to the bottom of it.

Amazingly, the crash was occurring in the layoutSubviews method of one of my custom views.  Specifically one line adjusts the frame of a UITextView and that is causing a crash.  Notably, there’s web stuff occurring so it looks like in some way some of the web rendering engine is being used by UITextView, which is an interesting aside.  But more to the point, how is layoutSubviews called on a background thread?  I didn’t expect that.

A bit of thinking, a careful Google for “layoutSubviews occurs on background thread” and I found this brilliant post by Alan Quatermain (unfortunately I couldn’t find out how to comment on it to say thanks) http://tumblr.alanquatermain.me/post/1670154581/lesson-for-today#notes

I went through my code and made sure that all setNeedsLayout calls are done on the main thread (it only sets a flag so it’s not time consuming).

Seems to be working!

Programming

iPad simulator keyboard not working?


I’ve noticed an issue with the iPad simulator, sometimes when I go to type in a text field, the software keyboard comes up but I can’t type into it using my laptop keyboard as usual. I’ve not fixed it but at least I’ve got a bit more clarity when it occurs. Now it seems to be fine if I run an app using iPad 6.1 Simulator but not if I run using iPad 5.0 Simulator. And it’s only a problem when I’m entering text into a popup prompt on the simulator, like the app store username/password for “restore purchases”, it’s fine in standard text fields. Reset content and settings doesn’t seem to cure it either. It’s not a fix but it’s a step towards a diagnosis! 🙂

Programming

midnight epiphany


I’ve just noticed, while decoding the NSAssert macro, that there’s a variable hiding in plain sight, _cmd, the dark twin sister of self, the current selector you’re running! I’m not sure what it’s useful for, but it looks fun.

Programming

GPS Pro is finally here!


After a year of being buried by just about everything, I’ve finally got the major updates done.  Waypoints editable (back in December), and now this week the GPS pro update.  To make it simpler, rather than having to buy a separate app, you can just buy an in-app purchase from within the standard free app.  Also, to make it even easier, I’m no longer updating the GPS Receiver app for iPhone and I’ve merged (and extended) it’s code into GPS Receiver HD as a universal app.  Now all customers just download one free app that works on iPhone and iPad and can buy the pro app right there and then as a one off purchase, giving you the pro package on all platforms for life for under four dollars!