Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempting to create multiple WebViews crashes the program (on Mac OS only?) #77

Open
rdw-software opened this issue Feb 27, 2023 · 4 comments

Comments

@rdw-software
Copy link
Member

rdw-software commented Feb 27, 2023

This seems to be a limitation of the upstream library:

local webview = require("webview")

local view = webview.bindings.webview_create(true, nil)
print("First WebView created")

local view = webview.bindings.webview_create(true, nil)
print("Second WebView created")

local childview = webview.bindings.webview_create(true, webview.bindings.webview_get_window(view))
print("Child created")

Crashes with SEGFAULT on Mac OS. Fails with GTK warning in WSL?

(evo:262): Gtk-WARNING **: 15:27:22.020: Attempting to add a widget with type WebKitWebView to a GtkWindow, but as a GtkBin subclass a GtkWindow can only contain one widget at a time; it already contains a widget of type WebKitWebView

@rdw-software
Copy link
Member Author

rdw-software commented Feb 28, 2023

A few theories observations:

  • The webview library uses hardcoded names for the webview config object, and recreates the app delegate for every instance
  • Now, the Objective C runtime seems to crash when trying to create a second app delegate with the same name
  • I was able to avoid this by checking for nullptr and exiting cleanly, which of course doesn't solve the real problem
  • ... which is that there should be just one app delegate for each app, and it should handle all instances on its own
  • It may be required to create a separate config object for each instance of cocoa_webkit_engine as well?

Not sure if that will help. Also need to test more on Windows/Linux, but that's left for later since OSX is the bigger problem.

@rdw-software
Copy link
Member Author

I guess for the time being webviews can be limited to one instance per app, even if it's not ideal. But the SEGFAULT needs to go.

rdw-software added a commit that referenced this issue May 5, 2023
This needs to be fixed properly so that we can create multiple webviews and destroy them at will, without SEGFAULT on OSX.

Right now we can't, and I don't particularly feel like digging through the arcane Objective C code in webview itself, so this will have to do. It's tracked via #77 so the info won't get lost.
rdw-software added a commit that referenced this issue May 5, 2023
This needs to be fixed properly so that we can create multiple webviews and destroy them at will, without SEGFAULT on OSX.

Right now we can't, and I don't particularly feel like digging through the arcane Objective C code in webview itself, so this will have to do. It's tracked via #77 so the info won't get lost.
@rdw-software
Copy link
Member Author

As shown by the SEGFAULT in #155, the problem is even more severe: There can't just be a single WebView that's currently active, but creating any view after the first seems to instantly crash the runtime. That makes it quite annoying to test, and it also means that no long-running program can create more than a single, global/shared view without crashing.

Unfortunately, fixing this would mean replacing a lot of the OSX specific code in the webview library. Is there an easy way out?

@rdw-software
Copy link
Member Author

Waiting for #201 to be completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Soon™
Development

No branches or pull requests

1 participant