I'm having a random UIWebView crash using iOS8.1 and UIWebView, using an iPhone5. In my tests the crash doesn't appear on iOS7.
I've created this github repository to reproduce the crash:
https://github.com/crarau/WebViewCrash
Basically I'm adding a UIWebView and loading www.amazon.com
Randomly the app is crashing on the WebThread with EXC_ARM_BREAKPOINT
After enabling Zombie tracking on the console there is this message:
[UIViewAnimationState release]: message sent to deallocated instance 0x14deff70
Here what happens on UIView load:
[super viewDidLoad];
NSURLRequest * urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.amazon.com"]];
self.webView.layer.cornerRadius = 0;
self.webView.userInteractionEnabled = YES;
self.webView.multipleTouchEnabled = YES;
self.webView.backgroundColor = [UIColor clearColor];
self.webView.scrollView.scrollEnabled = NO;
self.webView.scrollView.bounces = NO;
[self.webView loadRequest:urlRequest];
The exception stacktrace:
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000000000defe
Triggered by Thread: 2
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 libsystem_kernel.dylib 0x2fe054f0 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x2fe052e4 mach_msg + 36
2 CoreFoundation 0x21fed936 __CFRunLoopServiceMachPort + 142
3 CoreFoundation 0x21febedc __CFRunLoopRun + 1012
4 CoreFoundation 0x21f3a20c CFRunLoopRunSpecific + 472
5 CoreFoundation 0x21f3a01e CFRunLoopRunInMode + 102
6 GraphicsServices 0x293330a4 GSEventRunModal + 132
7 UIKit 0x255461cc UIApplicationMain + 1436
8 WebViewCrash 0x0002deec main (main.m:14)
9 libdyld.dylib 0x2fd52aac start + 0
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0 libsystem_kernel.dylib 0x2fe052a0 kevent64 + 24
1 libdispatch.dylib 0x00162674 0x154000 + 58996
2 libdispatch.dylib 0x00157496 0x154000 + 13462
Thread 2 name: WebThread
Thread 2 Crashed:
0 CoreFoundation 0x2202aea2 ___forwarding___ + 534
1 CoreFoundation 0x21f5cdf4 _CF_forwarding_prep_0 + 20
2 CoreFoundation 0x21f2ee58 CFRelease + 596
3 QuartzCore 0x24f0ba60 CA::release_objects(X::List<void const*>*) + 12
4 QuartzCore 0x24f10dc2 -[CAAnimation dealloc] + 50
5 libobjc.A.dylib 0x2f7ecd5a objc_object::sidetable_release(bool) + 162
6 libobjc.A.dylib 0x2f7ed1a4 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 400
7 CoreFoundation 0x21fee2a4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 12
8 CoreFoundation 0x21fede1e __CFRunLoopDoTimer + 646
9 CoreFoundation 0x21fec06e __CFRunLoopRun + 1414
10 CoreFoundation 0x21f3a20c CFRunLoopRunSpecific + 472
11 CoreFoundation 0x21f3a01e CFRunLoopRunInMode + 102
12 WebCore 0x2d362ebe RunWebThread(void*) + 414
13 libsystem_pthread.dylib 0x2fe95e90 _pthread_body + 136
14 libsystem_pthread.dylib 0x2fe95e02 _pthread_start + 114
15 libsystem_pthread.dylib 0x2fe93b8c thread_start + 4
Any advice is appreciated
Thanks
I'm experiencing the same issue on iOS 8 and more specifically an iPad 3 fails much more often than others.
Based on your post and a couple of others that I was able to find, it seems that it's an issue with UIWebView on iOS8 only, as it works on iOS7.
What I've done is to use the new WKWebView on iOS8, which doesn't present the same issue, while continuing to use UIWebView on iOS7.
The best thing to do would be to file a radar with Apple and switch to WKWebView in the meantime.
If you are not using animations you can avoid this bug by disabling Animations. Put this in your controller init method:
[UIView setAnimationsEnabled:NO];
[super viewDidLoad];
[[MPVolumeView alloc] init]; <------ add this line, that will be ok too.
NSURLRequest * urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.amazon.com"]];
self.webView.layer.cornerRadius = 0;
self.webView.userInteractionEnabled = YES;
self.webView.multipleTouchEnabled = YES;
self.webView.backgroundColor = [UIColor clearColor];
self.webView.scrollView.scrollEnabled = NO;
self.webView.scrollView.bounces = NO;
[self.webView loadRequest:urlRequest];
This work around appears to fix it for my app. I'm not comfortable with this, but it's currently the only thing I've been able to figure out to get rid of the crash.
[self.webView performSelector:#selector(loadRequest:)
withObject:urlRequest] afterDelay:0.5];
Or, if you want something safer you can use WKWebView on iOS 8+
Since WKWebView doesn't support local files, start a web server:
[GCDWebServer setLogLevel:4];
webServer = [[[GCDWebServer alloc] init] retain];
[webServer addGETHandlerForBasePath:#"/" directoryPath:rootDir indexFilename:#"index.html" cacheAge:3600 allowRangeRequests:YES];
[webServer startWithPort:0 bonjourName:nil];
Then, depending on the OS version, create your webview:
if (NSClassFromString(#"WKWebView"))
{
NSString* jScript = #"";
WKUserScript* wkUScript = [[WKUserScript alloc] initWithSource:jScript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
WKUserContentController* wkUController = [[WKUserContentController alloc] init];
[wkUController addUserScript:wkUScript];
WKWebViewConfiguration* wkWebConfig = [[WKWebViewConfiguration alloc] init];
wkWebConfig.userContentController = wkUController;
webViewNew = [[WKWebView alloc] initWithFrame:CGRectMake(0.f, 0.f, 1.f, 1.f) configuration:wkWebConfig];
webViewNew.navigationDelegate = self;
webViewNew.scrollView.bounces = NO;
webViewNew.scrollView.scrollEnabled = NO;
webViewNew.backgroundColor = [UIColor redColor];
webViewNew.opaque = YES;
}
else
{
webViewOld = [[UIWebView alloc] initWithFrame: CGRectMake (0, 0, 1.0f, 1.0f)];
webViewOld.delegate = self;
[[webViewOld scrollView] setBounces: NO];
webViewOld.scrollView.scrollEnabled = NO;
webViewOld.scalesPageToFit = YES;
[webViewOld setBackgroundColor:[UIColor whiteColor]];
[webViewOld setOpaque:NO];
}
And then browse to: [NSString stringWithFormat: "htztp://127.0.0.1:%d", (int)webServer.port]
(Ignore the z in the http, stackoverflow won't let me post urls to localhost)
I solved the problem. I had the same issue adding a video tag (source was a local mp4 file approx. 18Mb). I could identify the video tag as the crash responsible because html without video doesn't crash. Then i tried to inject two seconds later the video tag via javascript and the app crashed. After a few hours i found this: UIWebView loading html5-Video EXC_BAD_ACCESS crash.
My solution was to extract the video tag injection in a javascript function and call that function on webViewDidFinishLoad.
So, in my controller i have:
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[self.webView stringByEvaluatingJavaScriptFromString:#"placeVideoTag();"];
}
While in my index.html i have:
...
<div id="left">
<div id="media-div"></div>
...
and (i added an audio tag too!):
<script>
function placeVideoTag() {
$('#media-div').html('<video id="videoController" width="100%" controls > <source src="video_1.mp4" type="video/mp4"></video>');
$('#media-div').append('<br/><audio id="audioController" controls="" width="100%"><source src="audio_1.mp3" type="audio/mp3"></audio>');
}
</script>
I know it sounds as a strange solution, but it is really working. I had the same identical issue as stated here, also enabling Zombie tracking
Randomly the app is crashing on the WebThread with EXC_ARM_BREAKPOINT
After enabling Zombie tracking on the console there is this message:
[UIViewAnimationState release]: message sent to deallocated instance
0x14deff70
make sure you set the UIWebView delegate to nil in the dealloc method
- (void)dealloc {
[self.webView stopLoading];
self.webView.delegate = nil;
}
Try to update to iOS 8.4.1. It worked for us (however, we didn't find any references to this bug in release notes).
I know am late but this could help someone, make sure your IBOutlet views are weak. This answer helped me to get rid of this issue.
Related
I have a problem with objective-c code that handles openning camera to take a picture the code is injected as native code inside codename one
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
NSArray *mediaTypes = [[NSArray alloc]initWithObjects:(NSString *)kUTTypeImage, nil];
imagePicker.mediaTypes = mediaTypes;
imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
[[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentViewController:imagePicker animated:YES completion:nil];
}else{
[self showAlert:#"No Camera Privilege On This Device"];
}
the problem is when the above code is executed on iOS-11 ,I get null pointer exception from codenameone without asking for camera permission unlike iOS-12
the code works perfectly
the permission are added in the codenamesettings
codename1.arg.ios.NSPhotoLibraryAddUsageDescription=The App uses the Photo Library to save Images downloaded from News
codename1.arg.ios.NSCameraUsageDescription=The App uses the Camera for Video Chat support
codename1.arg.ios.NSPhotoLibraryUsageDescription=The App uses the Photo Library to save Images downloaded from News
is there anything that can be done to handle the issue on iOS11
--exception stack-trace from simulator using Xcode9.2
2018-10-04 18:47:50.830359+0300 TestApplication[7630:35311] *** Assertion failure in -[UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3698.33.6/UIApplication.m:1709
2018-10-04 18:47:50.853277+0300 TestApplication[7630:35311] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'accessing _cachedSystemAnimationFence requires the main thread'
*** First throw call stack:
(
0 CoreFoundation 0x000000010da7312b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010d107f41 objc_exception_throw + 48
2 CoreFoundation 0x000000010da782f2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x0000000109d38d69 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 UIKit 0x0000000107ac692d -[UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:] + 359
5 UIKit 0x0000000107b51ac9 +[UIWindow _synchronizeDrawingWithPreCommitHandler:] + 57
6 UIKit 0x00000001082cfb7b -[UIInputViewAnimationStyle launchAnimation:afterStarted:completion:forHost:fromCurrentPosition:] + 99
7 UIKit 0x000000010872be9a -[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:] + 1697
8 UIKit 0x0000000108734c8f __43-[UIInputWindowController setInputViewSet:]_block_invoke.1493 + 97
9 UIKit 0x0000000108724208 -[UIInputWindowController performOperations:withTemplateNotificationInfo:] + 46
10 UIKit 0x000000010873481b -[UIInputWindowController setInputViewSet:] + 1336
11 UIKit 0x000000010872b450 -[UIInputWindowController performOperations:withAnimationStyle:] + 50
12 UIKit 0x00000001082c8164 -[UIPeripheralHost(UIKitInternal) setInputViews:animationStyle:] + 1669
13 UIKit 0x00000001082bff4b -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 2163
14 UIKit 0x00000001082c9480 -[UIPeripheralHost(UIKitInternal) _preserveInputViewsWithId:animated:reset:] + 498
15 UIKit 0x0000000107c89130 -[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:] + 1233
16 UIKit 0x0000000107c8ae94 -[UIViewController _presentViewController:withAnimationController:completion:] + 4621
17 UIKit 0x0000000107c8d9a9 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 99
18 UIKit 0x0000000107c8e079 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 532
19 UIKit 0x0000000107c8d908 -[UIViewController _presentViewController:animated:completion:] + 181
20 UIKit 0x0000000107c8dc67 -[UIViewController presentViewController:animated:completion:] + 159
appreciate the help
Regards,
thanks for all of your help , the problem as stated was only on iOS11 , and the reason for that if I present any viewcontroller with animated:Yes and I changed how to call the view controller by adding the following code
dispatch_queue_t _serialQueue = dispatch_queue_create("x.y.z", DISPATCH_QUEUE_CONCURRENT);
dispatch_sync(_serialQueue, ^{
self.filePath=param;
[self showForm];
});
and the showForm : just take a copy of the old viewcontroller and present the new one like this [condition was used to wait for the camera to finish picking and saving the file to gallery] :
-(void)showForm{
condition = [[NSCondition alloc] init];
self.parentViewController = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
[self.parentViewController.view setUserInteractionEnabled:NO];
destinationViewController = [[ViewController alloc] initWithValues:self.filePath andCondition:condition andChoice:#"Camera"];
[[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentViewController:destinationViewController animated:NO completion:nil];
[condition lock];
[condition wait];
self.filePath = [(ViewController*)destinationViewController getImagePath];
[self.parentViewController.view setUserInteractionEnabled:YES];
[condition unlock];
}
I hope that would help any one who needs it
Regards,
My app (iOS 8 only) has been rejected due to a crash when IAP are attempted. I've tried pretty much every incantation of the purchase process in an AdHoc build but cannot reproduce a crash. Looking at the crash log that the review team attached, I am seeing a very weird stack trace in the last exception backtrace. The crash looks to be involving UIPopoverController, however my app, though universal, does not explicitly or implicitly display popovers anywhere. Does anyone have any idea what might trigger the activity that is causing this crash? What might cause my app to display popovers when the review team is looking at it only?
Last Exception Backtrace:
0 CoreFoundation 0x186d52084 __exceptionPreprocess + 132
1 libobjc.A.dylib 0x1977a40e4 objc_exception_throw + 60
2 UIKit 0x18bc0aee0 -[UIPopoverPresentationController presentationTransitionWillBegin] + 2464
3 UIKit 0x18b7d27d8 __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 1324
4 UIKit 0x18b7d1310 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 212
5 UIKit 0x18b557388 _applyBlockToCFArrayCopiedToStack + 356
6 UIKit 0x18b4c8e4c _afterCACommitHandler + 532
7 CoreFoundation 0x186d0a388 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
8 CoreFoundation 0x186d07314 __CFRunLoopDoObservers + 360
9 CoreFoundation 0x186d076f4 __CFRunLoopRun + 836
10 CoreFoundation 0x186c35664 CFRunLoopRunSpecific + 396
11 GraphicsServices 0x18fd435a4 GSEventRunModal + 168
12 UIKit 0x18b53a984 UIApplicationMain + 1488
Not sure if it's the same cause as the original question, but I have the exact same error and the issue was using a UIAlertController with an ActionSheet style, presenting it worked fine on iPhone but iPad requires a sourceview to be set - https://stackoverflow.com/a/24233937/285694
This is a just similar situation. I had a crash bug on [UIPopoverPresentationController presentationTransitionWillBegin] on iOS 9+, and turns out that the crash occurred when sourceView was nil.
Example (in Objective-C):
UIViewController *vc = <#instance#>.
vc.modalPresentationStyle = UIModalPresentationPopover;
vc.popoverPresentationController.delegate = self;
vc.popoverPresentationController.sourceView = sourceView; // <--- this MUST NOT be nil.
vc.popoverPresentationController.sourceRect = sourceView.bounds;
[self presentViewController:vc animated:YES completion:nil];
It most probable the ActionSheet crash in iPad.
You should have a if condition like:
if let popoverController = alertVC.popoverPresentationController {
popoverController.sourceView = self.view
popoverController.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
popoverController.permittedArrowDirections = []
}
First you should check UIPopoverPresentationController available or not.
NSArray *Items = [NSArray arrayWithObjects:emailBody,anImage, nil];
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:Items applicationActivities:nil];
if ([UIPopoverPresentationController class] != nil) {
UIPopoverPresentationController *popover = activityController.popoverPresentationController;
if (popover)
{
popover.sourceView = sender;
//popover.sourceRect = sender.bounds;
popover.permittedArrowDirections = UIPopoverArrowDirectionAny;
}
}
[self presentViewController:activityController animated:YES completion:NULL];
I re-edit my question, it's for about two weeks that i set up my WebView in my application, everything was going well working together. Yesterday i wanted to just see if the webView is still working even if i didn't change any of the class's code, and boom SIGABRT. I'm on this bug since yesterday and don't understand why it still give my a SIGABRT.I did as advised some changes but still nothing works yet. If someone with advanced skills in objective c can help me please i'am going crazy, here is the log message (i can show all my code if needed, and please feel free to edit an answer so i can rate the good answer in order to help people after me):
here is my code :
- (void)showWebView;
{
//here i call my webview in my RootViewController
ViewController *WebViewVC = [[ViewController alloc] init];
[[self navigationController] pushViewController:WebViewVC animated:YES];
[WebViewVC pushIt];
}
//here is my WebViewController.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#interface ViewController : UIViewController <UIWebViewDelegate>
{
IBOutlet UIWebView *myWebView;
}
#property (nonatomic, retain) IBOutlet UIWebView *myWebView;
-(void)XButton;
-(void)pushIt;
#end
//here is my WebViewController.m
-(void)pushIt;
{
navigation control
self.navigationItem.hidesBackButton = YES;
self.navigationItem.leftBarButtonItem = nil;
self.title = #"*****";
myWebView = [[UIWebView alloc] initWithFrame:self.view.frame];
[self.view addSubview:myWebView];
[self XButton];
[self WebViewBrowserBackButton];
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSString *defaults = [prefs stringForKey:#"myKey"];
NSString *defaults2 = [prefs stringForKey:#"mySecondKey"];
NSString *username = defaults;
NSString *password = defaults2;
NSURL* url = [NSURL URLWithString:#"**************"];
NSString* body = [NSString stringWithFormat:#"************", username, password];
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:30];
request.HTTPMethod = #"POST";
request.HTTPBody = [body dataUsingEncoding:NSStringEncodingConversionAllowLossy];
[myWebView loadRequest:request];
}
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "MyWebViewController" nib but the view outlet was not set.'
*** First throw call stack:
(
0 CoreFoundation 0x017e15e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x015648b6 objc_exception_throw + 44
2 CoreFoundation 0x017e13bb +[NSException raise:format:] + 139
3 UIKit 0x005fd6e6 -[UIViewController _loadViewFromNibNamed:bundle:] + 505
4 UIKit 0x005fddad -[UIViewController loadView] + 302
5 UIKit 0x005fe0ae -[UIViewController loadViewIfRequired] + 78
6 UIKit 0x005fe5b4 -[UIViewController view] + 35
7 LockScreen 0x00011596 -[MyWebViewController pushIt] + 246
8 LockScreen 0x00003c0a -[RootViewController showWebView] + 202
9 libobjc.A.dylib 0x015767d2 -[NSObject performSelector:] + 62
10 LockScreen 0x00007f02 -[LCYDataBackedTableView tableView:didSelectRowAtIndexPath:] + 130
11 UIKit 0x005cc7b1 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1513
12 UIKit 0x005cc924 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 279
13 UIKit 0x005d0908 __38-[UITableView touchesEnded:withEvent:]_block_invoke + 43
14 UIKit 0x00507183 ___afterCACommitHandler_block_invoke + 15
15 UIKit 0x0050712e _applyBlockToCFArrayCopiedToStack + 403
16 UIKit 0x00506f5a _afterCACommitHandler + 532
17 CoreFoundation 0x017a94ce __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
18 CoreFoundation 0x017a941f __CFRunLoopDoObservers + 399
19 CoreFoundation 0x01787344 __CFRunLoopRun + 1076
20 CoreFoundation 0x01786ac3 CFRunLoopRunSpecific + 467
21 CoreFoundation 0x017868db CFRunLoopRunInMode + 123
22 GraphicsServices 0x02a659e2 GSEventRunModal + 192
23 GraphicsServices 0x02a65809 GSEventRun + 104
24 UIKit 0x004ead3b UIApplicationMain + 1225
25 LockScreen 0x0000297d main + 125
26 libdyld.dylib 0x0208970d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Connect the view property of WebViewController from nib file to File's Owner's view object.
The exception trace clearly shows that your view in nib is not connected.
This code worked under iOS6.2; installed iOS7 and now crashes:
- (IBAction)bOpenCamera:(UIButton *)sender {
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
customerCameraFlag = YES; // indicator so text fields are not cleared
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = (id)self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects: (NSString *) kUTTypeImage, nil];
imagePicker.allowsEditing = NO;
[self presentViewController:imagePicker animated:YES completion:nil];
newMedia = YES;
}
}
I use the same code in two separate classes; neither one work. The camera never opens, just crashes when the last line (newMedia = YES) has executed. I have looked at all the entries in SO and Google, and found nothing that resembles this crash. It apparently worked on iOS 6, but I am now unable to test it because I have gone to iOS7.
Any ideas on how to fix this?
*EXC_BAD_ACCESS is not a thrown exception; it is a hard crash. Spokane-dude should post the backtrace of the actual crash.*
when running the same app on the iPad under iOS7, outside of the debugger it works fine!
I'd bet it isn't working fine. It only appears to be working, but something is still going wildly wrong, potentially corrupting user data. I'd make figuring out what a priority.
Post the crash details.
OK -- crash is here:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x3b39c350 __pthread_kill + 8
1 libsystem_c.dylib 0x3b31311e pthread_kill + 54
2 libsystem_c.dylib 0x3b34f96e abort + 90
3 REDACTED.APP 0x0006aa72 0x19000 + 334450
4 Foundation 0x338a438c -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] + 164
5 Foundation 0x338a4088 -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] + 132
That the main thread is dispatching to itself is pretty odd and indicative of a shaky, at best, concurrency implementation.
But wait! The crash is actually further up Thread 0:
11 libsystem_c.dylib 0x3b34f96e abort + 90
12 libsystem_c.dylib 0x3b3304cc __assert_rtn + 176
13 REDACTED.APP 0x0001c3f2 0x19000 + 13298
14 UIKit 0x34e4bd18 -[UIView(CALayerDelegate) drawLayer:inContext:] + 360
15 QuartzCore 0x34bfabe0 -[CALayer drawInContext:] + 108
Whatever is in frame 13 -- some layer delegate trying to draw -- is assert()ing.
Given that it is a failed assert in a drawing method, that should narrow things down considerably.
I am writing iPad application and created DatePickerView and calling it from UIPopoverController as below:
DatePickerView *dt = [[DatePickerView alloc] initWithNibName:nil bundle:nil];
popover = [[UIPopoverController alloc] initWithContentViewController:dt];
popover.delegate = self;
[dt release];
self.popoverController = popover;
[popover release];
CGRect popoverRect = [self.view convertRect:[sender frame] fromView:[sender superview]];
popoverRect.size.width = MIN(popoverRect.size.width, 100);
[self.popoverController presentPopoverFromRect:popoverRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
In the DatePickerView i have below code when the "Done" button is selected, this is basically sending the selected date with formatter back to main UI by using appdelegate:
.h
I
BOutlet UIDatePicker *dtPicker;
-(IBAction) btnSelectClicked:(UIButton *)sender
{
MachineDetailsView *appDelegate;
appDelegate = (MachineDetailsView *)[[UIApplication sharedApplication] delegate];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:#"MM/dd/YYYY"];
NSDate *dt = [dtPicker date];
appDelegate.backPickerStartDate = [formatter stringFromDate:dt];
}
in MachineDetailsView i declared backPickerStartDate as below:
.h: file details
NSString *backPickerStartDate;
UIPopoverController *popoverController;
UIPopoverController *popover;
....
#property(nonatomic, retain) NSString *backPickerStartDate;
....
.m: file details
#synthesize backPickerStartDate;
I am getting below error when i click on "Done" button of DatePickerView
2011-03-23 11:46:59.813 iMobile[22492:40b] -[iMobileAppDelegate setBackPickerStartDate:]: unrecognized selector sent to instance 0x8a3dc00
2011-03-23 11:46:59.816 iMobile[22492:40b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[iMobileAppDelegate setBackPickerStartDate:]: unrecognized selector sent to instance 0x8a3dc00'
*** Call stack at first throw:
(
0 CoreFoundation 0x00df9be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f4e5c2 objc_exception_throw + 47
2 CoreFoundation 0x00dfb6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00d6b366 ___forwarding___ + 966
4 CoreFoundation 0x00d6af22 _CF_forwarding_prep_0 + 50
5 UIKit 0x00302a6e -[UIApplication sendAction:to:from:forEvent:] + 119
6 UIKit 0x003911b5 -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x00393647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
8 UIKit 0x003921f4 -[UIControl touchesEnded:withEvent:] + 458
9 UIKit 0x003270d1 -[UIWindow _sendTouchesForEvent:] + 567
10 UIKit 0x0030837a -[UIApplication sendEvent:] + 447
11 UIKit 0x0030d732 _UIApplicationHandleEvent + 7576
12 GraphicsServices 0x0172fa36 PurpleEventCallback + 1550
13 CoreFoundation 0x00ddb064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
14 CoreFoundation 0x00d3b6f7 __CFRunLoopDoSource1 + 215
15 CoreFoundation 0x00d38983 __CFRunLoopRun + 979
16 CoreFoundation 0x00d38240 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x00d38161 CFRunLoopRunInMode + 97
18 GraphicsServices 0x0172e268 GSEventRunModal + 217
19 GraphicsServices 0x0172e32d GSEventRun + 115
20 UIKit 0x0031142e UIApplicationMain + 1160
21 iG2Mobile 0x000022f2 main + 84
22 iG2Mobile 0x00002295 start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
ANY HELP IS GREATLY APPRECIATED. Please let me know if any further details are needed.
I also added below setter method to MachineDetailsView but still no use:
-(void)setBackPickerStartDate:(NSString *)newBackPickerStartDate
{
if (backPickerStartDate != newBackPickerStartDate) {
backPickerStartDate = newBackPickerStartDate;
}
}
Thank you very much
You've stated that you've declared and synthesize the backPickerStartDate property in the MachineDetailsView class, yet you call it on an instance of iMobileAppDelegate in btnSelectClicked:
appDelegate.backPickerStartDate = [formatter stringFromDate:dt];
A few lines above, you have this:
MachineDetailsView *appDelegate;
appDelegate = (MachineDetailsView *)[[UIApplication sharedApplication] delegate];
That's wrong because you cast the pointer to your app delegate to a pointer to MachineDetailsView. That doesn't make your app delegate object magically turn into a MachineDetailsView object. What you need instead is a getter method or property that returns your MachineDetailsView object (or find another way to access it).
[iMobileAppDelegate setBackPickerStartDate:]: unrecognized selector sent to instance
As per the Exception above, you need to declare backPickerStartDate in your app delegate.