[webkit-help] [WebKitGTK] Issue with web process extensions

Alain Bareille abareille at witekio.com
Thu Oct 31 08:36:53 PDT 2024


For those that come after me, let it be known a solution is to be found
here:
https://discourse.gnome.org/t/webkitgtk-web-process-extension-not-loading/24809

On 29/10/2024 13:13, Alain Bareille wrote:
> Hello,
>
> I'm on Ubuntu Linux 24.04 Noble Numbat, with the following packages
> installed:
>
> - libwebkitgtk-6.0-4 2.46.1-0ubuntu0.24.04.1 amd64
> - libwebkitgtk-6.0-dev 2.46.1-0ubuntu0.24.04.1 amd64
>
> I'm trying to enable web process extensions in a mostly C++ written
> application. I've spent some hours going through the documentation and
> searching over the internet for a solution, but I don't find any issue
> with my code (although, I may be overlooking a small detail).
>
> Below, there's a minimal reproducing sample. Is anything wrong with my
> code? If not, how should I proceed to figure out where the issue is?
>
> Based on the code below, here's a few things I've tried already:
> - moving the libextension.so file to another path than ./ or
> specifying an absolute path to
> webkit_web_context_set_web_process_extensions_directory.
> - writing a tool using GModule that loads libextension.so and checks
> webkit_web_process_extension_initialize symbol can be reached with
> g_module_symbol().
> - running inside gdb and placing a breakpoint on
> WebKit::WebProcessExtensionManager::initialize from
> Source/WebKit/WebProcess/InjectedBundle/API/glib/WebProcessExtensionManager.cpp.
> That breakpoint is never triggered.
>
> =========== CMakeLists.txt
>
> cmake_minimum_required(VERSION 3.28.3)
>
> project(
>     IssueSample
>     VERSION 1.0.0
>     LANGUAGES C CXX)
>
> find_package(PkgConfig REQUIRED)
> pkg_check_modules(WebkitGTK REQUIRED IMPORTED_TARGET glib-2.0>=2.74
> gtk4>=4.14.2 webkitgtk-6.0)
>
> add_executable(browser main.cpp)
> target_link_libraries(browser PkgConfig::WebkitGTK)
>
> add_library(extension MODULE extension.c)
> target_link_libraries(extension PkgConfig::WebkitGTK)
>
> =========== extension.c
>
> #include <gtk/gtk.h>
> #include <webkit/webkit-web-process-extension.h>
>
> #ifdef __cplusplus
> #error Must be compiled as C
> #endif
>
> static void web_page_created_cb(WebKitWebProcessExtension *extension,
> WebKitWebPage *web_page, gpointer /* unused */)
> {
>     g_print("Page %ld created for %s with table\n",
> webkit_web_page_get_id(web_page),
>         webkit_web_page_get_uri(web_page));
> }
>
> G_MODULE_EXPORT void
> webkit_web_process_extension_initialize(WebKitWebProcessExtension
> *extension)
> {
>     g_print("Inside webkit_web_extension_initialize %p\n", extension);
>     g_signal_connect(extension, "page-created",
> G_CALLBACK(web_page_created_cb), NULL);
> }
>
> =========== main.cpp
>
> #include <gtk/gtk.h>
> #include <webkit/webkit.h>
>
> void initialize_web_extensions(WebKitWebContext *context, gpointer
> /*unused*/)
> {
>     webkit_web_context_set_web_process_extensions_directory(context,
> "./");
> }
>
> int main()
> {
>     gtk_init();
>
>     g_signal_connect(webkit_web_context_get_default(),
> "initialize-web-process-extensions",
>         G_CALLBACK(initialize_web_extensions), NULL);
>
>     GtkWindow * window = GTK_WINDOW(gtk_window_new());
>
>     WebKitWebView * web_view = WEBKIT_WEB_VIEW(webkit_web_view_new());
>
>     webkit_web_view_load_uri(web_view, "https://linux.org/");
>
>     gtk_window_set_child(window, GTK_WIDGET(web_view));
>
>     gtk_window_present(window);
>
>     while (g_list_model_get_n_items(gtk_window_get_toplevels()) > 0)
>     {
>         g_main_context_iteration(NULL, TRUE);
>     }
> }
>
> ===========
>
>
>

Witekio France is an SAS company registered in Lyon. Registered office: 14 rue Rhin et Danube - 69009 Lyon. Registered company number: RCS 518 864 012 00035. VAT number FR 68 518 864 012
This message contains confidential information and is intended only for the individual(s) addressed in the message. If you aren't the named addressee, you should not disseminate, distribute, or copy this e-mail.

We continuously commit to comply with the applicable data protection laws and ensure fair and transparent processing of your personal data. Please read our privacy statement including an information notice and data protection policy for detailed information on our website.


More information about the webkit-help mailing list