tags:

views:

297

answers:

1

Hey guys,

Thanks to Ole Begemann, I spent yesterday digging around in Core Plot to explore adding graphing to an iPad application that I've been working on. I was fairly satisfied with it, and wanted to show it off to a friend of mine - so I stopped the debugger, took the device off the dock, handed it over to my friend and pushed the icon. Lo, it started and then immediately crashed.

I figured that it was using the release profile, and on a whim went ahead and compiled and ran (through the debugger) under the release profile instead of the debug. As expected, it crashed right away with EXC_BAD_ACCESS.

I have added the relative path to the core plot to Release configuration and -all_load and -ObjC to the "other" linker flags - just like in the debugger profile and googled all around. IT seems that most people with this issue have forgotten to add the linker flags.

Further research indicates that the app is crashing when I set the hostedLayer for a newly allocated CPXYGraph object.

graphLayer = [[CPLayerHostingView alloc] initWithFrame: graphView.bounds];
graph = [[CPXYGraph alloc] initWithFrame: graphLayer.bounds];
graphLayer.hostedLayer = graph;

graphView is an IBOutlet tied to a UIView.

Further investigation reveals that [CPXYGraph alloc] initWithFrame is not actually returning a pointer when ran in the release target.

Oif, even further analysis yields that when I manually initialize the destination UIView (graphView) the code at least runs in release mode - but doesn't render the graph as I'm assuming the view is now tied off in the netherworld somewhere. I can't imagine that the UIView initialization stuff is different from standard debug to release flags... I'm totally baffled at this point.

Even more updates; I totally removed the release configuration - so the only configuration that the app can be compiled and ran as is "debug". It runs while XCode is attached, but exits immediately if it isn't. I'm now officially completely stumped.

Does anyone have any suggestions for next steps in figuring out this issue?

Update

I fixed the issue in a very hackish sort of way. It seems that some object initialization was occurring after the viewDidLoad method - but only if Xcode was not attached. I am thoroughly baffled by this, but that appears to be what it was. I had a timer around that was doing some other stuff, and added a bool (wasInitialized) to my init method that was setting up the graphs. It only gets called once, but man its a kludge.

So, not that this is an answer - but for other people in the future this might be a temporary solution.

A: 

I am running with the same issue where I can run graph perfectly for first time but when I release graph in dealloc method with all its references. CALayer crash occurs.

Can you please provide me code where you have put called function in Timer?

Jignesh Brahmkhatri
My hack was particular to my specific code, since I had a timer laying around that was delayed (inadvertently) until the layer had completely loaded. You can re-implement this (remember, its a hack) by setting up an NSTimer to fire off 1s after ViewDidLoad and then do all of your CPXYGraph initialization in there.My issue was that I couldn't even get the graphs to initialize - much less run until legitimate de-allocation. Sounds like something attached to the graph object is getting de-allocated before the graph. I would pose this as a separate question to the rest of the SO community.
phantomdata