Added fix for mzbz#1861615

This commit is contained in:
Martin Stransky 2023-10-27 12:10:26 +02:00
parent 29b8dda20b
commit b896e22d66
2 changed files with 113 additions and 1 deletions

107
D192061.1698487416.diff Normal file
View File

@ -0,0 +1,107 @@
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 @@
#ifdef MOZ_ENABLE_DBUS
class UserIdleServiceMutter : public UserIdleServiceImpl {
public:
bool PollIdleTime(uint32_t* aIdleTime) override {
- MOZ_LOG(sIdleLog, LogLevel::Info,
- ("UserIdleServiceMutter::PollIdleTime()\n"));
-
- MOZ_ASSERT(mProxy);
- GUniquePtr<GError> error;
+ MOZ_LOG(sIdleLog, LogLevel::Info, ("PollIdleTime() request\n"));
- RefPtr<GVariant> result = dont_AddRef(g_dbus_proxy_call_sync(
- mProxy, "GetIdletime", nullptr, G_DBUS_CALL_FLAGS_NONE, -1,
- mCancellable, getter_Transfers(error)));
- if (!result) {
- MOZ_LOG(sIdleLog, LogLevel::Info,
- ("UserIdleServiceMutter::PollIdleTime() failed, message: %s\n",
- error->message));
+ // We're not ready yet
+ if (!mProxy) {
return false;
}
- if (!g_variant_is_of_type(result, G_VARIANT_TYPE_TUPLE) ||
- g_variant_n_children(result) != 1) {
- MOZ_LOG(
- sIdleLog, LogLevel::Info,
- ("UserIdleServiceMutter::PollIdleTime() Unexpected params type: %s\n",
- g_variant_get_type_string(result)));
- return false;
- }
- RefPtr<GVariant> iTime = dont_AddRef(g_variant_get_child_value(result, 0));
- if (!g_variant_is_of_type(iTime, G_VARIANT_TYPE_UINT64)) {
- MOZ_LOG(
- sIdleLog, LogLevel::Info,
- ("UserIdleServiceMutter::PollIdleTime() Unexpected params type: %s\n",
- g_variant_get_type_string(result)));
- return false;
- }
- uint64_t idleTime = g_variant_get_uint64(iTime);
- if (idleTime > std::numeric_limits<uint32_t>::max()) {
- idleTime = std::numeric_limits<uint32_t>::max();
- }
- *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;
MOZ_LOG(sIdleLog, LogLevel::Info,
- ("UserIdleServiceMutter::PollIdleTime() %d\n", *aIdleTime));
+ ("PollIdleTime() returns %d\n", *aIdleTime));
return true;
}
bool ProbeImplementation(
RefPtr<nsUserIdleServiceGTK> aUserIdleServiceGTK) override {
@@ -229,10 +237,11 @@
}
private:
RefPtr<GDBusProxy> mProxy;
RefPtr<GCancellable> mCancellable;
+ uint32_t mLastIdleTime = 0;
};
#endif
void nsUserIdleServiceGTK::ProbeService() {
MOZ_LOG(sIdleLog, LogLevel::Info,

View File

@ -169,7 +169,7 @@ ExcludeArch: i686
Summary: Mozilla Firefox Web browser
Name: firefox
Version: 119.0
Release: 1%{?pre_tag}%{?dist}
Release: 2%{?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
@ -245,6 +245,7 @@ Patch231: fedora-customization.patch
Patch402: mozilla-1196777.patch
Patch407: mozilla-1667096.patch
Patch408: D167159.diff
Patch409: D192061.1698487416.diff
# PGO/LTO patches
Patch600: pgo.patch
@ -533,6 +534,7 @@ This package contains results of tests executed during build.
%patch402 -p1 -b .1196777
%patch407 -p1 -b .1667096
%patch408 -p1 -b .D167159
%patch409 -p1 -b .D192061
# PGO patches
%if %{build_with_pgo}
@ -1123,6 +1125,9 @@ fi
#---------------------------------------------------------------------
%changelog
* Fri Oct 27 2023 Martin Stransky <stransky@redhat.com>- 119.0-2
- Added fix for mzbz#1861615
* Tue Oct 24 2023 Martin Stransky <stransky@redhat.com>- 119.0-1
- Updated to 119.0