Added fix for rhbz#2247665

This commit is contained in:
Martin Stransky 2023-11-07 13:07:16 +01:00
parent ffa346e745
commit 5364193d8d
3 changed files with 256 additions and 44 deletions

View File

@ -1,7 +1,7 @@
diff --git a/widget/gtk/nsUserIdleServiceGTK.cpp b/widget/gtk/nsUserIdleServiceGTK.cpp diff --git a/widget/gtk/nsUserIdleServiceGTK.cpp b/widget/gtk/nsUserIdleServiceGTK.cpp
--- a/widget/gtk/nsUserIdleServiceGTK.cpp --- a/widget/gtk/nsUserIdleServiceGTK.cpp
+++ b/widget/gtk/nsUserIdleServiceGTK.cpp +++ b/widget/gtk/nsUserIdleServiceGTK.cpp
@@ -149,48 +149,56 @@ @@ -149,48 +149,62 @@
#ifdef MOZ_ENABLE_DBUS #ifdef MOZ_ENABLE_DBUS
class UserIdleServiceMutter : public UserIdleServiceImpl { 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", - ("UserIdleServiceMutter::PollIdleTime() Unexpected params type: %s\n",
- g_variant_get_type_string(result))); - g_variant_get_type_string(result)));
- return false; - 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<GVariant>&& 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<GVariant> 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<uint32_t>::max()) {
+ idleTime = std::numeric_limits<uint32_t>::max();
+ }
+ mLastIdleTime = idleTime;
+ mPollInProgress = false;
+ MOZ_LOG(sIdleLog, LogLevel::Info,
+ ("Async handler got %d\n", mLastIdleTime));
+ },
+ [self = RefPtr{this}, this](GUniquePtr<GError>&& aError) {
+ mPollInProgress = false;
+ g_warning("Failed to call GetIdletime(): %s\n",
+ aError->message);
+ });
}
- RefPtr<GVariant> iTime = dont_AddRef(g_variant_get_child_value(result, 0)); - RefPtr<GVariant> iTime = dont_AddRef(g_variant_get_child_value(result, 0));
- if (!g_variant_is_of_type(iTime, G_VARIANT_TYPE_UINT64)) { - if (!g_variant_is_of_type(iTime, G_VARIANT_TYPE_UINT64)) {
- MOZ_LOG( - MOZ_LOG(
@ -47,42 +88,6 @@ diff --git a/widget/gtk/nsUserIdleServiceGTK.cpp b/widget/gtk/nsUserIdleServiceG
- } - }
- *aIdleTime = idleTime; - *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<GVariant>&& 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<GVariant> 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<uint32_t>::max()) {
+ idleTime = std::numeric_limits<uint32_t>::max();
+ }
+ mLastIdleTime = idleTime;
+ MOZ_LOG(sIdleLog, LogLevel::Info,
+ ("Async handler got %d\n", mLastIdleTime));
+ },
+ [](GUniquePtr<GError>&& aError) {
+ g_warning("Failed to call GetIdletime(): %s\n", aError->message);
+ });
+
+ *aIdleTime = mLastIdleTime; + *aIdleTime = mLastIdleTime;
MOZ_LOG(sIdleLog, LogLevel::Info, MOZ_LOG(sIdleLog, LogLevel::Info,
- ("UserIdleServiceMutter::PollIdleTime() %d\n", *aIdleTime)); - ("UserIdleServiceMutter::PollIdleTime() %d\n", *aIdleTime));
@ -92,13 +97,14 @@ diff --git a/widget/gtk/nsUserIdleServiceGTK.cpp b/widget/gtk/nsUserIdleServiceG
bool ProbeImplementation( bool ProbeImplementation(
RefPtr<nsUserIdleServiceGTK> aUserIdleServiceGTK) override { RefPtr<nsUserIdleServiceGTK> aUserIdleServiceGTK) override {
@@ -229,10 +237,11 @@ @@ -229,10 +243,12 @@
} }
private: private:
RefPtr<GDBusProxy> mProxy; RefPtr<GDBusProxy> mProxy;
RefPtr<GCancellable> mCancellable; RefPtr<GCancellable> mCancellable;
+ uint32_t mLastIdleTime = 0; + uint32_t mLastIdleTime = 0;
+ bool mPollInProgress = false;
}; };
#endif #endif

201
D192208.1699444906.diff Normal file
View File

@ -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<nsUserIdleServiceGTK> 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<UserIdleServiceImpl> mIdleService;
+ mozilla::UniquePtr<UserIdleServiceImpl> 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<nsUserIdleServiceGTK> 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<GVariant>&& aResult) {
+ [this](RefPtr<GVariant>&& 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<GError>&& aError) {
+ [this](GUniquePtr<GError>&& 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<nsUserIdleServiceGTK> 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<GDBusProxy>&& aProxy) {
- self->mProxy = std::move(aProxy);
- service->AcceptServiceCallback();
+ [this](RefPtr<GDBusProxy>&& aProxy) {
+ mProxy = std::move(aProxy);
+ mUserIdleServiceGTK->AcceptServiceCallback();
},
- [self = RefPtr{this}, service = RefPtr{aUserIdleServiceGTK}](
- GUniquePtr<GError>&& aError) {
- service->RejectAndTryNextServiceCallback();
+ [this](GUniquePtr<GError>&& 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<UserIdleServiceMutter>(this);
break;
#endif
#ifdef MOZ_X11
case IDLE_SERVICE_XSCREENSAVER:
- mIdleService = new UserIdleServiceX11();
+ mIdleService = MakeUnique<UserIdleServiceX11>(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) {

View File

@ -169,7 +169,7 @@ ExcludeArch: i686
Summary: Mozilla Firefox Web browser Summary: Mozilla Firefox Web browser
Name: firefox Name: firefox
Version: 119.0 Version: 119.0
Release: 4%{?pre_tag}%{?dist} Release: 5%{?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
@ -248,8 +248,9 @@ Patch242: 0026-Add-KDE-integration-to-Firefox.patch
Patch402: mozilla-1196777.patch Patch402: mozilla-1196777.patch
Patch407: mozilla-1667096.patch Patch407: mozilla-1667096.patch
Patch408: D167159.diff Patch408: D167159.diff
Patch409: D192061.1698487416.diff Patch409: D192061.1699444912.diff
Patch410: mozilla-1762816.patch Patch410: D192208.1699444906.diff
Patch411: mozilla-1762816.patch
# PGO/LTO patches # PGO/LTO patches
Patch600: pgo.patch Patch600: pgo.patch
@ -542,7 +543,8 @@ This package contains results of tests executed during build.
%patch407 -p1 -b .1667096 %patch407 -p1 -b .1667096
%patch408 -p1 -b .D167159 %patch408 -p1 -b .D167159
%patch409 -p1 -b .D192061 %patch409 -p1 -b .D192061
%patch410 -p1 -b .mozilla-1762816 %patch410 -p1 -b .D192208
%patch411 -p1 -b .mozilla-1762816
# PGO patches # PGO patches
%if %{build_with_pgo} %if %{build_with_pgo}
@ -1151,7 +1153,10 @@ fi
#--------------------------------------------------------------------- #---------------------------------------------------------------------
%changelog %changelog
* Mon Nov 06 2023 Martin Stransky <stransky@redhat.com>- 119.0-3 * Tue Nov 07 2023 Martin Stransky <stransky@redhat.com>- 119.0-5
- Added fix for rhbz#2247665
* Mon Nov 06 2023 Martin Stransky <stransky@redhat.com>- 119.0-4
- Added fix for mzbz#1762816 - Added fix for mzbz#1762816
* Mon Oct 30 2023 Jan Horak <jhorak@redhat.com> - 119.0-3 * Mon Oct 30 2023 Jan Horak <jhorak@redhat.com> - 119.0-3