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

Eval not working for users without libwebkit2gtk-4.0-dev installed #53

Open
LVCarnevalli opened this issue Aug 29, 2024 · 4 comments
Open

Comments

@LVCarnevalli
Copy link

Good afternoon,

In my development environment, where I have the dev packages installed, I can successfully compile, and the application works as expected. However, when I distribute it in production, I noticed that for users who only have libwebkit2gtk-4.0.37 installed, the JavaScript Eval function is not working. If I install libwebkit2gtk-4.0-dev, it starts working, but I would prefer not to have to install the dev version.

Could someone help me with this issue? Thanks.

@SteffenL
Copy link
Contributor

Are the users who experience issues with (only) libwebkit2gtk-4.0.37 installed the same users whose issues are resolved by installing libwebkit2gtk-4.0-dev? Not sure if it would make a difference but are you certain that they don't also have WebKitGTK API 4.1 installed at the same time?

The core webview library has recently added support for WebKitGTK API 6.0 but at the same time 4.0 and 4.1 have to be compiled separately to avoid the work involved with supporting them all in a single compiled library. Maybe the latest core library will resolve the issue, but at the same time there's a problem with Go/CGo and how GTK and WebKitGTK versions are hardcoded in the Go bindings. It's a problem because newer Linux distros dropped support for WebKitGTK API 4.0, and old distros may not have anything more recent than 4.0.

I'm not personally a Go developer and I've been having a hard time figuring out how to solve this seamlessly, and I'm not 100% sure how to go forward with the Go bindings.

@LVCarnevalli
Copy link
Author

Hello @SteffenL , thank you for your response. Yesterday, I spent quite some time testing to identify what the dev version was installing that made it work. I discovered that it was the symbolic link from libwebkit2gtk-4.0.so to libwebkit2gtk-4.0.so.37. The Ubuntu version without the dev package installed didn't have this symbolic link, so Eval wasn't working.

This version of Ubuntu 22 didn't have version 4.1, only 4.0-37. I downloaded a VM with image 22.04 to test

I don't know much about C, but I made a change, and it started working:

libs/webview/include/webview.h
line 1418

constexpr std::array<const char *, 3> lib_names{"libwebkit2gtk-4.1.so","libwebkit2gtk-4.0.so","libwebkit2gtk-4.0.so.37"};

Am I on the right track?

@SteffenL
Copy link
Contributor

I'm trying something else in the Go binding. Here's what I have so far.

mkdir webview_go_experiment
cd webview_go_experiment

git clone --branch update-core https://github.com/SteffenL/webview_go.git
git clone --branch experiment https://github.com/SteffenL/webview-go-example.git

cd webview-go-example

go build -tags webview.backend.gtk4_webkitgtk600 -o bind_gtk4_webkitgtk600 ./bind/main.go
go build -tags webview.backend.gtk3_webkitgtk401 -o bind_gtk3_webkitgtk401 ./bind/main.go
go build -tags webview.backend.gtk3_webkitgtk400 -o bind_gtk3_webkitgtk400 ./bind/main.go

This uses build tags and constraints in the Go binding to selectively compile the backend. So here you can build 3 different programs using:

  • GTK 3 / WebKitGTK API 4.0
  • GTK 3 / WebKitGTK API 4.1
  • GTK 4 / WebKitGTK API 6.0

It's some sort of progress but I don't want to specify a build tag every time on the command line.

@ImGarlic
Copy link

@SteffenL I was actually planning on doing something similar with the build tags - do you plan on continuing that work?

You can create a "default" binding file that just excludes all the build tags for the case that you don't want to specify it, but I will admit it's a little messy:

// +build !webview.backend.gtk3_webkitgtk400 !webview.backend.gtk3_webkitgtk401 !webview.backend.gtk4_webkitgtk600 !webview.backend.cocoa_webkit !webview.backend.win32_edge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants