OSX 10.10.3 WebView crash on dealloc

After upgrading to 10.10.3 WebView component started crashing after dealloc

- (void)dealloc {
    [self.webView.windowScriptObject setValue:nil forKey:@"CocoaApp"];
    [[self.webView mainFrame] stopLoading];
    [self.webView setUIDelegate:nil];
    [self.webView setEditingDelegate:nil];
    [self.webView setFrameLoadDelegate:nil];
    [self.webView setPolicyDelegate:nil];
    [self.webView removeFromSuperview];
}

      

The crash is happening somewhere deep in the WebView

EXC_BAD_ACCESS

1   0x7fff910bae9e WebDocumentLoaderMac::detachFromFrame()
2   0x7fff920288c0 WebCore::FrameLoader::detachFromParent()
3   0x7fff910d0e55 -[WebView(WebPrivate) _close]
4   0x7fff910d0c49 -[WebView dealloc]
5   0x7fff8b1cf89c objc_object::sidetable_release(bool)
6   0x7fff8b1b5e8f (anonymous namespace)::AutoreleasePoolPage::pop(void*)
7   0x7fff912b26f2 _CFAutoreleasePoolPop
8   0x7fff8830e762 -[NSAutoreleasePool drain]
9   0x7fff8e3f0cc1 -[NSApplication run]
10  0x7fff8e36d354 NSApplicationMain
11  0x1000ebb12 main
12  0x7fff8c81e5c9 start
13  0x3

      

Any ideas? Is this an Apple bug? Did it start AFTER 10.10.3?

It doesn't crash when NSZombie is on!

+3


source to share


2 answers


I noticed that you are using your own policy delegate:

[self.webView setPolicyDelegate:nil];

      

There is a known bug related to policy delegates in WebKit (only recently fixed):

https://bugs.webkit.org/show_bug.cgi?id=144975



The short version is that you are probably pushing this statement (which causes the process to crash with an intentional segfault):

https://github.com/WebKit/webkit/blob/24b1ae89efc10a4e6a6057b429c8e1d8d138a32f/Source/WebCore/loader/DocumentLoader.cpp#L935

because your policy handler (i.e. decidePolicyForMIMEType:request:frame:decisionListener:

) is not executing a policy decision (i.e. use

, ignore

or download

). The solution hangs around unmade, and when the bootloader eventually shuts down, it claims there is no pending policy decision that fails as the view is still waiting for a decision.

+1


source


The fix I did was not to free up the webview, but to insert a static link into it (this is far from a solution and I contacted Apple about this issue)



#warning HOTFIX
{
    //this is because of http://stackoverflow.com/questions/29746074/osx-10-10-3-crashes-webview-on-dealloc
    static NSMutableArray * LIVE_FOR_EVER_WEBVIEW;

    if (LIVE_FOR_EVER_WEBVIEW == nil) {
        LIVE_FOR_EVER_WEBVIEW = [NSMutableArray new];
    }
    if (self.webView) {
        [LIVE_FOR_EVER_WEBVIEW addObject:self.webView];
    }
}

      

0


source







All Articles