Boscop / web-view

Rust bindings for webview, a tiny cross-platform library to render web-based GUIs for desktop applications
MIT License
1.93k stars 176 forks source link

Webview on Mac does not work with multiple windows #116

Open carbotaniuman opened 4 years ago

carbotaniuman commented 4 years ago

Opening for tracking as we just hit this. 90% sure someone has already worked on or fixed this.

carbotaniuman commented 4 years ago
  Class __WKScriptMessageHandler = objc_allocateClassPair(
      objc_getClass("NSObject"), "__WKScriptMessageHandler", 0);
  class_addMethod(
      __WKScriptMessageHandler,
      sel_registerName("userContentController:didReceiveScriptMessage:"),
      (IMP)webview_external_invoke, "v@:@@");
  objc_registerClassPair(__WKScriptMessageHandler);

These lines are responsible for the segmentation fault when opening multiple windows. objc_allocateClassPair can return NULL if the class is already registered, and I'm wondering what this code does and whether it works with multiple windows.