1

This just started happening when I tested on my iPad using the new 4.2.1 firmware using the iOS 4.2 final SDK, however I've changed a lot of code since the last time I tested on my device so I can't be 100% sure it's 4.2.1 related though it seems very likely. I was previously testing on 4.2 beta3 with 4.2 beta3 SDK with no problems.

I have a view that does some Quartz 2D drawing. Every time I call [self setNeedsDisplay] on it to update the drawing, the application crashes with a Signal 0. I've never had a problem with this before and was always using that call to redraw the view without issue.

Has anyone run into this before or has any info on what the cause could be? The crash is happening before drawRect: is called, so I'm not sure how to debug this.

It does not crash in the simulator, only on the actual device.

No crash logs are generated on the device and the exact error that is displayed in the debugger is this:

Program received signal:  “0”.
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Unknown error loading shared library "/Developer/usr/lib/libXcodeDebuggerSupport.dylib")

Also, before anyone suggests that it's an issue with using too much memory as signal 0 errors often are, the app is using only 1.4mb of ram when the crash happens (viewed in Instruments) and I don't see a big spike of allocations or anything before it crashes. It crashes with just over 1.4mb used.


Update: I've been working on this more, here's what I've found so far.

  1. There seem to be some issue with the 4.2 final SDK and iOS 4.2.1 but they don't seem related to this particular issue.
  2. I've downgraded to 4.2 beta 3 that was previously working for me, and it is still crashing the same way
  3. If I don't override the drawRect: method in my class and I call setNeedsDisplay is DOESN'T crash.
  4. If I override drawRect: even if I keep it empy (just calling [super drawRect:] or even leaving it completely empty) it DOES crash.

So for some reason, just implementing drawRect: at all is causing this problem. It makes no sense though as I've implemented this code this same way since I started this project and am only now experiencing this issue.


Update: It turned out to be a memory issue after all related to the size of the view that I'm doing the drawing in. Although the Instruments tool seems to not be displaying it for some reason, according to this post: iPhone + UIView. Enormous memory consumption during drawRect. Any strategies for reducing this? when using setNeedsDisplay: on a large view there is a huge memory spike and the only real way to fix it is to use smaller tiled views and draw in each separately.

I removed a bunch of images from my scrollview and was able to see the memory warnings without the crash. I found if I lower the size of my drawing view in the scroll view, I no longer get memory errors. I had the drawing view at almost 4000x4000 before. Lowered it to 3000x2000 and no more crashes.

Now the issue for me is I need one contiguous drawing view, due do the nature of what I'm drawing I'm not sure it's possible to tile it. But that's a question for another post.

Community
  • 1
  • 1
Ben Baron
  • 14,496
  • 12
  • 55
  • 65
  • Post what is happening on the crash. You do get crash reports, those will help us help you. – jer Nov 24 '10 at 20:54
  • where do you call setNeedsDisplay? – Vladimir Nov 24 '10 at 21:01
  • Any chance you are calling `setNeedsDisplay` on a background thread? – Ole Begemann Nov 24 '10 at 21:06
  • Calling setNeedsDisplay in a method in the UIView subclass. That method is called by an NSNotification. To rule out any thread issues I've tried using performSelectorOnMainThread and it has the same results. // It doesn't seem to be generating any crash longs on the device, just showing a signal 0 and crashing. I'll paste in the exact error at the end of my question. – Ben Baron Nov 24 '10 at 21:07
  • Try deleting the app on your device then re-installing via Xcode. I had a strange but similar issue where a Core Data model was failing to compile and be installed properly after updating to the 4.2 final SDK and iOS 4.2.1, and this seemed to have fixed it. – Daniel Dickison Nov 24 '10 at 21:17
  • No dice :( I had done a clean restore anyway when I updated, so everything got wiped. No chance of using any of the old code. – Ben Baron Nov 24 '10 at 21:41

1 Answers1

2

Try this Other Answer/Solution Basically it is likely a memory problem.

Community
  • 1
  • 1
Michael Kernahan
  • 1,442
  • 1
  • 13
  • 15
  • I've read that post already. Like I said in my question, I realize these are usually memory issues, however in this case it isn't. The app is using all of 1.4mb of ram when it crashes. Also, it ran fine on 4.2 beta 3, only now on 4.2.1 final is it crashing. I'm also having some weird symbol issues with another app of mine now that I've updated to 4.2.1 (when it crashes it doesn't show me debug into, instead complains about a missing file), so I'm going to reinstall Xcode from scratch to see if that makes any difference. It seems like something might have gotten messed up when I updated Xcode. – Ben Baron Nov 25 '10 at 06:46
  • Actually looks like you were right after all. Although the Instruments tool seems to not be displaying it for some reason, according to this post: http://stackoverflow.com/questions/1864218 when using setNeedsDisplay: on a large view there is a memory spike. I removed a bunch of images from my scrollview and was able to see the memory warnings without the crash. I found if I lower the size of my drawing view in the scroll view, I no longer get memory errors. I had the view at almost 4000x4000 before. Lowered it to 3000x2000 and no more crashes. – Ben Baron Dec 01 '10 at 22:01
  • 1
    Nice. Glad you were able to fix it. I know the documentation recommends nothing greater than 1024x1024 (Note at the top of UIView Class Reference). I guess you found out why. – Michael Kernahan Dec 02 '10 at 14:56