0

I'm having trouble finding a bug in my app because it only presents itself after an adhoc installation. I have narrowed it down to [self.mapview removeOverlay:overlay]; and '[self.mapview addOverlay:overlay]. The exact same code with the exact same steps works just minutes before if I install and debug via Xcode (4.6.1). I'm not changing any other settings in between tests. I just Archive and distribute the app, or I press the Run button and it gets pushed to my iPad. One time it works, one time it fails.

Xcode->device = overlays can come and go as I want Xcode->adhoc->server->device = complete app freeze when I try to remove a visible overlay or add one that is within the area the map can see right now

I've looked at the crash logs on the device and it always within [MKOverlayClusterView didAddSubview:] or [MKOverlayClusterView willRemoveSubview:]

Here's the main thread as shown in the crash log

0   libsystem_kernel.dylib        0x3c4ff27c __psynch_rw_wrlock + 24
1   libsystem_c.dylib             0x3c44fbd6 pthread_rwlock_wrlock + 334
2   MapKit                        0x34fb321e -[MKOverlayClusterView willRemoveSubview:] + 50
3   UIKit                         0x3614b2d2 __UIViewWillBeRemovedFromSuperview + 126
4   UIKit                         0x35f93844 -[UIView(Hierarchy) removeFromSuperview] + 52
5   MapKit                        0x34fae5b0 -[MKOverlayContainerView _removeOverlayView:forOverlay:coalesce:] + 24
6   MapKit                        0x34fae118 -[MKOverlayContainerView removeOverlays:] + 240

It's worth noting that in both the add/remove variants the last top of the stack is the same so perhaps this is an issue with pthread_rwlock_wrlock meaning I've crossed threads at some point. I have tried to protect against this by using [self performSelectorOnMainThread:@selector(mainThreadRemoveOverlays:) withObject:@[overlay] waitUntilDone:YES]; but the crash keeps happening when the app is installed via the adhoc method and never happens when debugging via Xcode.

Craig
  • 8,093
  • 8
  • 42
  • 74

1 Answers1

0

I had something similar problem. I was adding a map overlay to a map. Worked fine when testing but not for Ad hoc deployment. My solution was that I had put the wrong case. I was using map.jpeg when the file name was actually Map.jpeg.

Map.jpeg != map.jpeg

As the map was working on test I just assumed that was the correct name. Took me a while to find out this was the problem. Not sure why my iPhone 5 or simulator did not pick this up.

Also it is good to Clean your project before deploying.

Hope this helps

Will
  • 3,004
  • 29
  • 43
  • O.M.G. I think your "Also it is good to Clean your project before deploying." solved it. I've been going nuts over this. NUTS! I'll do some more testing tonight but I'm pretty sure you just bagged yourself a bonus! – Craig Apr 18 '13 at 20:35
  • Yay Thanks. Never answered a question with a bounty before :P – Will Apr 19 '13 at 11:27
  • It appears I jumped the gun. Whilst doing a clean I also reenabled debugging by defining the function ELog. I had a busy wait that only had an ELog call in it (very rudimentary locking procedure) and it seems that with nothing in the loop the app crashed when in ad-hoc mode. With something in the loop it runs fine in ad-hoc mode without cleaning. I have now moved over to using NSLock properly. – Craig Apr 22 '13 at 23:11