WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
231958
[GTK] Rewrite LowPowerModeNotifier to use GPowerProfileMonitor
https://bugs.webkit.org/show_bug.cgi?id=231958
Summary
[GTK] Rewrite LowPowerModeNotifier to use GPowerProfileMonitor
Patrick Griffis
Reported
2021-10-19 09:02:02 PDT
[GTK] Rewrite LowPowerModeNotifier to use GPowerProfileMonitor
Attachments
Patch
(5.18 KB, patch)
2021-10-19 09:02 PDT
,
Patrick Griffis
no flags
Details
Formatted Diff
Diff
Patch
(6.46 KB, patch)
2021-10-19 09:04 PDT
,
Patrick Griffis
no flags
Details
Formatted Diff
Diff
Patch
(6.74 KB, patch)
2021-10-20 10:14 PDT
,
Patrick Griffis
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(6.47 KB, patch)
2021-10-20 10:53 PDT
,
Patrick Griffis
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(6.47 KB, patch)
2021-10-20 11:21 PDT
,
Patrick Griffis
no flags
Details
Formatted Diff
Diff
Patch
(6.46 KB, patch)
2021-10-21 07:21 PDT
,
Patrick Griffis
no flags
Details
Formatted Diff
Diff
Show Obsolete
(5)
View All
Add attachment
proposed patch, testcase, etc.
Patrick Griffis
Comment 1
2021-10-19 09:02:11 PDT
Created
attachment 441733
[details]
Patch
Patrick Griffis
Comment 2
2021-10-19 09:04:26 PDT
Created
attachment 441734
[details]
Patch
Michael Catanzaro
Comment 3
2021-10-19 09:18:31 PDT
This fixes
bug #179978
, right? Why not reuse that bug?
Patrick Griffis
Comment 4
2021-10-19 09:21:21 PDT
(In reply to Michael Catanzaro from
comment #3
)
> This fixes
bug #179978
, right? Why not reuse that bug?
I forgot it was a thing until I already did it. :/
Michael Catanzaro
Comment 5
2021-10-19 09:33:45 PDT
***
Bug 179978
has been marked as a duplicate of this bug. ***
Michael Catanzaro
Comment 6
2021-10-19 09:41:25 PDT
Comment on
attachment 441734
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=441734&action=review
This is nice.
> Source/WebCore/platform/LowPowerModeNotifier.h:65 > #elif USE(GLIB) > - void updateWarningLevel(); > - void warningLevelChanged(); > - static void gPropertiesChangedCallback(LowPowerModeNotifier*, GVariant* changedProperties); > + static void powerSaverEnabledNotifyCallback(LowPowerModeNotifier*, GParamSpec*, GPowerProfileMonitor*); > > - GRefPtr<GDBusProxy> m_displayDeviceProxy; > - GRefPtr<GCancellable> m_cancellable; > +#if GLIB_CHECK_VERSION(2, 69, 1) > + GRefPtr<GPowerProfileMonitor> m_powerProfileMonitor; > +#endif > LowPowerModeChangeCallback m_callback; > bool m_lowPowerModeEnabled { false };
Can you simplify things by doing #elif USE(GLIB) && GLIB_CHECK_VERSION(2, 69, 1) all in one condition? I bet it will turn out a little nicer. Ditto for the .cpp file.
Patrick Griffis
Comment 7
2021-10-19 11:35:30 PDT
(In reply to Michael Catanzaro from
comment #6
)
> Comment on
attachment 441734
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=441734&action=review
> Can you simplify things by doing #elif USE(GLIB) && GLIB_CHECK_VERSION(2, > 69, 1) all in one condition? I bet it will turn out a little nicer. Ditto > for the .cpp file.
Trying it out I think its just more messy. Like `m_lowPowerModeEnabled` defaulting to `false` and the impl just returning that results in less ifdefs. I also am not sure what changes you want in the .cpp file as its already as compact as it can be.
Michael Catanzaro
Comment 8
2021-10-19 12:59:47 PDT
Comment on
attachment 441734
[details]
Patch OK, LGTM. I'll save cq+ for Carlos Garcia, just in case he objects to removing the compat path for older GLib.
Carlos Garcia Campos
Comment 9
2021-10-20 00:58:07 PDT
Comment on
attachment 441734
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=441734&action=review
> Source/WebCore/platform/LowPowerModeNotifier.h:59 > + static void powerSaverEnabledNotifyCallback(LowPowerModeNotifier*, GParamSpec*, GPowerProfileMonitor*);
This is only used when glib is 2.69.1, we can use lambda instead for the callback though.
> Source/WebCore/platform/LowPowerModeNotifier.h:64 > LowPowerModeChangeCallback m_callback;
I think we could move this out of the ifdefs.
>> Source/WebCore/platform/LowPowerModeNotifier.h:65 >> bool m_lowPowerModeEnabled { false }; > > Can you simplify things by doing #elif USE(GLIB) && GLIB_CHECK_VERSION(2, 69, 1) all in one condition? I bet it will turn out a little nicer. Ditto for the .cpp file.
Do we still need m_lowPowerModeEnabled? Can't we just use g_power_profile_monitor_get_power_saver_enabled()?
> Source/WebCore/platform/glib/LowPowerModeNotifierGLib.cpp:32 > - : m_cancellable(adoptGRef(g_cancellable_new())) > - , m_callback(WTFMove(callback)) > + : m_callback(WTFMove(callback)) > {
Move the m_powerProfileMonitor initializartion here #if GLIB_CHECK_VERSION(2, 69, 1) , m_powerProfileMonitor(adoptGRef(g_power_profile_monitor_dup_default())) #endif
> Source/WebCore/platform/glib/LowPowerModeNotifierGLib.cpp:39 > + g_signal_connect_swapped(m_powerProfileMonitor.get(), "notify::power-saver-enabled", G_CALLBACK(powerSaverEnabledNotifyCallback), this);
You can use G_CALLBACK(+[](LowPowerModeNotifier* self, GParamSpec*, GPowerProfileMonitor* monitor) {
> Source/WebCore/platform/glib/LowPowerModeNotifierGLib.cpp:47 > + self->m_lowPowerModeEnabled = g_power_profile_monitor_get_power_saver_enabled(monitor); > + self->m_callback(self->m_lowPowerModeEnabled);
So, this could be self->m_callback(g_power_profile_monitor_get_power_saver_enabled(monitor));
> Source/WebCore/platform/glib/LowPowerModeNotifierGLib.cpp:-100 > - g_cancellable_cancel(m_cancellable.get());
Since we are getting a reference of a global object, unref won't destroy the monitor, so you must disconnect the notify signal or we will get a crash the nest time it changes.
Patrick Griffis
Comment 10
2021-10-20 10:14:26 PDT
Created
attachment 441893
[details]
Patch
Patrick Griffis
Comment 11
2021-10-20 10:53:45 PDT
Created
attachment 441898
[details]
Patch
Patrick Griffis
Comment 12
2021-10-20 11:03:55 PDT
(In reply to Carlos Garcia Campos from
comment #9
)
> Comment on
attachment 441734
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=441734&action=review
Thanks for the detailed review I've applied these changes.
> > Source/WebCore/platform/LowPowerModeNotifier.h:64 > > LowPowerModeChangeCallback m_callback; > > I think we could move this out of the ifdefs.
Moving this out caused other EWS failures regarding constructor ordering. I just found it cleaner to leave it as-is.
> > Can you simplify things by doing #elif USE(GLIB) && GLIB_CHECK_VERSION(2, 69, 1) all in one condition? I bet it will turn out a little nicer. Ditto for the .cpp file.
Windows EWS fails with this, the preprocessor doesn't like it, so I've kept it as two #ifdefs.
> > Source/WebCore/platform/glib/LowPowerModeNotifierGLib.cpp:-100 > > - g_cancellable_cancel(m_cancellable.get()); > > Since we are getting a reference of a global object, unref won't destroy the > monitor, so you must disconnect the notify signal or we will get a crash the > nest time it changes.
Good catch.
Patrick Griffis
Comment 13
2021-10-20 11:21:16 PDT
Created
attachment 441904
[details]
Patch
Carlos Garcia Campos
Comment 14
2021-10-21 01:34:26 PDT
Comment on
attachment 441904
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=441904&action=review
> Source/WebCore/platform/LowPowerModeNotifier.h:36 > +#include <gio/gio.h>
Move the include to the cpp file and here simply forward declare GPowerProfileMonitor
> Source/WebCore/platform/glib/LowPowerModeNotifierGLib.cpp:36 > + m_callback(isLowPowerModeEnabled());
Why do we call the callback here? It's expected to be called when the mode changes, no? or is it because the object can be created when already in low power mode? That's not needed because the caller is expected to check the mode right after creating the object.
Patrick Griffis
Comment 15
2021-10-21 07:21:11 PDT
Created
attachment 442018
[details]
Patch
EWS
Comment 16
2021-10-22 01:07:53 PDT
Committed
r284670
(
243390@main
): <
https://commits.webkit.org/243390@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 442018
[details]
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug