Search code examples
c#macosmonochromium-embedded

CEF for C#/Mono on OS X Crashes on javascript:window.close()


We are building a project that is using the Xilium/CefGlue Mono library, in order to render our user-interface in a Chromium embedded frame. Pages load and display in an NSWindow. JavaScript is executed on the page and on page events.

However, the application crashes with a FATAL message when calling

window.close();

anywhere in the page's JavaScript. Last bit of output prior to the crash is

FATAL:message_pump_mac.mm(765) Check Failed: [NSApp conformsToProtocol:@protocol(CrAppProtocol)]

Is this related? Is there some way we can have NSApp conform to this protocol in C#/Mono?

For more information, here is a similar topic posted in the CEF forum


Solution

  • See this comment in include/cef_application_mac.h:

    // All CEF client applications must subclass NSApplication and implement this
    // protocol.
    @protocol CefAppProtocol<CrAppControlProtocol>
    @end
    

    https://bitbucket.org/chromiumembedded/cef/src/master/include/cef_application_mac.h?at=master#cef_application_mac.h-80