Really enable proxy cache

This commit is contained in:
Martin Stransky 2024-01-02 15:22:55 +01:00
parent 55e1497866
commit 5d26feb548
3 changed files with 80 additions and 59 deletions

View File

@ -23,7 +23,7 @@ diff --git a/third_party/wayland-proxy/wayland-proxy.h b/third_party/wayland-pro
new file mode 100644 new file mode 100644
--- /dev/null --- /dev/null
+++ b/third_party/wayland-proxy/wayland-proxy.h +++ 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 -*- +/* -*- 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 + * 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 + * License, v. 2.0. If a copy of the MPL was not distributed with this
@ -36,6 +36,7 @@ new file mode 100644
+#include <vector> +#include <vector>
+#include <fcntl.h> +#include <fcntl.h>
+#include <atomic> +#include <atomic>
+#include <memory>
+ +
+typedef unsigned char byte; +typedef unsigned char byte;
+ +
@ -50,7 +51,7 @@ new file mode 100644
+ bool RunThread(); + bool RunThread();
+ +
+ void SetWaylandDisplay(); + void SetWaylandDisplay();
+ void SetVerbose(bool aVerbose); + static void SetVerbose(bool aVerbose);
+ +
+ ~WaylandProxy(); + ~WaylandProxy();
+ +
@ -82,7 +83,7 @@ diff --git a/third_party/wayland-proxy/wayland-proxy.cpp b/third_party/wayland-p
new file mode 100644 new file mode 100644
--- /dev/null --- /dev/null
+++ b/third_party/wayland-proxy/wayland-proxy.cpp +++ 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 -*- +/* -*- 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 + * 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 + * 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 +// This code is based on Rust implementation at
+// https://github.com/the8472/weyland-p5000 +// https://github.com/the8472/weyland-p5000
+ +
+// Version 1.0
+
+#include <stdio.h> +#include <stdio.h>
+#include <stdlib.h> +#include <stdlib.h>
+#include <stdarg.h> +#include <stdarg.h>
@ -179,6 +182,7 @@ new file mode 100644
+class ProxiedConnection { +class ProxiedConnection {
+ public: + public:
+ bool Init(int aChildSocket); + bool Init(int aChildSocket);
+ bool IsConnected() { return mCompositorConnected; }
+ +
+ struct pollfd* AddToPollFd(struct pollfd* aPfds); + struct pollfd* AddToPollFd(struct pollfd* aPfds);
+ struct pollfd* LoadPollFd(struct pollfd* aPfds); + struct pollfd* LoadPollFd(struct pollfd* aPfds);
@ -365,7 +369,7 @@ new file mode 100644
+ mCompositorSocket = + mCompositorSocket =
+ socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0); + socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
+ if (mCompositorSocket == -1) { + if (mCompositorSocket == -1) {
+ Error("ConnectToCompositor() socket()"); + Error("ProxiedConnection::Init() socket()");
+ } + }
+ return mApplicationSocket > 0 && mCompositorSocket > 0; + return mApplicationSocket > 0 && mCompositorSocket > 0;
+} +}
@ -516,6 +520,7 @@ new file mode 100644
+ } else { + } else {
+ // Try to reconnect to compositor. + // Try to reconnect to compositor.
+ if (!ConnectToCompositor()) { + if (!ConnectToCompositor()) {
+ Info("Failed to connect to compositor\n");
+ return false; + return false;
+ } + }
+ // We're not connected yet but ConnectToCompositor() didn't return + // We're not connected yet but ConnectToCompositor() didn't return
@ -571,6 +576,7 @@ new file mode 100644
+ return false; + return false;
+ } + }
+ +
+ Info("WaylandProxy Wayland '%s' proxy '%s'\n", sWaylandDisplay, sWaylandProxy);
+ return true; + return true;
+} +}
+ +
@ -645,14 +651,19 @@ new file mode 100644
+ for (auto const& connection : mConnections) { + for (auto const& connection : mConnections) {
+ addedPollfd = connection->AddToPollFd(addedPollfd); + addedPollfd = connection->AddToPollFd(addedPollfd);
+ } + }
+ int nfds = (addedPollfd - pollfds);
+ +
+ // Add extra listening socket + // 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->fd = mProxyServerSocket;
+ addedPollfd->events = POLLIN; + addedPollfd->events = POLLIN;
+ nfds++;
+ }
+ assert(addedPollfd < pollfds + nfds_max); + assert(addedPollfd < pollfds + nfds_max);
+ +
+ int nfds = (addedPollfd - pollfds) + 1;
+
+ while (1) { + while (1) {
+ int ret = poll(pollfds, nfds, POLL_TIMEOUT); + int ret = poll(pollfds, nfds, POLL_TIMEOUT);
+ if (ret == 0) { + if (ret == 0) {
@ -685,7 +696,7 @@ new file mode 100644
+ assert(loadedPollfd < pollfds + nfds_max); + assert(loadedPollfd < pollfds + nfds_max);
+ +
+ // Create a new connection if there's a new client waiting + // 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"); + Info("WaylandProxy: new child connection\n");
+ int applicationSocket = accept4(loadedPollfd->fd, nullptr, nullptr, + int applicationSocket = accept4(loadedPollfd->fd, nullptr, nullptr,
+ SOCK_NONBLOCK | SOCK_CLOEXEC); + SOCK_NONBLOCK | SOCK_CLOEXEC);
@ -744,6 +755,7 @@ new file mode 100644
+ if (mProxyServerSocket != -1) { + if (mProxyServerSocket != -1) {
+ close(mProxyServerSocket); + close(mProxyServerSocket);
+ } + }
+ SetWaylandDisplay();
+} +}
+ +
+void* WaylandProxy::RunProxyThread(WaylandProxy* aProxy) { +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 diff --git a/widget/gtk/moz.build b/widget/gtk/moz.build
--- a/widget/gtk/moz.build --- a/widget/gtk/moz.build
+++ b/widget/gtk/moz.build +++ b/widget/gtk/moz.build
@@ -23,10 +23,13 @@ @@ -21,11 +21,15 @@
if CONFIG["COMPILE_ENVIRONMENT"]:
DIRS += ["mozgtk"] DIRS += ["mozgtk"]
if CONFIG["MOZ_WAYLAND"]: 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"]: if CONFIG["MOZ_ENABLE_VAAPI"]:
DIRS += ["vaapitest"] DIRS += ["vaapitest"]
if CONFIG["MOZ_ENABLE_V4L2"]: if CONFIG["MOZ_ENABLE_V4L2"]:
DIRS += ["v4l2test"]

View File

@ -1,19 +1,23 @@
diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
--- a/toolkit/xre/nsAppRunner.cpp --- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp
@@ -343,16 +343,24 @@ @@ -342,17 +342,28 @@
# include "mozilla/WidgetUtilsGtk.h"
# include <gtk/gtk.h> # include <gtk/gtk.h>
# ifdef MOZ_WAYLAND # ifdef MOZ_WAYLAND
# include <gdk/gdkwayland.h> # include <gdk/gdkwayland.h>
# include "mozilla/widget/nsWaylandDisplay.h" # include "mozilla/widget/nsWaylandDisplay.h"
# endif
+# ifdef MOZ_WAYLAND_PROXY
+# include "wayland-proxy.h" +# include "wayland-proxy.h"
+# endif # endif
# ifdef MOZ_X11 # ifdef MOZ_X11
# include <gdk/gdkx.h> # include <gdk/gdkx.h>
# endif /* MOZ_X11 */ # endif /* MOZ_X11 */
#endif #endif
+
+#if defined(MOZ_WAYLAND)
+std::unique_ptr<WaylandProxy> gWaylandProxy;
+#endif
+
#include "BinaryPath.h" #include "BinaryPath.h"
+#ifdef MOZ_LOGGING +#ifdef MOZ_LOGGING
@ -26,52 +30,54 @@ diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
namespace mozilla { namespace mozilla {
FuzzerRunner* fuzzerRunner = 0; FuzzerRunner* fuzzerRunner = 0;
@@ -3670,10 +3678,13 @@ @@ -2790,10 +2801,13 @@
class XREMain { if (gRemoteService) {
public: gRemoteService->UnlockStartup();
XREMain() = default; gRemoteService = nullptr;
}
~XREMain() { #endif
+#if defined(MOZ_WAYLAND_PROXY) +#if defined(MOZ_WAYLAND)
+ mWaylandProxy = nullptr; + gWaylandProxy = nullptr;
+#endif +#endif
mScopedXPCOM = nullptr; return LaunchChild(false, true);
mAppData = nullptr; }
} 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);
} }
int XRE_main(int argc, char* argv[], const BootstrapConfig& aConfig); static bool gDoMigration = false;
@@ -3689,10 +3700,13 @@ static bool gDoProfileReset = false;
nsCOMPtr<nsIFile> mProfLD; @@ -4709,20 +4726,36 @@
nsCOMPtr<nsIProfileLock> mProfileLock;
#if defined(MOZ_HAS_REMOTE)
RefPtr<nsRemoteService> mRemoteService;
#endif
+#if defined(MOZ_WAYLAND_PROXY)
+ std::unique_ptr<WaylandProxy> mWaylandProxy;
+#endif
UniquePtr<ScopedXPCOMStartup> mScopedXPCOM;
UniquePtr<XREAppData> mAppData;
nsXREDirProvider mDirProvider;
@@ -4709,20 +4723,34 @@
#if defined(MOZ_WIDGET_GTK) #if defined(MOZ_WIDGET_GTK)
if (!isBackgroundTaskMode && !gfxPlatform::IsHeadless()) { if (!isBackgroundTaskMode && !gfxPlatform::IsHeadless()) {
const char* display_name = nullptr; const char* display_name = nullptr;
bool saveDisplayArg = false; bool saveDisplayArg = false;
+ bool waylandEnabled = IsWaylandEnabled(); + bool waylandEnabled = IsWaylandEnabled();
+# ifdef MOZ_WAYLAND_PROXY +# ifdef MOZ_WAYLAND
+ auto* proxyEnv = getenv("MOZ_DISABLE_WAYLAND_PROXY"); + auto* proxyEnv = getenv("MOZ_DISABLE_WAYLAND_PROXY");
+ bool disableWaylandProxy = proxyEnv && *proxyEnv; + bool disableWaylandProxy = proxyEnv && *proxyEnv;
+ if (!disableWaylandProxy && XRE_IsParentProcess() && waylandEnabled) { + if (!disableWaylandProxy && XRE_IsParentProcess() && waylandEnabled) {
+ mWaylandProxy = WaylandProxy::Create();
+ mWaylandProxy->RunThread();
+# ifdef MOZ_LOGGING +# ifdef MOZ_LOGGING
+ if (MOZ_LOG_TEST(gWidgetWaylandLog, mozilla::LogLevel::Debug)) { + if (MOZ_LOG_TEST(gWidgetWaylandLog, mozilla::LogLevel::Debug)) {
+ mWaylandProxy->SetVerbose(true); + WaylandProxy::SetVerbose(true);
+ } + }
+# endif +# endif
+ gWaylandProxy = WaylandProxy::Create();
+ if (gWaylandProxy) {
+ gWaylandProxy->RunThread();
+ }
+ } + }
+# endif +# endif
+ +
@ -90,20 +96,16 @@ diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
if (!waylandEnabled && !display_name) { if (!waylandEnabled && !display_name) {
display_name = PR_GetEnv("DISPLAY"); display_name = PR_GetEnv("DISPLAY");
if (!display_name) { 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. // appropriately when necessary.
if (!gfxPlatform::IsHeadless()) { if (!gfxPlatform::IsHeadless()) {
# ifdef MOZ_WAYLAND # ifdef MOZ_WAYLAND
WaylandDisplayRelease(); WaylandDisplayRelease();
+ gWaylandProxy = nullptr;
# endif # endif
+# ifdef MOZ_WAYLAND_PROXY
+ if (mWaylandProxy) {
+ mWaylandProxy = nullptr;
+ }
+# endif
} }
#endif #endif
XRE_DeinitCommandLine(); XRE_DeinitCommandLine();

View File

@ -174,7 +174,7 @@ ExcludeArch: i686
Summary: Mozilla Firefox Web browser Summary: Mozilla Firefox Web browser
Name: firefox Name: firefox
Version: 121.0 Version: 121.0
Release: 3%{?pre_tag}%{?dist} Release: 4%{?pre_tag}%{?dist}
URL: https://www.mozilla.org/firefox/ URL: https://www.mozilla.org/firefox/
License: MPLv1.1 or GPLv2+ or LGPLv2+ 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 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 Patch408: D167159.diff
Patch409: D196554.diff Patch409: D196554.diff
Patch410: D196555.diff Patch410: D196555.diff
Patch411: D196556.diff
# PGO/LTO patches # PGO/LTO patches
Patch600: pgo.patch Patch600: pgo.patch
@ -550,6 +549,8 @@ This package contains results of tests executed during build.
%patch402 -p1 -b .1196777 %patch402 -p1 -b .1196777
%patch407 -p1 -b .1667096 %patch407 -p1 -b .1667096
%patch408 -p1 -b .D167159 %patch408 -p1 -b .D167159
%patch409 -p1 -b .D196554
%patch410 -p1 -b .D196555
# PGO patches # PGO patches
%if %{build_with_pgo} %if %{build_with_pgo}
@ -1168,6 +1169,9 @@ fi
#--------------------------------------------------------------------- #---------------------------------------------------------------------
%changelog %changelog
* Tue Jan 24 2023 Martin Stransky <stransky@redhat.com>- 121.0-4
- Really enable proxy cache
* Fri Dec 22 2023 Martin Stransky <stransky@redhat.com>- 121.0-3 * Fri Dec 22 2023 Martin Stransky <stransky@redhat.com>- 121.0-3
- Disabled DBus activations - Disabled DBus activations