EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x00000000bbadbeef crash on UIWebview

1k views Asked by At

Here is my viewDidLoad method:

- (void)viewDidLoad {
    [super viewDidLoad];

    [self setTitle:[self.parameters_ get:@"title"]];
    whiteBGLayer = [[CALayer alloc] init];
    [whiteBGLayer setBackgroundColor:[UIColor whiteColor].CGColor];
    [self.view.layer addSublayer:whiteBGLayer];

    if ([self isWebView]) {
        _webView = [[UIWebView alloc] initWithFrame:CGRectZero];
        _webView.delegate = self;
        _webView.allowsInlineMediaPlayback = YES;
        _webView.mediaPlaybackRequiresUserAction = NO;
        [self  checkWebsiteAuthentication];
        [_webView setTranslatesAutoresizingMaskIntoConstraints:NO];
        NSString *encodedUrlString = [self  toAbsoluteUrlWithNSString:[self.parameters_ get:@"url"]];
        NSURL *url = [NSURL URLWithString:encodedUrlString];
        NSURLRequest *request = [NSURLRequest requestWithURL:url];

        _webView.frame = self.view.frame;
        [_webView loadRequest:request];
        [_webView setScalesPageToFit:YES];
        _webView.scrollView.delegate = self;

        [self.view addSubview:_webView];
        [_webView setTranslatesAutoresizingMaskIntoConstraints:NO];
        [self.view setNeedsUpdateConstraints];
    } else {
        self.view.backgroundColor = [UIColor whiteColor];
        _label = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 320, 40)];
        _label.text = @"content view";
        [self.view addSubview:_label];
    }

    if (someName isEqualToString:@“SomeName”]) {
        UINib *nib = [UINib nibWithNibName:@XYYouTubePlayerContainerView" bundle:nil];
        self.youTubePlayerContainerView = [[nib instantiateWithOwner:self options:nil] objectAtIndex:0];
        self.youTubePlayerContainerView.hidden = YES;
        [self.view addSubview:self.youTubePlayerContainerView];

        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(dismissVideoPlayer)
                                                     name:UIWindowDidBecomeHiddenNotification
                                                   object:nil];
    }  
}

For some reasons it is crashing at this line, as reported by Crashlytics:

_webView = [[UIWebView alloc] initWithFrame:CGRectZero];

Below is the stack-trace of crashed thread:

Thread : Crashed: com.apple.root.utility-qos
0  JavaScriptCore                 0x000000018413c9e4 WTFCrash + 72
1  JavaScriptCore                 0x000000018413c9dc WTFCrash + 64
2  WebCore                        0x0000000190992504 WebRunLoopUnlock(__CFRunLoopObserver*, unsigned long, void*)
3  WebCore                        0x0000000190992dac WebThreadLock + 104
4  UIKit                          0x0000000187449b2c -[UIWebView _webViewCommonInitWithWebView:scalesPageToFit:] + 140
5  UIKit                          0x000000018729dc38 -[UIWebView initWithFrame:] + 88
6  XYZ                           0x00000001002e0b60 -[XYContentViewController viewDidLoad] (XYContentViewController.m:43)
7  UIKit                          0x0000000187074958 -[UIViewController loadViewIfRequired] + 692
8  UIKit                          0x0000000187074668 -[UIViewController view] + 32
9  XYZ                           0x0000000100032620 -[XYModalViewController setViewController:] (XYModalViewController.m:252)
10 XYZ                           0x000000010003279c -[XYModalViewController pushModalController:] (XYModalViewController.m:260)
11 XYZ                           0x0000000100038b14 -[XYViewController presentModalController:] (XYViewController.m:426)
12 XYZ                           0x00000001002fc3d4 __57-[AppDelegate application:didFinishLaunchingWithOptions:]_block_invoke451 (AppDelegate.m:590)
13 XYZ                           0x00000001002fc6c0 __57-[AppDelegate application:didFinishLaunchingWithOptions:]_block_invoke499 (AppDelegate.m:619)
14 Foundation                     0x0000000183672574 -[__NSObserver _doit:] + 320
15 CoreFoundation                 0x000000018280cddc __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
16 CoreFoundation                 0x000000018274b370 _CFXNotificationPost + 2060
17 Foundation                     0x000000018366f520 -[NSNotificationCenter postNotificationName:object:userInfo:] + 72
18 XYZ                           0x0000000100312a50 __44-[XYListingPriceHistoryCell getPriceAlerts:]_block_invoke_2 (XYListingPriceHistoryCell.m:77)
19 libdispatch.dylib              0x0000000193e75994 _dispatch_call_block_and_release + 24
20 libdispatch.dylib              0x0000000193e75954 _dispatch_client_callout + 16
21 libdispatch.dylib              0x0000000193e82780 _dispatch_root_queue_drain + 1848
22 libdispatch.dylib              0x0000000193e83c4c _dispatch_worker_thread3 + 108
23 libsystem_pthread.dylib        0x000000019405522c _pthread_wqthread + 816

I am clueless :-/, please suggest.

0

There are 0 answers