- Revision
- 265056
- Author
- jer.no...@apple.com
- Date
- 2020-07-29 14:22:43 -0700 (Wed, 29 Jul 2020)
Log Message
REGRESSION(r264476): Calling systemHasAC() regresses launch time performance
https://bugs.webkit.org/show_bug.cgi?id=214907
<rdar://problem/66191430>
Reviewed by Eric Carlson.
Source/WebCore:
Because calling into IOPS can block, delay queries about AC state during WebProcessPool creation until
the next run-loop.
Simultaneously, we don't need to check HDR state in the UI process for IOS, so send a default value
there as well.
* platform/cocoa/PowerSourceNotifier.h:
* platform/cocoa/PowerSourceNotifier.mm:
(WebCore::PowerSourceNotifier::PowerSourceNotifier):
* platform/cocoa/SystemBattery.h:
* platform/cocoa/SystemBattery.mm:
(WebCore::cachedSystemHasAC):
* platform/ios/PlatformScreenIOS.mm:
(WebCore::collectScreenProperties):
Source/WebKit:
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (265055 => 265056)
--- trunk/Source/WebCore/ChangeLog 2020-07-29 21:21:17 UTC (rev 265055)
+++ trunk/Source/WebCore/ChangeLog 2020-07-29 21:22:43 UTC (rev 265056)
@@ -1,3 +1,26 @@
+2020-07-29 Jer Noble <jer.no...@apple.com>
+
+ REGRESSION(r264476): Calling systemHasAC() regresses launch time performance
+ https://bugs.webkit.org/show_bug.cgi?id=214907
+ <rdar://problem/66191430>
+
+ Reviewed by Eric Carlson.
+
+ Because calling into IOPS can block, delay queries about AC state during WebProcessPool creation until
+ the next run-loop.
+
+ Simultaneously, we don't need to check HDR state in the UI process for IOS, so send a default value
+ there as well.
+
+ * platform/cocoa/PowerSourceNotifier.h:
+ * platform/cocoa/PowerSourceNotifier.mm:
+ (WebCore::PowerSourceNotifier::PowerSourceNotifier):
+ * platform/cocoa/SystemBattery.h:
+ * platform/cocoa/SystemBattery.mm:
+ (WebCore::cachedSystemHasAC):
+ * platform/ios/PlatformScreenIOS.mm:
+ (WebCore::collectScreenProperties):
+
2020-07-29 Don Olmstead <don.olmst...@sony.com>
Remove USE(ZLIB)
Modified: trunk/Source/WebCore/platform/cocoa/PowerSourceNotifier.h (265055 => 265056)
--- trunk/Source/WebCore/platform/cocoa/PowerSourceNotifier.h 2020-07-29 21:21:17 UTC (rev 265055)
+++ trunk/Source/WebCore/platform/cocoa/PowerSourceNotifier.h 2020-07-29 21:22:43 UTC (rev 265056)
@@ -26,10 +26,11 @@
#pragma once
#include <wtf/Function.h>
+#include <wtf/WeakPtr.h>
namespace WebCore {
-class PowerSourceNotifier {
+class PowerSourceNotifier : public CanMakeWeakPtr<PowerSourceNotifier> {
WTF_MAKE_FAST_ALLOCATED;
public:
using PowerSourceNotifierCallback = WTF::Function<void(bool hasAC)>;
Modified: trunk/Source/WebCore/platform/cocoa/PowerSourceNotifier.mm (265055 => 265056)
--- trunk/Source/WebCore/platform/cocoa/PowerSourceNotifier.mm 2020-07-29 21:21:17 UTC (rev 265055)
+++ trunk/Source/WebCore/platform/cocoa/PowerSourceNotifier.mm 2020-07-29 21:22:43 UTC (rev 265056)
@@ -36,11 +36,20 @@
: m_callback(WTFMove(callback))
{
int token = 0;
- auto status = notify_register_dispatch(kIOPSNotifyPowerSource, &token, dispatch_get_main_queue(), ^(int) {
- notifyPowerSourceChanged();
+ auto status = notify_register_dispatch(kIOPSNotifyPowerSource, &token, dispatch_get_main_queue(), [weakThis = makeWeakPtr(*this)] (int) {
+ if (weakThis)
+ weakThis->notifyPowerSourceChanged();
});
if (status == NOTIFY_STATUS_OK)
m_tokenID = token;
+
+ // If the current value of systemHasAC() is uncached, force a notification.
+ if (!cachedSystemHasAC()) {
+ dispatch_async(dispatch_get_main_queue(), [weakThis = makeWeakPtr(*this)] {
+ if (weakThis)
+ weakThis->notifyPowerSourceChanged();
+ });
+ }
}
PowerSourceNotifier::~PowerSourceNotifier()
Modified: trunk/Source/WebCore/platform/cocoa/SystemBattery.h (265055 => 265056)
--- trunk/Source/WebCore/platform/cocoa/SystemBattery.h 2020-07-29 21:21:17 UTC (rev 265055)
+++ trunk/Source/WebCore/platform/cocoa/SystemBattery.h 2020-07-29 21:22:43 UTC (rev 265056)
@@ -33,6 +33,7 @@
WEBCORE_EXPORT void resetSystemHasAC();
WEBCORE_EXPORT void setSystemHasAC(bool);
WEBCORE_EXPORT bool systemHasAC();
+WEBCORE_EXPORT Optional<bool> cachedSystemHasAC();
WEBCORE_EXPORT void setOverrideSystemHasBatteryForTesting(Optional<bool>&&);
WEBCORE_EXPORT void setOverrideSystemHasACForTesting(Optional<bool>&&);
Modified: trunk/Source/WebCore/platform/cocoa/SystemBattery.mm (265055 => 265056)
--- trunk/Source/WebCore/platform/cocoa/SystemBattery.mm 2020-07-29 21:21:17 UTC (rev 265055)
+++ trunk/Source/WebCore/platform/cocoa/SystemBattery.mm 2020-07-29 21:22:43 UTC (rev 265056)
@@ -116,6 +116,11 @@
return *hasAC;
}
+Optional<bool> cachedSystemHasAC()
+{
+ return hasAC;
+}
+
void setOverrideSystemHasBatteryForTesting(Optional<bool>&& hasBattery)
{
hasBatteryOverrideForTesting = WTFMove(hasBattery);
Modified: trunk/Source/WebCore/platform/ios/PlatformScreenIOS.mm (265055 => 265056)
--- trunk/Source/WebCore/platform/ios/PlatformScreenIOS.mm 2020-07-29 21:21:17 UTC (rev 265055)
+++ trunk/Source/WebCore/platform/ios/PlatformScreenIOS.mm 2020-07-29 21:22:43 UTC (rev 265056)
@@ -200,10 +200,9 @@
int screenDepthPerComponent = WebCore::screenDepthPerComponent(nullptr);
bool screenSupportsExtendedColor = WebCore::screenSupportsExtendedColor(nullptr);
bool screenHasInvertedColors = WebCore::screenHasInvertedColors();
- bool hdr = screenSupportsHighDynamicRange(nullptr);
float scaleFactor = WebCore::screenPPIFactor();
- screenProperties.screenDataMap.set(++displayID, ScreenData { screenAvailableRect, screenRect, colorSpace, screenDepth, screenDepthPerComponent, screenSupportsExtendedColor, screenHasInvertedColors, hdr, scaleFactor });
+ screenProperties.screenDataMap.set(++displayID, ScreenData { screenAvailableRect, screenRect, colorSpace, screenDepth, screenDepthPerComponent, screenSupportsExtendedColor, screenHasInvertedColors, false, scaleFactor });
if (screen == [PAL::getUIScreenClass() mainScreen])
screenProperties.primaryDisplayID = displayID;
Modified: trunk/Source/WebKit/ChangeLog (265055 => 265056)
--- trunk/Source/WebKit/ChangeLog 2020-07-29 21:21:17 UTC (rev 265055)
+++ trunk/Source/WebKit/ChangeLog 2020-07-29 21:22:43 UTC (rev 265056)
@@ -1,3 +1,14 @@
+2020-07-29 Jer Noble <jer.no...@apple.com>
+
+ REGRESSION(r264476): Calling systemHasAC() regresses launch time performance
+ https://bugs.webkit.org/show_bug.cgi?id=214907
+ <rdar://problem/66191430>
+
+ Reviewed by Eric Carlson.
+
+ * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+ (WebKit::WebProcessPool::platformInitializeWebProcess):
+
2020-07-29 Darin Adler <da...@apple.com>
Improve range idioms and other changes to prepare the way for more reduction in live range use
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (265055 => 265056)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2020-07-29 21:21:17 UTC (rev 265055)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2020-07-29 21:22:43 UTC (rev 265056)
@@ -408,7 +408,7 @@
#if PLATFORM(COCOA)
parameters.systemHasBattery = systemHasBattery();
- parameters.systemHasAC = systemHasAC();
+ parameters.systemHasAC = cachedSystemHasAC().valueOr(true);
SandboxExtension::Handle mapDBHandle;
if (SandboxExtension::createHandleForMachLookup("com.apple.lsd.mapdb"_s, WTF::nullopt, mapDBHandle, SandboxExtension::Flags::NoReport))