diff --git a/D196554.diff b/D196554.diff index b971f28..158b7c1 100644 --- a/D196554.diff +++ b/D196554.diff @@ -23,7 +23,7 @@ diff --git a/third_party/wayland-proxy/wayland-proxy.h b/third_party/wayland-pro new file mode 100644 --- /dev/null +++ b/third_party/wayland-proxy/wayland-proxy.h -@@ -0,0 +1,54 @@ +@@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -36,6 +36,7 @@ new file mode 100644 +#include +#include +#include ++#include + +typedef unsigned char byte; + @@ -50,7 +51,7 @@ new file mode 100644 + bool RunThread(); + + void SetWaylandDisplay(); -+ void SetVerbose(bool aVerbose); ++ static void SetVerbose(bool aVerbose); + + ~WaylandProxy(); + @@ -82,7 +83,7 @@ diff --git a/third_party/wayland-proxy/wayland-proxy.cpp b/third_party/wayland-p new file mode 100644 --- /dev/null +++ b/third_party/wayland-proxy/wayland-proxy.cpp -@@ -0,0 +1,731 @@ +@@ -0,0 +1,742 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -91,6 +92,8 @@ new file mode 100644 +// This code is based on Rust implementation at +// https://github.com/the8472/weyland-p5000 + ++// Version 1.0 ++ +#include +#include +#include @@ -179,6 +182,7 @@ new file mode 100644 +class ProxiedConnection { + public: + bool Init(int aChildSocket); ++ bool IsConnected() { return mCompositorConnected; } + + struct pollfd* AddToPollFd(struct pollfd* aPfds); + struct pollfd* LoadPollFd(struct pollfd* aPfds); @@ -365,7 +369,7 @@ new file mode 100644 + mCompositorSocket = + socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0); + if (mCompositorSocket == -1) { -+ Error("ConnectToCompositor() socket()"); ++ Error("ProxiedConnection::Init() socket()"); + } + return mApplicationSocket > 0 && mCompositorSocket > 0; +} @@ -516,6 +520,7 @@ new file mode 100644 + } else { + // Try to reconnect to compositor. + if (!ConnectToCompositor()) { ++ Info("Failed to connect to compositor\n"); + return false; + } + // We're not connected yet but ConnectToCompositor() didn't return @@ -571,6 +576,7 @@ new file mode 100644 + return false; + } + ++ Info("WaylandProxy Wayland '%s' proxy '%s'\n", sWaylandDisplay, sWaylandProxy); + return true; +} + @@ -645,14 +651,19 @@ new file mode 100644 + for (auto const& connection : mConnections) { + addedPollfd = connection->AddToPollFd(addedPollfd); + } ++ int nfds = (addedPollfd - pollfds); + -+ // Add extra listening socket -+ addedPollfd->fd = mProxyServerSocket; -+ addedPollfd->events = POLLIN; ++ // If all connections are attached to compositor, add another one ++ // for new potential connection from application. ++ bool addNewConnection = mConnections.empty() || ++ mConnections.back()->IsConnected(); ++ if (addNewConnection) { ++ addedPollfd->fd = mProxyServerSocket; ++ addedPollfd->events = POLLIN; ++ nfds++; ++ } + assert(addedPollfd < pollfds + nfds_max); + -+ int nfds = (addedPollfd - pollfds) + 1; -+ + while (1) { + int ret = poll(pollfds, nfds, POLL_TIMEOUT); + if (ret == 0) { @@ -685,7 +696,7 @@ new file mode 100644 + assert(loadedPollfd < pollfds + nfds_max); + + // Create a new connection if there's a new client waiting -+ if (loadedPollfd->revents & POLLIN) { ++ if (addNewConnection && (loadedPollfd->revents & POLLIN)) { + Info("WaylandProxy: new child connection\n"); + int applicationSocket = accept4(loadedPollfd->fd, nullptr, nullptr, + SOCK_NONBLOCK | SOCK_CLOEXEC); @@ -744,6 +755,7 @@ new file mode 100644 + if (mProxyServerSocket != -1) { + close(mProxyServerSocket); + } ++ SetWaylandDisplay(); +} + +void* WaylandProxy::RunProxyThread(WaylandProxy* aProxy) { @@ -817,18 +829,21 @@ new file mode 100644 diff --git a/widget/gtk/moz.build b/widget/gtk/moz.build --- a/widget/gtk/moz.build +++ b/widget/gtk/moz.build -@@ -23,10 +23,13 @@ +@@ -21,11 +21,15 @@ + + if CONFIG["COMPILE_ENVIRONMENT"]: DIRS += ["mozgtk"] if CONFIG["MOZ_WAYLAND"]: - DIRS += ["wayland", "mozwayland"] +- DIRS += ["wayland", "mozwayland"] ++ DIRS += [ ++ "wayland", ++ "mozwayland", ++ "../../third_party/wayland-proxy" ++ ] -+if CONFIG["MOZ_WAYLAND_PROXY"]: -+ DIRS += ["../../third_party/wayland-proxy"] -+ if CONFIG["MOZ_ENABLE_VAAPI"]: DIRS += ["vaapitest"] if CONFIG["MOZ_ENABLE_V4L2"]: - DIRS += ["v4l2test"] diff --git a/D196555.diff b/D196555.diff index 8d22b29..6a8d6dd 100644 --- a/D196555.diff +++ b/D196555.diff @@ -1,19 +1,23 @@ diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp -@@ -343,16 +343,24 @@ +@@ -342,17 +342,28 @@ + # include "mozilla/WidgetUtilsGtk.h" # include # ifdef MOZ_WAYLAND # include # include "mozilla/widget/nsWaylandDisplay.h" - # endif -+# ifdef MOZ_WAYLAND_PROXY +# include "wayland-proxy.h" -+# endif + # endif # ifdef MOZ_X11 # include # endif /* MOZ_X11 */ #endif ++ ++#if defined(MOZ_WAYLAND) ++std::unique_ptr gWaylandProxy; ++#endif ++ #include "BinaryPath.h" +#ifdef MOZ_LOGGING @@ -26,52 +30,54 @@ diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp namespace mozilla { FuzzerRunner* fuzzerRunner = 0; -@@ -3670,10 +3678,13 @@ - class XREMain { - public: - XREMain() = default; - - ~XREMain() { -+#if defined(MOZ_WAYLAND_PROXY) -+ mWaylandProxy = nullptr; -+#endif - mScopedXPCOM = nullptr; - mAppData = nullptr; - } - - int XRE_main(int argc, char* argv[], const BootstrapConfig& aConfig); -@@ -3689,10 +3700,13 @@ - nsCOMPtr mProfLD; - nsCOMPtr mProfileLock; - #if defined(MOZ_HAS_REMOTE) - RefPtr mRemoteService; +@@ -2790,10 +2801,13 @@ + if (gRemoteService) { + gRemoteService->UnlockStartup(); + gRemoteService = nullptr; + } #endif -+#if defined(MOZ_WAYLAND_PROXY) -+ std::unique_ptr mWaylandProxy; ++#if defined(MOZ_WAYLAND) ++ gWaylandProxy = nullptr; +#endif + return LaunchChild(false, true); + } + } else { + rv = ps->Alert(nullptr, killTitle.get(), killMessage.get()); + NS_ENSURE_SUCCESS_LOG(rv, rv); +@@ -2904,10 +2918,13 @@ + if (gRemoteService) { + gRemoteService->UnlockStartup(); + gRemoteService = nullptr; + } + #endif ++#if defined(MOZ_WAYLAND) ++ gWaylandProxy = nullptr; ++#endif + return LaunchChild(false, true); + } - UniquePtr mScopedXPCOM; - UniquePtr mAppData; - - nsXREDirProvider mDirProvider; -@@ -4709,20 +4723,34 @@ + static bool gDoMigration = false; + static bool gDoProfileReset = false; +@@ -4709,20 +4726,36 @@ #if defined(MOZ_WIDGET_GTK) if (!isBackgroundTaskMode && !gfxPlatform::IsHeadless()) { const char* display_name = nullptr; bool saveDisplayArg = false; + bool waylandEnabled = IsWaylandEnabled(); -+# ifdef MOZ_WAYLAND_PROXY ++# ifdef MOZ_WAYLAND + auto* proxyEnv = getenv("MOZ_DISABLE_WAYLAND_PROXY"); + bool disableWaylandProxy = proxyEnv && *proxyEnv; + if (!disableWaylandProxy && XRE_IsParentProcess() && waylandEnabled) { -+ mWaylandProxy = WaylandProxy::Create(); -+ mWaylandProxy->RunThread(); +# ifdef MOZ_LOGGING + if (MOZ_LOG_TEST(gWidgetWaylandLog, mozilla::LogLevel::Debug)) { -+ mWaylandProxy->SetVerbose(true); ++ WaylandProxy::SetVerbose(true); + } +# endif ++ gWaylandProxy = WaylandProxy::Create(); ++ if (gWaylandProxy) { ++ gWaylandProxy->RunThread(); ++ } + } +# endif + @@ -90,20 +96,16 @@ diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp if (!waylandEnabled && !display_name) { display_name = PR_GetEnv("DISPLAY"); if (!display_name) { -@@ -5953,10 +5981,15 @@ +@@ -5952,10 +5985,11 @@ + // gdk_display_close also calls gdk_display_manager_set_default_display // appropriately when necessary. if (!gfxPlatform::IsHeadless()) { # ifdef MOZ_WAYLAND WaylandDisplayRelease(); ++ gWaylandProxy = nullptr; # endif -+# ifdef MOZ_WAYLAND_PROXY -+ if (mWaylandProxy) { -+ mWaylandProxy = nullptr; -+ } -+# endif } #endif XRE_DeinitCommandLine(); - diff --git a/firefox.spec b/firefox.spec index d305236..84c0eb8 100644 --- a/firefox.spec +++ b/firefox.spec @@ -174,7 +174,7 @@ ExcludeArch: i686 Summary: Mozilla Firefox Web browser Name: firefox Version: 121.0 -Release: 3%{?pre_tag}%{?dist} +Release: 4%{?pre_tag}%{?dist} URL: https://www.mozilla.org/firefox/ License: MPLv1.1 or GPLv2+ or LGPLv2+ Source0: https://archive.mozilla.org/pub/firefox/releases/%{version}%{?pre_version}/source/firefox-%{version}%{?pre_version}.source.tar.xz @@ -256,7 +256,6 @@ Patch407: mozilla-1667096.patch Patch408: D167159.diff Patch409: D196554.diff Patch410: D196555.diff -Patch411: D196556.diff # PGO/LTO patches Patch600: pgo.patch @@ -550,6 +549,8 @@ This package contains results of tests executed during build. %patch402 -p1 -b .1196777 %patch407 -p1 -b .1667096 %patch408 -p1 -b .D167159 +%patch409 -p1 -b .D196554 +%patch410 -p1 -b .D196555 # PGO patches %if %{build_with_pgo} @@ -1168,6 +1169,9 @@ fi #--------------------------------------------------------------------- %changelog +* Tue Jan 24 2023 Martin Stransky - 121.0-4 +- Really enable proxy cache + * Fri Dec 22 2023 Martin Stransky - 121.0-3 - Disabled DBus activations