From 5364193d8d26ebe4e333a4e2a36a5483edff6ea1 Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Tue, 7 Nov 2023 13:07:16 +0100 Subject: [PATCH] Added fix for rhbz#2247665 --- ...1698487416.diff => D192061.1699444912.diff | 84 ++++---- D192208.1699444906.diff | 201 ++++++++++++++++++ firefox.spec | 15 +- 3 files changed, 256 insertions(+), 44 deletions(-) rename D192061.1698487416.diff => D192061.1699444912.diff (54%) create mode 100644 D192208.1699444906.diff diff --git a/D192061.1698487416.diff b/D192061.1699444912.diff similarity index 54% rename from D192061.1698487416.diff rename to D192061.1699444912.diff index b7a06b4..a7c4e85 100644 --- a/D192061.1698487416.diff +++ b/D192061.1699444912.diff @@ -1,7 +1,7 @@ diff --git a/widget/gtk/nsUserIdleServiceGTK.cpp b/widget/gtk/nsUserIdleServiceGTK.cpp --- a/widget/gtk/nsUserIdleServiceGTK.cpp +++ b/widget/gtk/nsUserIdleServiceGTK.cpp -@@ -149,48 +149,56 @@ +@@ -149,48 +149,62 @@ #ifdef MOZ_ENABLE_DBUS class UserIdleServiceMutter : public UserIdleServiceImpl { @@ -32,7 +32,48 @@ diff --git a/widget/gtk/nsUserIdleServiceGTK.cpp b/widget/gtk/nsUserIdleServiceG - ("UserIdleServiceMutter::PollIdleTime() Unexpected params type: %s\n", - g_variant_get_type_string(result))); - return false; -- } ++ ++ if (!mPollInProgress) { ++ mPollInProgress = true; ++ DBusProxyCall(mProxy, "GetIdletime", nullptr, G_DBUS_CALL_FLAGS_NONE, -1, ++ mCancellable) ++ ->Then( ++ GetCurrentSerialEventTarget(), __func__, ++ // It's safe to capture this as we use mCancellable to stop ++ // listening. ++ [self = RefPtr{this}, this](RefPtr&& aResult) { ++ if (!g_variant_is_of_type(aResult, G_VARIANT_TYPE_TUPLE) || ++ g_variant_n_children(aResult) != 1) { ++ MOZ_LOG(sIdleLog, LogLevel::Info, ++ ("PollIdleTime() Unexpected params type: %s\n", ++ g_variant_get_type_string(aResult))); ++ mLastIdleTime = 0; ++ return; ++ } ++ RefPtr iTime = ++ dont_AddRef(g_variant_get_child_value(aResult, 0)); ++ if (!g_variant_is_of_type(iTime, G_VARIANT_TYPE_UINT64)) { ++ MOZ_LOG(sIdleLog, LogLevel::Info, ++ ("PollIdleTime() Unexpected params type: %s\n", ++ g_variant_get_type_string(aResult))); ++ mLastIdleTime = 0; ++ return; ++ } ++ uint64_t idleTime = g_variant_get_uint64(iTime); ++ if (idleTime > std::numeric_limits::max()) { ++ idleTime = std::numeric_limits::max(); ++ } ++ mLastIdleTime = idleTime; ++ mPollInProgress = false; ++ MOZ_LOG(sIdleLog, LogLevel::Info, ++ ("Async handler got %d\n", mLastIdleTime)); ++ }, ++ [self = RefPtr{this}, this](GUniquePtr&& aError) { ++ mPollInProgress = false; ++ g_warning("Failed to call GetIdletime(): %s\n", ++ aError->message); ++ }); + } - RefPtr iTime = dont_AddRef(g_variant_get_child_value(result, 0)); - if (!g_variant_is_of_type(iTime, G_VARIANT_TYPE_UINT64)) { - MOZ_LOG( @@ -47,42 +88,6 @@ diff --git a/widget/gtk/nsUserIdleServiceGTK.cpp b/widget/gtk/nsUserIdleServiceG - } - *aIdleTime = idleTime; + -+ DBusProxyCall(mProxy, "GetIdletime", nullptr, G_DBUS_CALL_FLAGS_NONE, -1, -+ mCancellable) -+ ->Then( -+ GetCurrentSerialEventTarget(), __func__, -+ // It's safe to capture this as we use mCancellable to stop -+ // listening. -+ [this](RefPtr&& aResult) { -+ if (!g_variant_is_of_type(aResult, G_VARIANT_TYPE_TUPLE) || -+ g_variant_n_children(aResult) != 1) { -+ MOZ_LOG(sIdleLog, LogLevel::Info, -+ ("PollIdleTime() Unexpected params type: %s\n", -+ g_variant_get_type_string(aResult))); -+ mLastIdleTime = 0; -+ return; -+ } -+ RefPtr iTime = -+ dont_AddRef(g_variant_get_child_value(aResult, 0)); -+ if (!g_variant_is_of_type(iTime, G_VARIANT_TYPE_UINT64)) { -+ MOZ_LOG(sIdleLog, LogLevel::Info, -+ ("PollIdleTime() Unexpected params type: %s\n", -+ g_variant_get_type_string(aResult))); -+ mLastIdleTime = 0; -+ return; -+ } -+ uint64_t idleTime = g_variant_get_uint64(iTime); -+ if (idleTime > std::numeric_limits::max()) { -+ idleTime = std::numeric_limits::max(); -+ } -+ mLastIdleTime = idleTime; -+ MOZ_LOG(sIdleLog, LogLevel::Info, -+ ("Async handler got %d\n", mLastIdleTime)); -+ }, -+ [](GUniquePtr&& aError) { -+ g_warning("Failed to call GetIdletime(): %s\n", aError->message); -+ }); -+ + *aIdleTime = mLastIdleTime; MOZ_LOG(sIdleLog, LogLevel::Info, - ("UserIdleServiceMutter::PollIdleTime() %d\n", *aIdleTime)); @@ -92,13 +97,14 @@ diff --git a/widget/gtk/nsUserIdleServiceGTK.cpp b/widget/gtk/nsUserIdleServiceG bool ProbeImplementation( RefPtr aUserIdleServiceGTK) override { -@@ -229,10 +237,11 @@ +@@ -229,10 +243,12 @@ } private: RefPtr mProxy; RefPtr mCancellable; + uint32_t mLastIdleTime = 0; ++ bool mPollInProgress = false; }; #endif diff --git a/D192208.1699444906.diff b/D192208.1699444906.diff new file mode 100644 index 0000000..f77a357 --- /dev/null +++ b/D192208.1699444906.diff @@ -0,0 +1,201 @@ +diff --git a/widget/gtk/nsUserIdleServiceGTK.h b/widget/gtk/nsUserIdleServiceGTK.h +--- a/widget/gtk/nsUserIdleServiceGTK.h ++++ b/widget/gtk/nsUserIdleServiceGTK.h +@@ -14,18 +14,20 @@ + + class nsUserIdleServiceGTK; + + class UserIdleServiceImpl { + public: +- NS_INLINE_DECL_REFCOUNTING(UserIdleServiceImpl); ++ explicit UserIdleServiceImpl(nsUserIdleServiceGTK* aUserIdleService) ++ : mUserIdleServiceGTK(aUserIdleService){}; + + virtual bool PollIdleTime(uint32_t* aIdleTime) = 0; +- virtual bool ProbeImplementation( +- RefPtr aUserIdleServiceGTK) = 0; ++ virtual bool ProbeImplementation() = 0; ++ ++ virtual ~UserIdleServiceImpl() = default; + + protected: +- virtual ~UserIdleServiceImpl() = default; ++ nsUserIdleServiceGTK* mUserIdleServiceGTK; + }; + + #define IDLE_SERVICE_MUTTER 0 + #define IDLE_SERVICE_XSCREENSAVER 1 + #define IDLE_SERVICE_NONE 2 +@@ -61,11 +63,11 @@ + nsUserIdleServiceGTK() = default; + + private: + ~nsUserIdleServiceGTK() = default; + +- RefPtr mIdleService; ++ mozilla::UniquePtr mIdleService; + #ifdef MOZ_ENABLE_DBUS + int mIdleServiceType = IDLE_SERVICE_MUTTER; + #else + int mIdleServiceType = IDLE_SERVICE_XSCREENSAVER; + #endif +diff --git a/widget/gtk/nsUserIdleServiceGTK.cpp b/widget/gtk/nsUserIdleServiceGTK.cpp +--- a/widget/gtk/nsUserIdleServiceGTK.cpp ++++ b/widget/gtk/nsUserIdleServiceGTK.cpp +@@ -74,12 +74,11 @@ + MOZ_LOG(sIdleLog, LogLevel::Warning, + ("XSSQueryExtension returned false!\n")); + return false; + } + +- bool ProbeImplementation( +- RefPtr aUserIdleServiceGTK) override { ++ bool ProbeImplementation() override { + MOZ_LOG(sIdleLog, LogLevel::Info, + ("UserIdleServiceX11::UserIdleServiceX11()\n")); + + if (!mozilla::widget::GdkIsX11Display()) { + return false; +@@ -114,15 +113,17 @@ + // We're missing X11 symbols + return false; + } + + // UserIdleServiceX11 uses sync init, confirm it now. +- aUserIdleServiceGTK->AcceptServiceCallback(); ++ mUserIdleServiceGTK->AcceptServiceCallback(); + return true; + } + +- protected: ++ explicit UserIdleServiceX11(nsUserIdleServiceGTK* aUserIdleService) ++ : UserIdleServiceImpl(aUserIdleService){}; ++ + ~UserIdleServiceX11() { + # ifdef MOZ_X11 + if (mXssInfo) { + XFree(mXssInfo); + } +@@ -164,11 +165,11 @@ + mCancellable) + ->Then( + GetCurrentSerialEventTarget(), __func__, + // It's safe to capture this as we use mCancellable to stop + // listening. +- [self = RefPtr{this}, this](RefPtr&& aResult) { ++ [this](RefPtr&& aResult) { + if (!g_variant_is_of_type(aResult, G_VARIANT_TYPE_TUPLE) || + g_variant_n_children(aResult) != 1) { + MOZ_LOG(sIdleLog, LogLevel::Info, + ("PollIdleTime() Unexpected params type: %s\n", + g_variant_get_type_string(aResult))); +@@ -191,25 +192,25 @@ + mLastIdleTime = idleTime; + mPollInProgress = false; + MOZ_LOG(sIdleLog, LogLevel::Info, + ("Async handler got %d\n", mLastIdleTime)); + }, +- [self = RefPtr{this}, this](GUniquePtr&& aError) { ++ [this](GUniquePtr&& aError) { + mPollInProgress = false; + g_warning("Failed to call GetIdletime(): %s\n", + aError->message); ++ mUserIdleServiceGTK->RejectAndTryNextServiceCallback(); + }); + } + + *aIdleTime = mLastIdleTime; + MOZ_LOG(sIdleLog, LogLevel::Info, + ("PollIdleTime() returns %d\n", *aIdleTime)); + return true; + } + +- bool ProbeImplementation( +- RefPtr aUserIdleServiceGTK) override { ++ bool ProbeImplementation() override { + MOZ_LOG(sIdleLog, LogLevel::Info, + ("UserIdleServiceMutter::UserIdleServiceMutter()\n")); + + mCancellable = dont_AddRef(g_cancellable_new()); + CreateDBusProxyForBus( +@@ -219,23 +220,23 @@ + nullptr, "org.gnome.Mutter.IdleMonitor", + "/org/gnome/Mutter/IdleMonitor/Core", "org.gnome.Mutter.IdleMonitor", + mCancellable) + ->Then( + GetCurrentSerialEventTarget(), __func__, +- [self = RefPtr{this}, service = RefPtr{aUserIdleServiceGTK}]( +- RefPtr&& aProxy) { +- self->mProxy = std::move(aProxy); +- service->AcceptServiceCallback(); ++ [this](RefPtr&& aProxy) { ++ mProxy = std::move(aProxy); ++ mUserIdleServiceGTK->AcceptServiceCallback(); + }, +- [self = RefPtr{this}, service = RefPtr{aUserIdleServiceGTK}]( +- GUniquePtr&& aError) { +- service->RejectAndTryNextServiceCallback(); ++ [this](GUniquePtr&& aError) { ++ mUserIdleServiceGTK->RejectAndTryNextServiceCallback(); + }); + return true; + } + +- protected: ++ explicit UserIdleServiceMutter(nsUserIdleServiceGTK* aUserIdleService) ++ : UserIdleServiceImpl(aUserIdleService){}; ++ + ~UserIdleServiceMutter() { + if (mCancellable) { + g_cancellable_cancel(mCancellable); + mCancellable = nullptr; + } +@@ -257,23 +258,23 @@ + MOZ_ASSERT(!mIdleService); + + switch (mIdleServiceType) { + #ifdef MOZ_ENABLE_DBUS + case IDLE_SERVICE_MUTTER: +- mIdleService = new UserIdleServiceMutter(); ++ mIdleService = MakeUnique(this); + break; + #endif + #ifdef MOZ_X11 + case IDLE_SERVICE_XSCREENSAVER: +- mIdleService = new UserIdleServiceX11(); ++ mIdleService = MakeUnique(this); + break; + #endif + default: + return; + } + +- if (!mIdleService->ProbeImplementation(this)) { ++ if (!mIdleService->ProbeImplementation()) { + RejectAndTryNextServiceCallback(); + } + } + + void nsUserIdleServiceGTK::AcceptServiceCallback() { +@@ -289,19 +290,19 @@ + mIdleServiceType)); + + // Delete recent non-working service + MOZ_ASSERT(mIdleService, "Nothing to reject?"); + mIdleService = nullptr; ++ mIdleServiceInitialized = false; + + mIdleServiceType++; + if (mIdleServiceType < IDLE_SERVICE_NONE) { + MOZ_LOG(sIdleLog, LogLevel::Info, + ("nsUserIdleServiceGTK try next idle service\n")); + ProbeService(); + } else { + MOZ_LOG(sIdleLog, LogLevel::Info, ("nsUserIdleServiceGTK failed\n")); +- mIdleServiceInitialized = false; + } + } + + bool nsUserIdleServiceGTK::PollIdleTime(uint32_t* aIdleTime) { + if (!mIdleServiceInitialized) { + diff --git a/firefox.spec b/firefox.spec index eec28df..41d431c 100644 --- a/firefox.spec +++ b/firefox.spec @@ -169,7 +169,7 @@ ExcludeArch: i686 Summary: Mozilla Firefox Web browser Name: firefox Version: 119.0 -Release: 4%{?pre_tag}%{?dist} +Release: 5%{?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 @@ -248,8 +248,9 @@ Patch242: 0026-Add-KDE-integration-to-Firefox.patch Patch402: mozilla-1196777.patch Patch407: mozilla-1667096.patch Patch408: D167159.diff -Patch409: D192061.1698487416.diff -Patch410: mozilla-1762816.patch +Patch409: D192061.1699444912.diff +Patch410: D192208.1699444906.diff +Patch411: mozilla-1762816.patch # PGO/LTO patches Patch600: pgo.patch @@ -542,7 +543,8 @@ This package contains results of tests executed during build. %patch407 -p1 -b .1667096 %patch408 -p1 -b .D167159 %patch409 -p1 -b .D192061 -%patch410 -p1 -b .mozilla-1762816 +%patch410 -p1 -b .D192208 +%patch411 -p1 -b .mozilla-1762816 # PGO patches %if %{build_with_pgo} @@ -1151,7 +1153,10 @@ fi #--------------------------------------------------------------------- %changelog -* Mon Nov 06 2023 Martin Stransky - 119.0-3 +* Tue Nov 07 2023 Martin Stransky - 119.0-5 +- Added fix for rhbz#2247665 + +* Mon Nov 06 2023 Martin Stransky - 119.0-4 - Added fix for mzbz#1762816 * Mon Oct 30 2023 Jan Horak - 119.0-3