Diff
Modified: branches/safari-612-branch/Source/WebKit/ChangeLog (282936 => 282937)
--- branches/safari-612-branch/Source/WebKit/ChangeLog 2021-09-23 05:14:02 UTC (rev 282936)
+++ branches/safari-612-branch/Source/WebKit/ChangeLog 2021-09-23 05:14:06 UTC (rev 282937)
@@ -1,5 +1,64 @@
2021-09-22 Alan Coon <alanc...@apple.com>
+ Cherry-pick r282364. rdar://problem/83429561
+
+ Send preference updates to the GPU process
+ https://bugs.webkit.org/show_bug.cgi?id=230159
+ <rdar://81049367>
+
+ Reviewed by Brent Fulgham.
+
+ Like the WebContent process, the GPU process should also receive preference updates since it is blocking the preference service in the sandbox.
+ The common code to set a preference is being moved to the AuxiliaryProcess base class, so that also the GPU process can make use of it. When
+ the UI process is sending preference update messages to all the WebContent processes, it will now also send to the GPU process.
+
+ * GPUProcess/GPUProcess.h:
+ * GPUProcess/GPUProcess.messages.in:
+ * GPUProcess/cocoa/GPUProcessCocoa.mm:
+ (WebKit::GPUProcess::notifyPreferencesChanged):
+ * Shared/AuxiliaryProcess.h:
+ * Shared/Cocoa/AuxiliaryProcessCocoa.mm:
+ (WebKit::AuxiliaryProcess::decodePreferenceValue):
+ (WebKit::AuxiliaryProcess::setPreferenceValue):
+ * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+ (WebKit::WebProcessPool::notifyPreferencesChanged):
+ * WebProcess/cocoa/WebProcessCocoa.mm:
+ (WebKit::handlePreferenceChange):
+ (WebKit::WebProcess::notifyPreferencesChanged):
+ (WebKit::setPreferenceValue): Deleted.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282364 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-09-13 Per Arne Vollan <pvol...@apple.com>
+
+ Send preference updates to the GPU process
+ https://bugs.webkit.org/show_bug.cgi?id=230159
+ <rdar://81049367>
+
+ Reviewed by Brent Fulgham.
+
+ Like the WebContent process, the GPU process should also receive preference updates since it is blocking the preference service in the sandbox.
+ The common code to set a preference is being moved to the AuxiliaryProcess base class, so that also the GPU process can make use of it. When
+ the UI process is sending preference update messages to all the WebContent processes, it will now also send to the GPU process.
+
+ * GPUProcess/GPUProcess.h:
+ * GPUProcess/GPUProcess.messages.in:
+ * GPUProcess/cocoa/GPUProcessCocoa.mm:
+ (WebKit::GPUProcess::notifyPreferencesChanged):
+ * Shared/AuxiliaryProcess.h:
+ * Shared/Cocoa/AuxiliaryProcessCocoa.mm:
+ (WebKit::AuxiliaryProcess::decodePreferenceValue):
+ (WebKit::AuxiliaryProcess::setPreferenceValue):
+ * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+ (WebKit::WebProcessPool::notifyPreferencesChanged):
+ * WebProcess/cocoa/WebProcessCocoa.mm:
+ (WebKit::handlePreferenceChange):
+ (WebKit::WebProcess::notifyPreferencesChanged):
+ (WebKit::setPreferenceValue): Deleted.
+
+2021-09-22 Alan Coon <alanc...@apple.com>
+
Cherry-pick r282157. rdar://problem/83429907
Remove unneeded call on startup of WebContent process
Modified: branches/safari-612-branch/Source/WebKit/GPUProcess/GPUProcess.h (282936 => 282937)
--- branches/safari-612-branch/Source/WebKit/GPUProcess/GPUProcess.h 2021-09-23 05:14:02 UTC (rev 282936)
+++ branches/safari-612-branch/Source/WebKit/GPUProcess/GPUProcess.h 2021-09-23 05:14:06 UTC (rev 282937)
@@ -157,6 +157,10 @@
void setVorbisDecoderEnabled(bool);
#endif
+#if ENABLE(CFPREFS_DIRECT_MODE)
+ void notifyPreferencesChanged(const String& domain, const String& key, const std::optional<String>& encodedValue);
+#endif
+
// Connections to WebProcesses.
HashMap<WebCore::ProcessIdentifier, Ref<GPUConnectionToWebProcess>> m_webProcessConnections;
MonotonicTime m_creationTime { MonotonicTime::now() };
Modified: branches/safari-612-branch/Source/WebKit/GPUProcess/GPUProcess.messages.in (282936 => 282937)
--- branches/safari-612-branch/Source/WebKit/GPUProcess/GPUProcess.messages.in 2021-09-23 05:14:02 UTC (rev 282936)
+++ branches/safari-612-branch/Source/WebKit/GPUProcess/GPUProcess.messages.in 2021-09-23 05:14:06 UTC (rev 282937)
@@ -63,6 +63,10 @@
#if ENABLE(VORBIS)
SetVorbisDecoderEnabled(bool enabled);
#endif
+
+#if ENABLE(CFPREFS_DIRECT_MODE)
+ NotifyPreferencesChanged(String domain, String key, std::optional<String> encodedValue)
+#endif
}
#endif // ENABLE(GPU_PROCESS)
Modified: branches/safari-612-branch/Source/WebKit/GPUProcess/cocoa/GPUProcessCocoa.mm (282936 => 282937)
--- branches/safari-612-branch/Source/WebKit/GPUProcess/cocoa/GPUProcessCocoa.mm 2021-09-23 05:14:02 UTC (rev 282936)
+++ branches/safari-612-branch/Source/WebKit/GPUProcess/cocoa/GPUProcessCocoa.mm 2021-09-23 05:14:06 UTC (rev 282937)
@@ -66,6 +66,19 @@
#endif // USE(OS_STATE)
+#if ENABLE(CFPREFS_DIRECT_MODE)
+void GPUProcess::notifyPreferencesChanged(const String& domain, const String& key, const std::optional<String>& encodedValue)
+{
+ id value = nil;
+ if (encodedValue) {
+ value = decodePreferenceValue(encodedValue);
+ if (!value)
+ return;
+ }
+ setPreferenceValue(domain, key, value);
+}
+#endif
+
} // namespace WebKit
#endif // ENABLE(GPU_PROCESS) && PLATFORM(COCOA)
Modified: branches/safari-612-branch/Source/WebKit/Shared/AuxiliaryProcess.h (282936 => 282937)
--- branches/safari-612-branch/Source/WebKit/Shared/AuxiliaryProcess.h 2021-09-23 05:14:02 UTC (rev 282936)
+++ branches/safari-612-branch/Source/WebKit/Shared/AuxiliaryProcess.h 2021-09-23 05:14:06 UTC (rev 282937)
@@ -134,6 +134,12 @@
static std::optional<std::pair<IPC::Connection::Identifier, IPC::Attachment>> createIPCConnectionPair();
+protected:
+#if ENABLE(CFPREFS_DIRECT_MODE)
+ static id decodePreferenceValue(const std::optional<String>& encodedValue);
+ static void setPreferenceValue(const String& domain, const String& key, id value);
+#endif
+
private:
virtual bool shouldOverrideQuarantine() { return true; }
Modified: branches/safari-612-branch/Source/WebKit/Shared/Cocoa/AuxiliaryProcessCocoa.mm (282936 => 282937)
--- branches/safari-612-branch/Source/WebKit/Shared/Cocoa/AuxiliaryProcessCocoa.mm 2021-09-23 05:14:02 UTC (rev 282936)
+++ branches/safari-612-branch/Source/WebKit/Shared/Cocoa/AuxiliaryProcessCocoa.mm 2021-09-23 05:14:06 UTC (rev 282937)
@@ -130,4 +130,36 @@
#endif // USE(OS_STATE)
+#if ENABLE(CFPREFS_DIRECT_MODE)
+id AuxiliaryProcess::decodePreferenceValue(const std::optional<String>& encodedValue)
+{
+ if (!encodedValue)
+ return nil;
+
+ auto encodedData = adoptNS([[NSData alloc] initWithBase64EncodedString:*encodedValue options:0]);
+ if (!encodedData)
+ return nil;
+ NSError *err = nil;
+ auto classes = [NSSet setWithArray:@[[NSString class], [NSNumber class], [NSDate class], [NSDictionary class], [NSArray class], [NSData class]]];
+ id value = [NSKeyedUnarchiver unarchivedObjectOfClasses:classes fromData:encodedData.get() error:&err];
+ ASSERT(!err);
+ if (err)
+ return nil;
+
+ return value;
+}
+
+void AuxiliaryProcess::setPreferenceValue(const String& domain, const String& key, id value)
+{
+ if (domain.isEmpty()) {
+ CFPreferencesSetValue(key.createCFString().get(), (__bridge CFPropertyListRef)value, kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+#if ASSERT_ENABLED
+ id valueAfterSetting = [[NSUserDefaults standardUserDefaults] objectForKey:key];
+ ASSERT(valueAfterSetting == value || [valueAfterSetting isEqual:value] || key == "AppleLanguages");
+#endif
+ } else
+ CFPreferencesSetValue(key.createCFString().get(), (__bridge CFPropertyListRef)value, domain.createCFString().get(), kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+}
+#endif // ENABLE(CFPREFS_DIRECT_MODE)
+
} // namespace WebKit
Modified: branches/safari-612-branch/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (282936 => 282937)
--- branches/safari-612-branch/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2021-09-23 05:14:02 UTC (rev 282936)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2021-09-23 05:14:06 UTC (rev 282937)
@@ -96,6 +96,10 @@
#import <WebCore/SystemBattery.h>
#endif
+#if ENABLE(GPU_PROCESS)
+#import "GPUProcessMessages.h"
+#endif
+
#if HAVE(MEDIA_ACCESSIBILITY_FRAMEWORK)
#include <WebCore/CaptionUserPreferencesMediaAF.h>
#include <WebCore/MediaAccessibilitySoftLink.h>
@@ -983,6 +987,11 @@
{
for (auto process : m_processes)
process->send(Messages::WebProcess::NotifyPreferencesChanged(domain, key, encodedValue), 0);
+
+#if ENABLE(GPU_PROCESS)
+ if (auto* gpuProcess = GPUProcessProxy::singletonIfCreated())
+ gpuProcess->send(Messages::GPUProcess::NotifyPreferencesChanged(domain, key, encodedValue), 0);
+#endif
}
#endif
Modified: branches/safari-612-branch/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (282936 => 282937)
--- branches/safari-612-branch/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2021-09-23 05:14:02 UTC (rev 282936)
+++ branches/safari-612-branch/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm 2021-09-23 05:14:06 UTC (rev 282937)
@@ -1131,17 +1131,8 @@
}
}
-static void setPreferenceValue(const String& domain, const String& key, id value)
+static void handlePreferenceChange(const String& domain, const String& key, id value)
{
- if (domain.isEmpty()) {
- CFPreferencesSetValue(key.createCFString().get(), (__bridge CFPropertyListRef)value, kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-#if ASSERT_ENABLED
- id valueAfterSetting = [[NSUserDefaults standardUserDefaults] objectForKey:key];
- ASSERT(valueAfterSetting == value || [valueAfterSetting isEqual:value] || key == "AppleLanguages");
-#endif
- } else
- CFPreferencesSetValue(key.createCFString().get(), (__bridge CFPropertyListRef)value, domain.createCFString().get(), kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-
if (key == "AppleLanguages") {
// We need to set AppleLanguages for the volatile domain, similarly to what we do in XPCServiceMain.mm.
NSDictionary *existingArguments = [[NSUserDefaults standardUserDefaults] volatileDomainForName:NSArgumentDomain];
@@ -1171,26 +1162,20 @@
if (CFEqual(cfKey.get(), kAXInterfaceReduceMotionKey) || CFEqual(cfKey.get(), kAXInterfaceIncreaseContrastKey) || key == invertColorsPreferenceKey())
[NSWorkspace _invalidateAccessibilityDisplayValues];
#endif
+
+ dispatchSimulatedNotificationsForPreferenceChange(key);
}
void WebProcess::notifyPreferencesChanged(const String& domain, const String& key, const std::optional<String>& encodedValue)
{
- if (!encodedValue) {
- setPreferenceValue(domain, key, nil);
- dispatchSimulatedNotificationsForPreferenceChange(key);
- return;
+ id value = nil;
+ if (encodedValue) {
+ value = decodePreferenceValue(encodedValue);
+ if (!value)
+ return;
}
- auto encodedData = adoptNS([[NSData alloc] initWithBase64EncodedString:*encodedValue options:0]);
- if (!encodedData)
- return;
- NSError *err = nil;
- auto classes = [NSSet setWithArray:@[[NSString class], [NSNumber class], [NSDate class], [NSDictionary class], [NSArray class], [NSData class]]];
- id object = [NSKeyedUnarchiver unarchivedObjectOfClasses:classes fromData:encodedData.get() error:&err];
- ASSERT(!err);
- if (err)
- return;
- setPreferenceValue(domain, key, object);
- dispatchSimulatedNotificationsForPreferenceChange(key);
+ setPreferenceValue(domain, key, value);
+ handlePreferenceChange(domain, key, value);
}
void WebProcess::unblockPreferenceService(SandboxExtension::HandleArray&& handleArray)