From 1052ca32aec34b5fbfd1e46ef5507dae3dfa0574 Mon Sep 17 00:00:00 2001
From: Pablo Saavedra <psaavedra@igalia.com>
Date: Wed, 18 Sep 2024 09:23:32 +0200
Subject: [PATCH] webkitgtk: Bump to version 2.46.1

Changes:

* Skia is used instead of Cairo for 2D rendering, and GPU rendering is enabled by default.
* Offscreen Canvas is now enabled by default.
* Add support for system tracing using Sysprof.
* Add new API to load settings from a config file.
* Add a new setting to toggle 2D Canvas acceleration (enabled by default).
* Undeprecate console messages API and make it available in the 2.0 API.
* Fix login QR code not shown in WhatsApp web.
* Disable PSON by default again in GTK 3 API versions.
* Disable DMABuf video sink by default to prevent file descriptor leaks.
* Fix the build with GCC 13.
* Fix several crashes and rendering issues.

Release Notes:

* https://wpewebkit.org/release/wpewebkit-2.46.0.html
* https://wpewebkit.org/release/wpewebkit-2.46.1.html

wip
---
 .github/workflows/test-build.yml              |  2 +-
 ...SSING_STD_FILESYSTEM_PATH_CONSTRUCTO.patch | 28 -------------------
 .../webkitgtk/fix-bmalloc-armhf.patch         | 19 +++++++++++++
 ...ebkitgtk_2.44.4.bb => webkitgtk_2.46.1.bb} | 12 +++++---
 4 files changed, 28 insertions(+), 33 deletions(-)
 delete mode 100644 recipes-browser/webkitgtk/webkitgtk/0001-Activate-HAVE_MISSING_STD_FILESYSTEM_PATH_CONSTRUCTO.patch
 create mode 100644 recipes-browser/webkitgtk/webkitgtk/fix-bmalloc-armhf.patch
 rename recipes-browser/webkitgtk/{webkitgtk_2.44.4.bb => webkitgtk_2.46.1.bb} (95%)

diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml
index 1c686480..722a25d3 100644
--- a/.github/workflows/test-build.yml
+++ b/.github/workflows/test-build.yml
@@ -79,7 +79,7 @@ jobs:
       - uses: actions/checkout@v3
       - uses: ./.github/actions/bitbake-build
         with:
-          bitbake_source: 'raspberrypi3-mesa-webkitgtk raspberrypi3-mesa poky layers.raspberrypi.webkit conf_v4'
+          bitbake_source: 'raspberrypi4-64-webkitgtk raspberrypi4-64 poky layers.raspberrypi.webkit conf_v4'
           bitbake_target: 'webkitgtk'
           repo_release: 'scarthgap'
     needs: scarthgap-repo
diff --git a/recipes-browser/webkitgtk/webkitgtk/0001-Activate-HAVE_MISSING_STD_FILESYSTEM_PATH_CONSTRUCTO.patch b/recipes-browser/webkitgtk/webkitgtk/0001-Activate-HAVE_MISSING_STD_FILESYSTEM_PATH_CONSTRUCTO.patch
deleted file mode 100644
index 827f3b21..00000000
--- a/recipes-browser/webkitgtk/webkitgtk/0001-Activate-HAVE_MISSING_STD_FILESYSTEM_PATH_CONSTRUCTO.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From e401743e585bd7bb3ae1956d64c8c913e69f28b8 Mon Sep 17 00:00:00 2001
-From: Pablo Saavedra <psaavedra@igalia.com>
-Date: Thu, 25 Jan 2024 12:06:44 +0100
-Subject: [PATCH] Activate HAVE_MISSING_STD_FILESYSTEM_PATH_CONSTRUCTOR for
- PLATFORM(WPE)
-
-Related to 'Start using C++20' [1]
-
-[1] https://bugs.webkit.org/show_bug.cgi?id=233963
-
-Upstream-Status: Inappropriate [Compiler to old]
----
- Source/WTF/wtf/PlatformHave.h | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/Source/WTF/wtf/PlatformHave.h b/Source/WTF/wtf/PlatformHave.h
-index 602749b0..b7448702 100644
---- a/Source/WTF/wtf/PlatformHave.h
-+++ b/Source/WTF/wtf/PlatformHave.h
-@@ -116,7 +116,7 @@
- #endif
- #endif
- 
--#if PLATFORM(PLAYSTATION)
-+#if PLATFORM(PLAYSTATION) || PLATFORM(GTK) || PLATFORM(WPE)
- #define HAVE_MISSING_STD_FILESYSTEM_PATH_CONSTRUCTOR 1
- #endif
- 
diff --git a/recipes-browser/webkitgtk/webkitgtk/fix-bmalloc-armhf.patch b/recipes-browser/webkitgtk/webkitgtk/fix-bmalloc-armhf.patch
new file mode 100644
index 00000000..4e388668
--- /dev/null
+++ b/recipes-browser/webkitgtk/webkitgtk/fix-bmalloc-armhf.patch
@@ -0,0 +1,19 @@
+From: Alberto Garcia <berto@igalia.com>
+Subject: Fix the armhf build if bmalloc is enabled
+Bug: https://bugs.webkit.org/show_bug.cgi?id=278858
+Index: webkitgtk/Source/WebKit/UIProcess/gtk/PointerLockManagerX11.cpp
+===================================================================
+--- webkitgtk.orig/Source/WebKit/UIProcess/gtk/PointerLockManagerX11.cpp
++++ webkitgtk/Source/WebKit/UIProcess/gtk/PointerLockManagerX11.cpp
+@@ -29,10 +29,10 @@
+ #if PLATFORM(X11)
+ 
+ #include "WebPageProxy.h"
+-#include <X11/Xlib.h>
+ #include <gtk/gtk.h>
+ #include <wtf/TZoneMallocInlines.h>
+ #include <wtf/glib/GRefPtr.h>
++#include <X11/Xlib.h>
+ 
+ #if USE(GTK4)
+ #include <gdk/x11/gdkx.h>
diff --git a/recipes-browser/webkitgtk/webkitgtk_2.44.4.bb b/recipes-browser/webkitgtk/webkitgtk_2.46.1.bb
similarity index 95%
rename from recipes-browser/webkitgtk/webkitgtk_2.44.4.bb
rename to recipes-browser/webkitgtk/webkitgtk_2.46.1.bb
index 86ce8484..7a0ceb7e 100644
--- a/recipes-browser/webkitgtk/webkitgtk_2.44.4.bb
+++ b/recipes-browser/webkitgtk/webkitgtk_2.46.1.bb
@@ -11,7 +11,7 @@ LIC_FILES_CHKSUM = "file://Source/JavaScriptCore/COPYING.LIB;md5=d0c6d6397a5d842
 
 # you need harfbuzz with icu enabled, you can add this to your config:
 # PACKAGECONFIG:append:pn-harfbuzz = " icu"
-DEPENDS = "curl libxml2 cairo libxslt libidn \
+DEPENDS = "curl libxml2 libxslt libidn \
            gtk+3 gstreamer1.0 gstreamer1.0-plugins-base flex-native icu \
            gperf-native perl-native ruby-native ninja-native \
            glib-2.0 \
@@ -27,12 +27,13 @@ DEPENDS = "curl libxml2 cairo libxslt libidn \
 "
 
 FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
+
 SRC_URI = " \
     https://www.webkitgtk.org/releases/webkitgtk-${PV}.tar.xz;name=tarball \
-    file://0001-Activate-HAVE_MISSING_STD_FILESYSTEM_PATH_CONSTRUCTO.patch \
+    file://fix-bmalloc-armhf.patch \
 "
 
-SRC_URI[tarball.sha256sum] = "2ce4ec1b78413035037aba8326b31ed72696626b7bea7bace5e46ac0d8cbe796"
+SRC_URI[tarball.sha256sum] = "2a14faac359aff941d0bc4443eb5537e3702bcaf316b0a129e0e65f3ff8eaac0"
 
 RRECOMMENDS:${PN} = "${PN}-bin \
                      ca-certificates \
@@ -59,7 +60,6 @@ PACKAGECONFIG ??= " ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)
                     ${@bb.utils.contains_any('LAYERSERIES_CORENAMES', 'kirkstone langdale', '', 'gtk4', d)} \
                     jit \
                     jpegxl \
-                    libbacktrace \
                     libsecret \
                     openjpeg \
                     video \
@@ -96,6 +96,7 @@ EXTRA_OECMAKE = " \
                  -DENABLE_INTROSPECTION=OFF \
                  -DENABLE_GTKDOC=OFF \
                  -DENABLE_MINIBROWSER=ON \
+                 -DUSE_SYSPROF_CAPTURE=OFF \
                  -G Ninja \
                 "
 
@@ -111,6 +112,9 @@ PACKAGECONFIG:remove:riscv64 = "jit"
 PACKAGECONFIG:remove:mipsarchn64 = "jit"
 PACKAGECONFIG:remove:mipsarchn32 = "jit"
 
+# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=949621
+LDFLAGS += "-Wl,--reduce-memory-overheads"
+
 # http://errors.yoctoproject.org/Errors/Details/20370/
 ARM_INSTRUCTION_SET:armv4 = "arm"
 ARM_INSTRUCTION_SET:armv5 = "arm"