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

GTK4 support? #94

Open
ghost opened this issue Jul 18, 2021 · 16 comments
Open

GTK4 support? #94

ghost opened this issue Jul 18, 2021 · 16 comments

Comments

@ghost
Copy link

ghost commented Jul 18, 2021

This blog post has got me wanting to port my WebKit-powered browser project over to GTK4-rs, as I'm seeking to replacing my implementation of tabs with the Libadwaita widget. This would accomplish two things for me: it removes the burden on me to solely develop & maintain a major component of my project, and it would additionally allow my project to match the design guidelines that other GTK projects follow.

As of present, I'm unable to make this switch to GTK4 + Libadwaita. I've:

  1. Updated the dependencies to rely on the latest GTK4-rs crate versions (as libadwaita-rs uses release numbers and not Git for its dependencies)
  2. Updated the GIR files locally (remember to do this yourself if you're checking out my current progress)
  3. Regenerated the bindings (using make gir)

However, I still encounter 6 build errors within webkit2gtk-sys, which reflect the following errors given by GIR:

[WARN  libgir::parser] <boxed name=Some("ByteArray")>
[ERROR libgir::analysis::record] Missing memory management functions for Gdk.EventKey
[ERROR libgir::analysis::record] Missing memory management functions for JavaScriptCore.ValueRef
[WARN  libgir::analysis::trampolines] Can't generate WebKit2.BackForwardList trampoline for signal 'changed'
[WARN  libgir::analysis::functions] Function webkit_input_method_context_get_preedit has unsupported outs

Specifically, webkit2gtk-rs is currently expecting GdkEventKey, GtkContainerClass, GtkContainer, and GtkAction to still exist.

During my work on getting this repository building again (see: #89), I became a little familiar with how this all works, but I must admit there's still a lot I don't know. I'm not good with Rust or C (hell, software development in general), I'm not familiar with the technical work being done in the GTK/GNOME world, nor am I familiar with the goings on with GTK-rs, so I'm sorry I can't work on this myself. I wish I had the knowledge and ability to contribute directly instead of just opening a GitHub issue.

@antoyo
Copy link
Contributor

antoyo commented Jul 18, 2021

I'm not sure whether webkit2gtk has a release supporting gtk4, you might have to build it with some cli options as specified here.

@jangernert
Copy link
Contributor

I have a super hacky branch for Gtk4 here: https://github.com/jangernert/webkit2gtk-rs/tree/gtk4

Just enough for me to port my application to Gtk4.
For this to work you still need to compile webkitgtk with the Gtk4 platform support and libsoup3 yourself. I am not aware of any binary packages for these two libraries at the moment.

@ghost
Copy link
Author

ghost commented Jul 20, 2021

@jangernert, would it be beneficial to move your branch over to the main webkit2gtk-rs repository? I'm thinking it would lead to increased development and attention. I'd like to know your thoughts.

Additionally, for those finding this GitHub issue, I've written a script to build & install WebKitGTK with GTK4 support (webkit2gtk-5.0):

#!/bin/bash

# Cleanup
rm -rf ./gtk4-dependencies
mkdir gtk4-dependencies && cd gtk4-dependencies

# GLib
git clone --depth 1 --recurse-submodules --shallow-submodules https://gitlab.gnome.org/GNOME/glib.git
cd ./glib
meson _build && ninja -C _build
sudo ninja -C _build install
cd ../

# glib-networking
git clone --depth 1 --recurse-submodules --shallow-submodules https://gitlab.gnome.org/GNOME/glib-networking.git
cd ./glib-networking
mkdir build && cd build
meson --prefix=/usr --buildtype=release .. && ninja
sudo ninja install
cd ../../

# libsoup 3
git clone --depth 1 --recurse-submodules --shallow-submodules https://gitlab.gnome.org/GNOME/libsoup.git
cd ./libsoup
mkdir build && cd build
meson --prefix=/usr --buildtype=release .. && ninja
sudo ninja install
cd ../../

# WebKitGTK 5.0
git clone --depth 1 --recurse-submodules --shallow-submodules https://github.com/WebKit/WebKit.git
cd ./WebKit
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_SKIP_RPATH=ON -DPORT=GTK \
-DLIB_INSTALL_DIR=/usr/lib \
-DUSE_GTK4=ON \
-DUSE_AVIF=ON \
-GNinja .. && ninja
sudo ninja install
cd ../../

@jangernert
Copy link
Contributor

I don't see any reason for that. It's just as easy to reference the fork in your cargo.toml. And once webkitgtk 5.0 is released and packaged I would start generating bindings from scratch. I manually copied and patched the .gir-files and then manually patched the generated bindings to get things working quick & dirty.

@ghost
Copy link
Author

ghost commented Jul 25, 2021

I've since encountered two issues which I suspect are upstream:

  1. WebView content being near-invisible
  2. HTTPS connections failing (resolved by adding glib-networking to the dependency build process, as suggested by Michael Catanzaro)

I've filed a bug report in the WebKit Bugzilla: https://bugs.webkit.org/show_bug.cgi?id=228268

@ergpopler
Copy link

Well, this is weird. Epiphany uses Gtk4, what exactly is stopping webkit2gtk-rs?

@ghost
Copy link
Author

ghost commented Aug 31, 2021

@ergpopler: Well, this is weird. Epiphany uses Gtk4, what exactly is stopping webkit2gtk-rs?

Epiphany does not use GTK4. It uses GTK3 with libhandy. It does appear that WebKitGTK 5.0 (WebKit for GTK 4) cannot render properly on Nvidia GPUs.

@ghost
Copy link
Author

ghost commented Dec 3, 2021

@jangernert I've been unable to get your branch working with my project as of recent, and would appreciate some quick assistance.

I've been compiling libsoup3 and WebKitGTK 5.0 (with the USE_GTK4 compilation flag), as I did in the past, but nowadays I get the following error when attempting to run my program:
libsoup-ERROR **: libsoup2 symbols detected. Using libsoup2 and libsoup3 in the same process is not supported.

I encounter the same exact error when using the libsoup3 and webkit2gtk-5.0 Arch Linux packages (as opposed to compiling them myself).

I do have libsoup2 and libsoup3 co-existing on my Arch Linux system. Could this be the source of the issue? Any thoughts on how I can fix this, short of uninstalling libsoup2?

@jangernert
Copy link
Contributor

jangernert commented Dec 3, 2021

You should try the official WIP bindings: https://gitlab.gnome.org/World/Rust/webkit2gtk5-rs

You'll need to use the Gtk-Bindings from git as well.

@grantshandy
Copy link

grantshandy commented Apr 3, 2023

It appears WebKit2Gtk now supports GTK-4 bindings in its new stable release:

https://webkitgtk.org/2023/03/17/webkitgtk2.40.0-released.html

Of course, this release was only a week or two ago, so it'll be a while until this version is available on most "scheduled-release" distros (debian, ubuntu, etc.).

Regardless, I think this is an issue to keep a look out for 👀

@ttys3
Copy link

ttys3 commented Apr 6, 2023

for tauri, becuase it depends on https://github.com/tauri-apps/libappindicator-rs , which depends on libayatana, and libayatana only support gtk3 (see AyatanaIndicators/libayatana-appindicator#22 ).

I do not think it can upgrade to gtk4 for the current.

@jeena
Copy link

jeena commented May 12, 2023

Just for my understanding, does this mean that there is no way to use webkit2gtk in rust with gtk4 right now and for the foreseeable future?

@jangernert
Copy link
Contributor

@jeena there is no webkit2gtk anymore. The new API is called webkitgtk-6.0 and there are rust bindings here: https://gitlab.gnome.org/World/Rust/webkit6-rs

@JoaquinDecima
Copy link

Currently I need to use GTK to be able to add some functions such as getting the desktop icons in GNU Linux and some other things... As far as I can see, gtk-rs cannot be used yet because of this it is pointing to gtk4 and tauri does not. supports. I reconsidered supporting it, I saw the thread and I understand that due to dependencies it is still not possible, is this so?

@amrbashir
Copy link
Member

the only blocking dependency afaik, is libappindicator but we might move away soon to ksni (KStatusNotifierItem), see tauri-apps/tauri#11293. If and once that lands, we can migrate to gtk4 in tauri@v3

@hjmallon
Copy link

Relevant issue from the recent migration to libwebkitgtk-4.1 (tauri-apps/tauri#9662)

Without a build time option (to select older API levels) moving to libwebkitgtk-6.0.so and gtk4 would require

  • Ubuntu 23.04+
  • Fedora 37+

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

9 participants