From c910add8a67c7b1956ef310eb383b5b447e8d572 Mon Sep 17 00:00:00 2001 From: Raymond Zhao Date: Wed, 4 May 2022 14:45:58 -0700 Subject: [PATCH 1/7] refactor: use stubs for gdk-pixbuf dependency --- BUILD.gn | 16 ++++++++++++---- shell/browser/ui/electron_gdk_pixbuf.fragment | 1 + shell/browser/ui/electron_gdk_pixbuf.sigs | 3 +++ 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 shell/browser/ui/electron_gdk_pixbuf.fragment create mode 100644 shell/browser/ui/electron_gdk_pixbuf.sigs diff --git a/BUILD.gn b/BUILD.gn index 9b62fb12029d4..48b367429be44 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -50,10 +50,7 @@ if (is_linux) { } pkg_config("libnotify_config") { - packages = [ - "glib-2.0", - "gdk-pixbuf-2.0", - ] + packages = [ "glib-2.0" ] } generate_library_loader("libnotify_loader") { @@ -94,6 +91,15 @@ if (is_linux) { logging_function = "LogNoop()" logging_include = "ui/gtk/log_noop.h" } + + generate_stubs("electron_gdk_pixbuf_stubs") { + sigs = [ "shell/browser/ui/electron_gdk_pixbuf.sigs" ] + extra_header = "shell/browser/ui/electron_gdk_pixbuf.fragment" + output_name = "electron_gdk_pixbuf_stubs" + public_deps = [ "//ui/gtk:gdk_pixbuf_config" ] + logging_function = "LogNoop()" + logging_include = "ui/gtk/log_noop.h" + } } declare_args() { @@ -490,6 +496,7 @@ source_set("electron_lib") { if (is_linux) { deps += [ "//components/crash/content/browser", + "//ui/gtk:gdk_pixbuf_config", "//ui/gtk:gtk_config", ] } @@ -553,6 +560,7 @@ source_set("electron_lib") { if (is_linux) { libs = [ "xshmfence" ] deps += [ + ":electron_gdk_pixbuf_stubs", ":electron_gtk_stubs", ":libnotify_loader", "//build/config/linux/gtk", diff --git a/shell/browser/ui/electron_gdk_pixbuf.fragment b/shell/browser/ui/electron_gdk_pixbuf.fragment new file mode 100644 index 0000000000000..bc16bc088ef23 --- /dev/null +++ b/shell/browser/ui/electron_gdk_pixbuf.fragment @@ -0,0 +1 @@ +#include diff --git a/shell/browser/ui/electron_gdk_pixbuf.sigs b/shell/browser/ui/electron_gdk_pixbuf.sigs new file mode 100644 index 0000000000000..ae7ed9ed7a4bb --- /dev/null +++ b/shell/browser/ui/electron_gdk_pixbuf.sigs @@ -0,0 +1,3 @@ +GdkPixbuf* gdk_pixbuf_new(GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample, int width, int height) +GdkPixbuf* gdk_pixbuf_scale_simple(const GdkPixbuf* src, int dest_width, int dest_height, GdkInterpType interp_type) +guchar* gdk_pixbuf_get_pixels(const GdkPixbuf* pixbuf) From b265c180264626b938de144d393fe915b764ba4b Mon Sep 17 00:00:00 2001 From: Raymond Zhao Date: Thu, 5 May 2022 09:54:25 -0700 Subject: [PATCH 2/7] Adjust build file --- BUILD.gn | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 48b367429be44..2e538b9afe4a6 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -96,7 +96,7 @@ if (is_linux) { sigs = [ "shell/browser/ui/electron_gdk_pixbuf.sigs" ] extra_header = "shell/browser/ui/electron_gdk_pixbuf.fragment" output_name = "electron_gdk_pixbuf_stubs" - public_deps = [ "//ui/gtk:gdk_pixbuf_config" ] + public_deps = [ "//ui/gtk:gtk_config" ] logging_function = "LogNoop()" logging_include = "ui/gtk/log_noop.h" } @@ -496,7 +496,6 @@ source_set("electron_lib") { if (is_linux) { deps += [ "//components/crash/content/browser", - "//ui/gtk:gdk_pixbuf_config", "//ui/gtk:gtk_config", ] } From 8db831583be953c010d874227aa8f118c0f43740 Mon Sep 17 00:00:00 2001 From: Raymond Zhao Date: Thu, 5 May 2022 13:47:59 -0700 Subject: [PATCH 3/7] Add includes --- BUILD.gn | 5 ++++- shell/browser/ui/gtk_util.cc | 1 + shell/browser/ui/message_box_gtk.cc | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/BUILD.gn b/BUILD.gn index 2e538b9afe4a6..80150f8c1cb44 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -50,7 +50,10 @@ if (is_linux) { } pkg_config("libnotify_config") { - packages = [ "glib-2.0" ] + packages = [ + "glib-2.0", + "gdk-pixbuf-2.0", + ] } generate_library_loader("libnotify_loader") { diff --git a/shell/browser/ui/gtk_util.cc b/shell/browser/ui/gtk_util.cc index 3d279485cf505..3b8db6c20fd94 100644 --- a/shell/browser/ui/gtk_util.cc +++ b/shell/browser/ui/gtk_util.cc @@ -12,6 +12,7 @@ #include "base/no_destructor.h" #include "base/strings/string_number_conversions.h" +#include "electron/electron_gdk_pixbuf_stubs.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkUnPreMultiply.h" diff --git a/shell/browser/ui/message_box_gtk.cc b/shell/browser/ui/message_box_gtk.cc index 3efc453fc97bd..95b45c23ab9dd 100644 --- a/shell/browser/ui/message_box_gtk.cc +++ b/shell/browser/ui/message_box_gtk.cc @@ -11,6 +11,7 @@ #include "base/no_destructor.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" +#include "electron/electron_gdk_pixbuf_stubs.h" #include "shell/browser/browser.h" #include "shell/browser/native_window_observer.h" #include "shell/browser/native_window_views.h" From 6ae52e89dc0a7fce667595081ffc1897797d71d6 Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Mon, 13 Jun 2022 22:09:21 +0000 Subject: [PATCH 4/7] Merge gdk_pixbuf stubs into gtk stubs --- BUILD.gn | 10 ---------- shell/browser/ui/electron_gdk_pixbuf.fragment | 1 - shell/browser/ui/electron_gdk_pixbuf.sigs | 3 --- shell/browser/ui/electron_gtk.fragment | 3 ++- shell/browser/ui/electron_gtk.sigs | 5 ++++- shell/browser/ui/gtk_util.cc | 2 +- shell/browser/ui/message_box_gtk.cc | 2 +- 7 files changed, 8 insertions(+), 18 deletions(-) delete mode 100644 shell/browser/ui/electron_gdk_pixbuf.fragment delete mode 100644 shell/browser/ui/electron_gdk_pixbuf.sigs diff --git a/BUILD.gn b/BUILD.gn index 80150f8c1cb44..9b62fb12029d4 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -94,15 +94,6 @@ if (is_linux) { logging_function = "LogNoop()" logging_include = "ui/gtk/log_noop.h" } - - generate_stubs("electron_gdk_pixbuf_stubs") { - sigs = [ "shell/browser/ui/electron_gdk_pixbuf.sigs" ] - extra_header = "shell/browser/ui/electron_gdk_pixbuf.fragment" - output_name = "electron_gdk_pixbuf_stubs" - public_deps = [ "//ui/gtk:gtk_config" ] - logging_function = "LogNoop()" - logging_include = "ui/gtk/log_noop.h" - } } declare_args() { @@ -562,7 +553,6 @@ source_set("electron_lib") { if (is_linux) { libs = [ "xshmfence" ] deps += [ - ":electron_gdk_pixbuf_stubs", ":electron_gtk_stubs", ":libnotify_loader", "//build/config/linux/gtk", diff --git a/shell/browser/ui/electron_gdk_pixbuf.fragment b/shell/browser/ui/electron_gdk_pixbuf.fragment deleted file mode 100644 index bc16bc088ef23..0000000000000 --- a/shell/browser/ui/electron_gdk_pixbuf.fragment +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/shell/browser/ui/electron_gdk_pixbuf.sigs b/shell/browser/ui/electron_gdk_pixbuf.sigs deleted file mode 100644 index ae7ed9ed7a4bb..0000000000000 --- a/shell/browser/ui/electron_gdk_pixbuf.sigs +++ /dev/null @@ -1,3 +0,0 @@ -GdkPixbuf* gdk_pixbuf_new(GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample, int width, int height) -GdkPixbuf* gdk_pixbuf_scale_simple(const GdkPixbuf* src, int dest_width, int dest_height, GdkInterpType interp_type) -guchar* gdk_pixbuf_get_pixels(const GdkPixbuf* pixbuf) diff --git a/shell/browser/ui/electron_gtk.fragment b/shell/browser/ui/electron_gtk.fragment index 74a31b23585ac..677c382087029 100644 --- a/shell/browser/ui/electron_gtk.fragment +++ b/shell/browser/ui/electron_gtk.fragment @@ -1 +1,2 @@ -#include \ No newline at end of file +#include +#include diff --git a/shell/browser/ui/electron_gtk.sigs b/shell/browser/ui/electron_gtk.sigs index 451fc74a953d6..7669df87d90ee 100644 --- a/shell/browser/ui/electron_gtk.sigs +++ b/shell/browser/ui/electron_gtk.sigs @@ -4,4 +4,7 @@ void gtk_native_dialog_show(GtkNativeDialog* self); void gtk_native_dialog_hide(GtkNativeDialog* self); gint gtk_native_dialog_run(GtkNativeDialog* self); void gtk_native_dialog_destroy(GtkNativeDialog* self); -GType gtk_native_dialog_get_type(void); \ No newline at end of file +GType gtk_native_dialog_get_type(void); +GdkPixbuf* gdk_pixbuf_new(GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample, int width, int height) +GdkPixbuf* gdk_pixbuf_scale_simple(const GdkPixbuf* src, int dest_width, int dest_height, GdkInterpType interp_type) +guchar* gdk_pixbuf_get_pixels(const GdkPixbuf* pixbuf) diff --git a/shell/browser/ui/gtk_util.cc b/shell/browser/ui/gtk_util.cc index 3b8db6c20fd94..7fc6154bf99f3 100644 --- a/shell/browser/ui/gtk_util.cc +++ b/shell/browser/ui/gtk_util.cc @@ -12,7 +12,7 @@ #include "base/no_destructor.h" #include "base/strings/string_number_conversions.h" -#include "electron/electron_gdk_pixbuf_stubs.h" +#include "electron/electron_gtk_stubs.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkUnPreMultiply.h" diff --git a/shell/browser/ui/message_box_gtk.cc b/shell/browser/ui/message_box_gtk.cc index 95b45c23ab9dd..6266dad29ef51 100644 --- a/shell/browser/ui/message_box_gtk.cc +++ b/shell/browser/ui/message_box_gtk.cc @@ -11,7 +11,7 @@ #include "base/no_destructor.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" -#include "electron/electron_gdk_pixbuf_stubs.h" +#include "electron/electron_gtk_stubs.h" #include "shell/browser/browser.h" #include "shell/browser/native_window_observer.h" #include "shell/browser/native_window_views.h" From 6f92aeb14dc5c38d17387c57adfbe1b94e0542a7 Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Tue, 14 Jun 2022 11:20:37 -0700 Subject: [PATCH 5/7] Split pixbuf sigs into own file again --- BUILD.gn | 5 ++++- shell/browser/ui/electron_gdk_pixbuf.sigs | 3 +++ shell/browser/ui/electron_gtk.sigs | 3 --- 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 shell/browser/ui/electron_gdk_pixbuf.sigs diff --git a/BUILD.gn b/BUILD.gn index 9b62fb12029d4..f1ac729440b24 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -87,7 +87,10 @@ if (is_linux) { # implementation. In future, this file can be extended to contain # gtk4 stubs to switch gtk version in runtime. generate_stubs("electron_gtk_stubs") { - sigs = [ "shell/browser/ui/electron_gtk.sigs" ] + sigs = [ + "shell/browser/ui/electron_gdk_pixbuf.sigs", + "shell/browser/ui/electron_gtk.sigs", + ] extra_header = "shell/browser/ui/electron_gtk.fragment" output_name = "electron_gtk_stubs" public_deps = [ "//ui/gtk:gtk_config" ] diff --git a/shell/browser/ui/electron_gdk_pixbuf.sigs b/shell/browser/ui/electron_gdk_pixbuf.sigs new file mode 100644 index 0000000000000..c19eb4679265f --- /dev/null +++ b/shell/browser/ui/electron_gdk_pixbuf.sigs @@ -0,0 +1,3 @@ +GdkPixbuf* gdk_pixbuf_new(GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample, int width, int height) +GdkPixbuf* gdk_pixbuf_scale_simple(const GdkPixbuf* src, int dest_width, int dest_height, GdkInterpType interp_type) +guchar* gdk_pixbuf_get_pixels(const GdkPixbuf* pixbuf) diff --git a/shell/browser/ui/electron_gtk.sigs b/shell/browser/ui/electron_gtk.sigs index 7669df87d90ee..41f3890096e09 100644 --- a/shell/browser/ui/electron_gtk.sigs +++ b/shell/browser/ui/electron_gtk.sigs @@ -5,6 +5,3 @@ void gtk_native_dialog_hide(GtkNativeDialog* self); gint gtk_native_dialog_run(GtkNativeDialog* self); void gtk_native_dialog_destroy(GtkNativeDialog* self); GType gtk_native_dialog_get_type(void); -GdkPixbuf* gdk_pixbuf_new(GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample, int width, int height) -GdkPixbuf* gdk_pixbuf_scale_simple(const GdkPixbuf* src, int dest_width, int dest_height, GdkInterpType interp_type) -guchar* gdk_pixbuf_get_pixels(const GdkPixbuf* pixbuf) From 7ce2a91b9e048b5e9b2d6cc6c05f93222c54f042 Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Wed, 15 Jun 2022 18:22:59 +0000 Subject: [PATCH 6/7] Add initialization check --- patches/chromium/.patches | 1 + .../make_gtk_getlibgdkpixbuf_public.patch | 50 +++++++++++++++++++ shell/browser/electron_browser_main_parts.cc | 5 ++ 3 files changed, 56 insertions(+) create mode 100644 patches/chromium/make_gtk_getlibgdkpixbuf_public.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 547c0b5e6240e..8cac2603fcb04 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -111,3 +111,4 @@ make_gtk_getlibgtk_public.patch build_disable_print_content_analysis.patch custom_protocols_plzserviceworker.patch feat_filter_out_non-shareable_windows_in_the_current_application_in.patch +make_gtk_getlibgdkpixbuf_public.patch diff --git a/patches/chromium/make_gtk_getlibgdkpixbuf_public.patch b/patches/chromium/make_gtk_getlibgdkpixbuf_public.patch new file mode 100644 index 0000000000000..f3b02f80ac7b1 --- /dev/null +++ b/patches/chromium/make_gtk_getlibgdkpixbuf_public.patch @@ -0,0 +1,50 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> +Date: Wed, 15 Jun 2022 17:59:18 +0000 +Subject: Make gtk::GetLibGdkPixbuf public + +Allows Electron to fetch libgdk_pixbuf during run-time +rather than having to link to it statically. + +diff --git a/ui/gtk/gtk_compat.cc b/ui/gtk/gtk_compat.cc +index 40b706ed7cde206e98274025148604760b7477f9..65b097cfab72b92f301968715eb218ef0e468567 100644 +--- a/ui/gtk/gtk_compat.cc ++++ b/ui/gtk/gtk_compat.cc +@@ -66,11 +66,6 @@ void* GetLibGio() { + return libgio; + } + +-void* GetLibGdkPixbuf() { +- static void* libgdk_pixbuf = DlOpen("libgdk_pixbuf-2.0.so.0"); +- return libgdk_pixbuf; +-} +- + void* GetLibGdk3() { + static void* libgdk3 = DlOpen("libgdk-3.so.0"); + return libgdk3; +@@ -128,6 +123,11 @@ gfx::Insets InsetsFromGtkBorder(const GtkBorder& border) { + + } // namespace + ++void* GetLibGdkPixbuf() { ++ static void* libgdk_pixbuf = DlOpen("libgdk_pixbuf-2.0.so.0"); ++ return libgdk_pixbuf; ++} ++ + void* GetLibGtk() { + if (GtkCheckVersion(4)) + return GetLibGtk4(); +diff --git a/ui/gtk/gtk_compat.h b/ui/gtk/gtk_compat.h +index 2245974f91be4a691d82f54b55e12e44ae2000c5..37720be9e393d192b3b7db13a007431a9ce77ddc 100644 +--- a/ui/gtk/gtk_compat.h ++++ b/ui/gtk/gtk_compat.h +@@ -34,6 +34,9 @@ using SkColor = uint32_t; + + namespace gtk { + ++// Get handle to the currently loaded gdk_pixbuf library in the process. ++void* GetLibGdkPixbuf(); ++ + // Get handle to the currently loaded gtk library in the process. + void* GetLibGtk(); + diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc index 151fc8d17a758..9fc659d9937c4 100644 --- a/shell/browser/electron_browser_main_parts.cc +++ b/shell/browser/electron_browser_main_parts.cc @@ -371,6 +371,11 @@ void ElectronBrowserMainParts::ToolkitInitialized() { electron::UninitializeElectron_gtk(); } + electron::InitializeElectron_gdk_pixbuf(gtk::GetLibGdkPixbuf()); + if (!electron::IsElectron_gdk_pixbufInitialized()) { + electron::UninitializeElectron_gdk_pixbuf(); + } + // Chromium does not respect GTK dark theme setting, but they may change // in future and this code might be no longer needed. Check the Chromium // issue to keep updated: From f4cee80cc6291fa24dbde9a2d85e1ec1d4e89a9c Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Thu, 16 Jun 2022 10:56:19 -0700 Subject: [PATCH 7/7] Apply PR feedback --- patches/chromium/.patches | 1 - .../make_gtk_getlibgdkpixbuf_public.patch | 50 ------------------- .../chromium/make_gtk_getlibgtk_public.patch | 36 ++++++++++--- shell/browser/electron_browser_main_parts.cc | 5 +- 4 files changed, 30 insertions(+), 62 deletions(-) delete mode 100644 patches/chromium/make_gtk_getlibgdkpixbuf_public.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 8cac2603fcb04..547c0b5e6240e 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -111,4 +111,3 @@ make_gtk_getlibgtk_public.patch build_disable_print_content_analysis.patch custom_protocols_plzserviceworker.patch feat_filter_out_non-shareable_windows_in_the_current_application_in.patch -make_gtk_getlibgdkpixbuf_public.patch diff --git a/patches/chromium/make_gtk_getlibgdkpixbuf_public.patch b/patches/chromium/make_gtk_getlibgdkpixbuf_public.patch deleted file mode 100644 index f3b02f80ac7b1..0000000000000 --- a/patches/chromium/make_gtk_getlibgdkpixbuf_public.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> -Date: Wed, 15 Jun 2022 17:59:18 +0000 -Subject: Make gtk::GetLibGdkPixbuf public - -Allows Electron to fetch libgdk_pixbuf during run-time -rather than having to link to it statically. - -diff --git a/ui/gtk/gtk_compat.cc b/ui/gtk/gtk_compat.cc -index 40b706ed7cde206e98274025148604760b7477f9..65b097cfab72b92f301968715eb218ef0e468567 100644 ---- a/ui/gtk/gtk_compat.cc -+++ b/ui/gtk/gtk_compat.cc -@@ -66,11 +66,6 @@ void* GetLibGio() { - return libgio; - } - --void* GetLibGdkPixbuf() { -- static void* libgdk_pixbuf = DlOpen("libgdk_pixbuf-2.0.so.0"); -- return libgdk_pixbuf; --} -- - void* GetLibGdk3() { - static void* libgdk3 = DlOpen("libgdk-3.so.0"); - return libgdk3; -@@ -128,6 +123,11 @@ gfx::Insets InsetsFromGtkBorder(const GtkBorder& border) { - - } // namespace - -+void* GetLibGdkPixbuf() { -+ static void* libgdk_pixbuf = DlOpen("libgdk_pixbuf-2.0.so.0"); -+ return libgdk_pixbuf; -+} -+ - void* GetLibGtk() { - if (GtkCheckVersion(4)) - return GetLibGtk4(); -diff --git a/ui/gtk/gtk_compat.h b/ui/gtk/gtk_compat.h -index 2245974f91be4a691d82f54b55e12e44ae2000c5..37720be9e393d192b3b7db13a007431a9ce77ddc 100644 ---- a/ui/gtk/gtk_compat.h -+++ b/ui/gtk/gtk_compat.h -@@ -34,6 +34,9 @@ using SkColor = uint32_t; - - namespace gtk { - -+// Get handle to the currently loaded gdk_pixbuf library in the process. -+void* GetLibGdkPixbuf(); -+ - // Get handle to the currently loaded gtk library in the process. - void* GetLibGtk(); - diff --git a/patches/chromium/make_gtk_getlibgtk_public.patch b/patches/chromium/make_gtk_getlibgtk_public.patch index dd4dec37023ec..730a2877e5aa2 100644 --- a/patches/chromium/make_gtk_getlibgtk_public.patch +++ b/patches/chromium/make_gtk_getlibgtk_public.patch @@ -1,16 +1,28 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Thu, 7 Apr 2022 20:30:16 +0900 -Subject: Make gtk::GetLibGtk public +Subject: Make gtk::GetLibGtk and gtk::GetLibGdkPixbuf public -Allows embedders to get a handle to the gtk library -already loaded in the process. +Allows embedders to get a handle to the gtk and +gdk_pixbuf libraries already loaded in the process. diff --git a/ui/gtk/gtk_compat.cc b/ui/gtk/gtk_compat.cc -index b5c7af5bdb93b320f95252d35d2d76bae7f8c445..40b706ed7cde206e98274025148604760b7477f9 100644 +index b5c7af5bdb93b320f95252d35d2d76bae7f8c445..65b097cfab72b92f301968715eb218ef0e468567 100644 --- a/ui/gtk/gtk_compat.cc +++ b/ui/gtk/gtk_compat.cc -@@ -86,12 +86,6 @@ void* GetLibGtk4(bool check = true) { +@@ -66,11 +66,6 @@ void* GetLibGio() { + return libgio; + } + +-void* GetLibGdkPixbuf() { +- static void* libgdk_pixbuf = DlOpen("libgdk_pixbuf-2.0.so.0"); +- return libgdk_pixbuf; +-} +- + void* GetLibGdk3() { + static void* libgdk3 = DlOpen("libgdk-3.so.0"); + return libgdk3; +@@ -86,12 +81,6 @@ void* GetLibGtk4(bool check = true) { return libgtk4; } @@ -23,10 +35,15 @@ index b5c7af5bdb93b320f95252d35d2d76bae7f8c445..40b706ed7cde206e9827402514860476 bool LoadGtk3() { if (!GetLibGtk3(false)) return false; -@@ -134,6 +128,12 @@ gfx::Insets InsetsFromGtkBorder(const GtkBorder& border) { +@@ -134,6 +123,17 @@ gfx::Insets InsetsFromGtkBorder(const GtkBorder& border) { } // namespace ++void* GetLibGdkPixbuf() { ++ static void* libgdk_pixbuf = DlOpen("libgdk_pixbuf-2.0.so.0"); ++ return libgdk_pixbuf; ++} ++ +void* GetLibGtk() { + if (GtkCheckVersion(4)) + return GetLibGtk4(); @@ -37,13 +54,16 @@ index b5c7af5bdb93b320f95252d35d2d76bae7f8c445..40b706ed7cde206e9827402514860476 static bool loaded = LoadGtkImpl(); return loaded; diff --git a/ui/gtk/gtk_compat.h b/ui/gtk/gtk_compat.h -index 57e55b9e749b43d327deff449a530e1f435a8e8b..2245974f91be4a691d82f54b55e12e44ae2000c5 100644 +index 57e55b9e749b43d327deff449a530e1f435a8e8b..37720be9e393d192b3b7db13a007431a9ce77ddc 100644 --- a/ui/gtk/gtk_compat.h +++ b/ui/gtk/gtk_compat.h -@@ -34,6 +34,9 @@ using SkColor = uint32_t; +@@ -34,6 +34,12 @@ using SkColor = uint32_t; namespace gtk { ++// Get handle to the currently loaded gdk_pixbuf library in the process. ++void* GetLibGdkPixbuf(); ++ +// Get handle to the currently loaded gtk library in the process. +void* GetLibGtk(); + diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc index 9fc659d9937c4..dd5f187ce9ed5 100644 --- a/shell/browser/electron_browser_main_parts.cc +++ b/shell/browser/electron_browser_main_parts.cc @@ -372,9 +372,8 @@ void ElectronBrowserMainParts::ToolkitInitialized() { } electron::InitializeElectron_gdk_pixbuf(gtk::GetLibGdkPixbuf()); - if (!electron::IsElectron_gdk_pixbufInitialized()) { - electron::UninitializeElectron_gdk_pixbuf(); - } + CHECK(electron::IsElectron_gdk_pixbufInitialized()) + << "Failed to initialize libgdk_pixbuf-2.0.so.0"; // Chromium does not respect GTK dark theme setting, but they may change // in future and this code might be no longer needed. Check the Chromium