Changeset 228888 in webkit
- Timestamp:
- Feb 21, 2018 11:42:35 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r228826 r228888 1 2018-02-21 Michael Catanzaro <mcatanzaro@igalia.com> 2 3 [GTK] USE_UPOWER causes crashes inside a chroot or on systems with broken dbus/upower 4 https://bugs.webkit.org/show_bug.cgi?id=181825 5 6 Reviewed by Carlos Garcia Campos. 7 8 Get rid of the upower-glib dependency. We will use upower's D-Bus API instead. 9 10 * Source/cmake/FindUPowerGLib.cmake: Removed. 11 * Source/cmake/OptionsGTK.cmake: 12 1 13 2018-02-20 Adrian Perez de Castro <aperez@igalia.com> 2 14 -
trunk/Source/WebCore/ChangeLog
r228886 r228888 1 2018-02-21 Michael Catanzaro <mcatanzaro@igalia.com> 2 3 [GTK] USE_UPOWER causes crashes inside a chroot or on systems with broken dbus/upower 4 https://bugs.webkit.org/show_bug.cgi?id=181825 5 6 Reviewed by Carlos Garcia Campos. 7 8 We could fix this crash, but that would not be good enough, because upower-glib is a 9 synchronous API that wraps D-Bus calls. That's not acceptable for use in the web process. 10 Rewrite LowPowerModeNotifierGLib to use upower's D-Bus API directly, instead. 11 12 Note that this also enables LowPowerModeNotifier for WPE, since the USE(UPOWER) build 13 flag is no longer needed. 14 15 * platform/LowPowerModeNotifier.cpp: 16 * platform/LowPowerModeNotifier.h: 17 * platform/glib/LowPowerModeNotifierGLib.cpp: 18 (WebCore::LowPowerModeNotifier::LowPowerModeNotifier): 19 (WebCore::LowPowerModeNotifier::updateWarningLevel): 20 (WebCore::LowPowerModeNotifier::warningLevelChanged): 21 (WebCore::LowPowerModeNotifier::gPropertiesChangedCallback): 22 (WebCore::LowPowerModeNotifier::~LowPowerModeNotifier): 23 (WebCore::LowPowerModeNotifier::updateState): Deleted. 24 (WebCore::LowPowerModeNotifier::warningLevelCallback): Deleted. 25 1 26 2018-02-21 Chris Dumez <cdumez@apple.com> 2 27 -
trunk/Source/WebCore/platform/LowPowerModeNotifier.cpp
r223728 r228888 29 29 namespace WebCore { 30 30 31 #if !PLATFORM(IOS) && !USE( UPOWER)31 #if !PLATFORM(IOS) && !USE(GLIB) 32 32 33 33 LowPowerModeNotifier::LowPowerModeNotifier(LowPowerModeChangeCallback&&) -
trunk/Source/WebCore/platform/LowPowerModeNotifier.h
r222834 r228888 29 29 30 30 #if PLATFORM(IOS) 31 32 31 #include <wtf/RetainPtr.h> 33 32 OBJC_CLASS WebLowPowerModeObserver; 34 35 33 #endif 36 34 37 #if USE(UPOWER) 38 #include <libupower-glib/upower.h> 35 #if USE(GLIB) 39 36 #include <wtf/glib/GRefPtr.h> 37 typedef _GDBusProxy GDBusProxy; 40 38 #endif 41 39 … … 57 55 RetainPtr<WebLowPowerModeObserver> m_observer; 58 56 LowPowerModeChangeCallback m_callback; 59 #elif USE(UPOWER) 60 static void warningLevelCallback(LowPowerModeNotifier*); 61 void updateState(); 57 #elif USE(GLIB) 58 void updateWarningLevel(); 59 void warningLevelChanged(); 60 static void gPropertiesChangedCallback(LowPowerModeNotifier*, GVariant* changedProperties); 62 61 63 GRefPtr< UpClient> m_upClient;64 GRefPtr< UpDevice> m_device;62 GRefPtr<GDBusProxy> m_displayDeviceProxy; 63 GRefPtr<GCancellable> m_cancellable; 65 64 LowPowerModeChangeCallback m_callback; 66 65 bool m_lowPowerModeEnabled { false }; -
trunk/Source/WebCore/platform/glib/LowPowerModeNotifierGLib.cpp
r223954 r228888 1 1 /* 2 2 * Copyright (C) 2017 Collabora Ltd. 3 * Copyright (C) 2018 Igalia S.L. 3 4 * 4 5 * This library is free software; you can redistribute it and/or … … 20 21 #include "LowPowerModeNotifier.h" 21 22 22 #if USE(UPOWER) 23 #include <cstring> 24 #include <gio/gio.h> 25 23 26 namespace WebCore { 24 27 28 static const char kWarningLevel[] = "WarningLevel"; 29 25 30 LowPowerModeNotifier::LowPowerModeNotifier(LowPowerModeChangeCallback&& callback) 26 : m_upClient(adoptGRef(up_client_new())) 27 , m_device(adoptGRef(up_client_get_display_device(m_upClient.get()))) 31 : m_cancellable(adoptGRef(g_cancellable_new())) 28 32 , m_callback(WTFMove(callback)) 29 33 { 30 updateState(); 34 g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM, static_cast<GDBusProxyFlags>(G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS | G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES), 35 nullptr, "org.freedesktop.UPower", "/org/freedesktop/UPower/devices/DisplayDevice", "org.freedesktop.UPower.Device", m_cancellable.get(), 36 [](GObject*, GAsyncResult* result, gpointer userData) { 37 GUniqueOutPtr<GError> error; 38 GRefPtr<GDBusProxy> proxy = adoptGRef(g_dbus_proxy_new_for_bus_finish(result, &error.outPtr())); 39 if (g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED)) 40 return; 31 41 32 g_signal_connect_swapped(m_device.get(), "notify::warning-level", G_CALLBACK(warningLevelCallback), this); 42 auto* self = static_cast<LowPowerModeNotifier*>(userData); 43 if (proxy) { 44 GUniquePtr<char> nameOwner(g_dbus_proxy_get_name_owner(proxy.get())); 45 if (nameOwner) { 46 self->m_displayDeviceProxy = WTFMove(proxy); 47 self->updateWarningLevel(); 48 g_signal_connect_swapped(self->m_displayDeviceProxy.get(), "g-properties-changed", G_CALLBACK(gPropertiesChangedCallback), self); 49 return; 50 } 51 } 52 53 // Now, if there is no name owner, it would be good to try to 54 // connect to a Flatpak battery status portal instead. 55 // Unfortunately, no such portal currently exists. 56 self->m_cancellable = nullptr; 57 }, this); 33 58 } 34 59 35 void LowPowerModeNotifier::update State()60 void LowPowerModeNotifier::updateWarningLevel() 36 61 { 37 UpDeviceLevel warningLevel; 38 g_object_get(G_OBJECT(m_device.get()), "warning-level", &warningLevel, nullptr); 39 m_lowPowerModeEnabled = warningLevel > UP_DEVICE_LEVEL_NONE && warningLevel <= UP_DEVICE_LEVEL_ACTION; 62 GRefPtr<GVariant> variant = adoptGRef(g_dbus_proxy_get_cached_property(m_displayDeviceProxy.get(), kWarningLevel)); 63 if (!variant) { 64 m_lowPowerModeEnabled = false; 65 return; 66 } 67 68 // 0: Unknown 69 // 1: None 70 // 2: Discharging (only for universal power supplies) 71 // 3: Low 72 // 4: Critical 73 // 5: Action 74 m_lowPowerModeEnabled = g_variant_get_uint32(variant.get()) > 1; 40 75 } 41 76 42 void LowPowerModeNotifier::warningLevelC allback(LowPowerModeNotifier* notifier)77 void LowPowerModeNotifier::warningLevelChanged() 43 78 { 44 notifier->updateState(); 45 notifier->m_callback(notifier->m_lowPowerModeEnabled); 79 updateWarningLevel(); 80 m_callback(m_lowPowerModeEnabled); 81 } 82 83 void LowPowerModeNotifier::gPropertiesChangedCallback(LowPowerModeNotifier* self, GVariant* changedProperties) 84 { 85 GUniqueOutPtr<GVariantIter> iter; 86 g_variant_get(changedProperties, "a{sv}", &iter.outPtr()); 87 88 const char* propertyName; 89 while (g_variant_iter_next(iter.get(), "{&sv}", &propertyName, nullptr)) { 90 if (!strcmp(propertyName, kWarningLevel)) { 91 self->warningLevelChanged(); 92 break; 93 } 94 } 46 95 } 47 96 48 97 LowPowerModeNotifier::~LowPowerModeNotifier() 49 98 { 50 g_ signal_handlers_disconnect_by_data(m_device.get(), this);99 g_cancellable_cancel(m_cancellable.get()); 51 100 } 52 101 … … 56 105 } 57 106 58 } 59 #endif 107 } // namespace WebCore -
trunk/Source/cmake/OptionsGTK.cmake
r228590 r228888 82 82 WEBKIT_OPTION_DEFINE(USE_LIBHYPHEN "Whether to enable the default automatic hyphenation implementation." PUBLIC ON) 83 83 WEBKIT_OPTION_DEFINE(USE_LIBSECRET "Whether to enable the persistent credential storage using libsecret." PUBLIC ON) 84 WEBKIT_OPTION_DEFINE(USE_UPOWER "Whether to enable the low power mode implementation." PUBLIC ON)85 84 WEBKIT_OPTION_DEFINE(USE_WOFF2 "Whether to enable support for WOFF2 Web Fonts." PUBLIC ON) 86 85 … … 342 341 endif () 343 342 344 if (USE_UPOWER)345 find_package(UPowerGLib)346 if (NOT UPOWERGLIB_FOUND)347 message(FATAL_ERROR "upower-glib is needed for USE_UPOWER.")348 endif ()349 endif ()350 351 343 if (USE_WOFF2) 352 344 find_package(WOFF2Dec 1.0.2)
Note: See TracChangeset
for help on using the changeset viewer.