title: Mac OS webview random crash
body: <p>I am allowing the users of my app to login via facebook on mac app. I have loaded the facebook login page on webview, asked users permission, getting the AccessToken/UserDetails from facebook - all fine.
  Except sometimes it crashes when I logout and relogin to the app. I did find placees in my app for potential memory issues, and found nothing. The app crashes at:</p>
  
  <pre><code>*** -[WebCoreThemeWindow _hasActiveAppearanceIgnoringKeyFocus]: message sent to deallocated instance 0x6080001e6400
  </code></pre>
  
  <p>Apparantly the message is passed to the deallocated object. But I can't figure why its being deallocated and what instance it is...</p>
  
  <pre><code>  - 0 : "0   ???                                 0x0000000108cdcb76 0x0 + 4442671990"
    - 1 : "1   MY_APP_NAME                           0x000000010002d760 main + 0"
    - 2 : "2   AppKit                              0x00007fff925eb7ef -[NSButtonCell _preferInactiveBezelArtInView:] + 72"
    - 3 : "3   AppKit                              0x00007fff9263e72b -[NSButtonCell _preferInactiveContentInView:] + 22"
    - 4 : "4   AppKit                              0x00007fff925eb5cf -[NSButtonCell _hasRolloverContentArt] + 76"
    - 5 : "5   AppKit                              0x00007fff925eb541 hasAnyRollover + 183"
    - 6 : "6   AppKit                              0x00007fff925eb2ad -[NSButtonCell _updateMouseTracking] + 140"
    - 7 : "7   AppKit                              0x00007fff925eb0e2 -[NSButtonCell setControlView:] + 59"
    - 8 : "8   AppKit                              0x00007fff9272812d -[NSButtonCell drawWithFrame:inView:] + 193"
    - 9 : "9   WebCore                             0x00007fff9c6adc61 _ZN7WebCore8ThemeMac38drawCellOrFocusRingWithViewIntoContextEP6NSCellRNS_15GraphicsContextERKNS_9FloatRectEP6NSViewbbbf + 561"
    - 10 : "10  WebCore                             0x00007fff9c6b07df _ZN7WebCoreL17paintToggleButtonENS_11ControlPartERNS_13ControlStatesERNS_15GraphicsContextERKNS_9FloatRectEfPNS_10ScrollViewEff + 2847"
    - 11 : "11  WebCore                             0x00007fff9c4658e0 _ZN7WebCore11RenderTheme5paintERKNS_9RenderBoxERNS_13ControlStatesERKNS_9PaintInfoERKNS_10LayoutRectE + 656"
    - 12 : "12  WebCore                             0x00007fff9b78c7a0 _ZN7WebCore9RenderBox19paintBoxDecorationsERNS_9PaintInfoERKNS_11LayoutPointE + 528"
    - 13 : "13  WebCore                             0x00007fff9b789e5b _ZN7WebCore11RenderBlock11paintObjectERNS_9PaintInfoERKNS_11LayoutPointE + 299"
    - 14 : "14  WebCore                             0x00007fff9b78c155 _ZN7WebCore11RenderBlock5paintERNS_9PaintInfoERKNS_11LayoutPointE + 309"
    - 15 : "15  WebCore                             0x00007fff9c3d5065 _ZN7WebCore11RenderLayer27paintBackgroundForFragmentsERKN3WTF6VectorINS_13LayerFragmentELm1ENS1_15CrashOnOverflowELm16EEERNS_15GraphicsContextES9_RKNS_10LayoutRectEbRKNS0_17LayerPaintingInfoEjPNS_12RenderObjectE + 389"
    - 16 : "16  WebCore                             0x00007fff9c3d2214 _ZN7WebCore11RenderLayer18paintLayerContentsERNS_15GraphicsContextERKNS0_17LayerPaintingInfoEj + 2356"
    - 17 : "17  WebCore                             0x00007fff9c3d24b5 _ZN7WebCore11RenderLayer18paintLayerContentsERNS_15GraphicsContextERKNS0_17LayerPaintingInfoEj + 3029"
    - 18 : "18  WebCore                             0x00007fff9c3d24b5 _ZN7WebCore11RenderLayer18paintLayerContentsERNS_15GraphicsContextERKNS0_17LayerPaintingInfoEj + 3029"
    - 19 : "19  WebCore                             0x00007fff9c3cfe47 _ZN7WebCore11RenderLayer5paintERNS_15GraphicsContextERKNS_10LayoutRectERKNS_10LayoutSizeEjPNS_12RenderObjectEj + 263"
    - 20 : "20  WebCore                             0x00007fff9bd16cd2 _ZN7WebCore9FrameView13paintContentsERNS_15GraphicsContextERKNS_7IntRectE + 546"
    - 21 : "21  WebKitLegacy                        0x00007fff9c948f2c -[WebFrame(WebInternal) _drawRect:contentsOnly:] + 268"
    - 22 : "22  WebKitLegacy                        0x00007fff9c948b1c -[WebHTMLView drawSingleRect:] + 316"
    - 23 : "23  WebKitLegacy                        0x00007fff9c948857 -[WebHTMLView drawRect:] + 423"
    - 24 : "24  AppKit                              0x00007fff9272644d -[NSView(NSInternal) _recursive:displayRectIgnoringOpacity:inGraphicsContext:CGContext:topView:shouldChangeFontReferenceColor:] + 1318"
    - 25 : "25  WebKitLegacy                        0x00007fff9c9485db -[WebHTMLView(WebPrivate) _recursive:displayRectIgnoringOpacity:inGraphicsContext:CGContext:topView:shouldChangeFontReferenceColor:] + 251"
    - 26 : "26  AppKit                              0x00007fff92725df4 __46-[NSView(NSLayerKitGlue) drawLayer:inContext:]_block_invoke + 267"
    - 27 : "27  AppKit                              0x00007fff9272591d -[NSView(NSLayerKitGlue) _drawViewBackingLayer:inContext:drawingHandler:] + 1589"
    - 28 : "28  AppKit                              0x00007fff927252e2 -[NSView(NSLayerKitGlue) drawLayer:inContext:] + 80"
    - 29 : "29  WebKitLegacy                        0x00007fff9c94e1f8 -[WebHTMLView(WebInternal) drawLayer:inContext:] + 72"
    - 30 : "30  AppKit                              0x00007fff9285b5bf -[_NSBackingLayerContents drawLayer:inContext:] + 162"
    - 31 : "31  QuartzCore                          0x00007fff9a569fd2 -[CALayer drawInContext:] + 257"
    - 32 : "32  AppKit                              0x00007fff9285b098 -[_NSTiledLayer drawTile:inContext:] + 624"
    - 33 : "33  AppKit                              0x00007fff9285adce -[_NSTiledLayerContents drawLayer:inContext:] + 176"
    - 34 : "34  QuartzCore                          0x00007fff9a569fd2 -[CALayer drawInContext:] + 257"
    - 35 : "35  AppKit                              0x00007fff9285ad15 -[NSTileLayer drawInContext:] + 169"
    - 36 : "36  QuartzCore                          0x00007fff9a44d2ba CABackingStoreUpdate_ + 3726"
    - 37 : "37  QuartzCore                          0x00007fff9a569bcc ___ZN2CA5Layer8display_Ev_block_invoke + 75"
    - 38 : "38  QuartzCore                          0x00007fff9a569846 _ZN2CA5Layer8display_Ev + 1748"
    - 39 : "39  AppKit                              0x00007fff9285ac2c -[NSTileLayer display] + 119"
    - 40 : "40  AppKit                              0x00007fff93025a7b -[_NSTiledLayerContents update:shouldCallPrepareContent:] + 5174"
    - 41 : "41  AppKit                              0x00007fff927dd5de -[_NSTiledLayer display] + 389"
    - 42 : "42  QuartzCore                          0x00007fff9a55d9a6 _ZN2CA5Layer17display_if_neededEPNS_11TransactionE + 572"
    - 43 : "43  QuartzCore                          0x00007fff9a55dad1 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 35"
    - 44 : "44  QuartzCore                          0x00007fff9a5532e8 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280"
    - 45 : "45  QuartzCore                          0x00007fff9a44a5e5 _ZN2CA11Transaction6commitEv + 475"
    - 46 : "46  AppKit                              0x00007fff929ec1cd __37+[NSDisplayCycle currentDisplayCycle]_block_invoke.31 + 323"
    - 47 : "47  CoreFoundation                      0x00007fff9494ff67 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23"
    - 48 : "48  CoreFoundation                      0x00007fff9494fed7 __CFRunLoopDoObservers + 391"
    - 49 : "49  CoreFoundation                      0x00007fff94930b79 __CFRunLoopRun + 873"
    - 50 : "50  CoreFoundation                      0x00007fff949305b4 CFRunLoopRunSpecific + 420"
    - 51 : "51  HIToolbox                           0x00007fff93ed1f6c RunCurrentEventLoopInMode + 240"
    - 52 : "52  HIToolbox                           0x00007fff93ed1da1 ReceiveNextEventCommon + 432"
    - 53 : "53  HIToolbox                           0x00007fff93ed1bd6 _BlockUntilNextEventMatchingListInModeWithFilter + 71"
    - 54 : "54  AppKit                              0x00007fff925c85f5 _DPSNextEvent + 1093"
    - 55 : "55  AppKit                              0x00007fff92cd88eb -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1637"
    - 56 : "56  AppKit                              0x00007fff925bcfbd -[NSApplication run] + 926"
    - 57 : "57  AppKit                              0x00007fff92587a8a NSApplicationMain + 1237"
    - 58 : "58  MY_APP_NAME                           0x000000010002d7b4 main + 84"
    - 59 : "59  libdyld.dylib                       0x00007fffa9970255 start + 1"
    - 60 : "60  ???                                 0x0000000000000003 0x0 + 3"
  </code></pre>
  
  <p>Is that possible its webview's internal crash? I think this has nothing to do with facebook. The crash does not happen all the times. Its random (once in ~three trial).</p>
  
  <p>Any help/clue is most welcome.</p>
  
  <p><strong>Edit:</strong> Solution: Was using old WebView, now using WKWebView. WORKIING FINE. At least we should get some warning while debugging to use WKWebView.</p>