- Revision
- 274117
- Author
- jer.no...@apple.com
- Date
- 2021-03-08 16:15:45 -0800 (Mon, 08 Mar 2021)
Log Message
[Cocoa][GPUP] Enable WebM/Vorbis/Opus in the GPU process
https://bugs.webkit.org/show_bug.cgi?id=222926
Reviewed by Eric Carlson.
The first time a GPUProcessProxy is created, and whenever a new WebPageProxy is created,
The GPUProcessProxy will query all existing WebPageGroups and their WebPreferences. If
any group enables "Media in the GPU Process", and also WebM, Vorbis, or Opus, those features
which are enabled will also be enabled inside the GPU process.
* GPUProcess/GPUProcess.cpp:
(WebKit::GPUProcess::setWebMParserEnabled):
(WebKit::GPUProcess::setWebMFormatReaderEnabled):
(WebKit::GPUProcess::setOpusDecoderEnabled):
(WebKit::GPUProcess::setVorbisDecoderEnabled):
* GPUProcess/GPUProcess.h:
* GPUProcess/GPUProcess.messages.in:
* UIProcess/GPU/GPUProcessProxy.cpp:
(WebKit::GPUProcessProxy::getOrCreate):
(WebKit::GPUProcessProxy::updatePreferences):
* UIProcess/GPU/GPUProcessProxy.h:
* UIProcess/WebPageGroup.cpp:
(WebKit::WebPageGroup::forEach):
* UIProcess/WebPageGroup.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::createWebPage):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (274116 => 274117)
--- trunk/Source/WebKit/ChangeLog 2021-03-09 00:03:44 UTC (rev 274116)
+++ trunk/Source/WebKit/ChangeLog 2021-03-09 00:15:45 UTC (rev 274117)
@@ -1,3 +1,32 @@
+2021-03-08 Jer Noble <jer.no...@apple.com>
+
+ [Cocoa][GPUP] Enable WebM/Vorbis/Opus in the GPU process
+ https://bugs.webkit.org/show_bug.cgi?id=222926
+
+ Reviewed by Eric Carlson.
+
+ The first time a GPUProcessProxy is created, and whenever a new WebPageProxy is created,
+ The GPUProcessProxy will query all existing WebPageGroups and their WebPreferences. If
+ any group enables "Media in the GPU Process", and also WebM, Vorbis, or Opus, those features
+ which are enabled will also be enabled inside the GPU process.
+
+ * GPUProcess/GPUProcess.cpp:
+ (WebKit::GPUProcess::setWebMParserEnabled):
+ (WebKit::GPUProcess::setWebMFormatReaderEnabled):
+ (WebKit::GPUProcess::setOpusDecoderEnabled):
+ (WebKit::GPUProcess::setVorbisDecoderEnabled):
+ * GPUProcess/GPUProcess.h:
+ * GPUProcess/GPUProcess.messages.in:
+ * UIProcess/GPU/GPUProcessProxy.cpp:
+ (WebKit::GPUProcessProxy::getOrCreate):
+ (WebKit::GPUProcessProxy::updatePreferences):
+ * UIProcess/GPU/GPUProcessProxy.h:
+ * UIProcess/WebPageGroup.cpp:
+ (WebKit::WebPageGroup::forEach):
+ * UIProcess/WebPageGroup.h:
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::createWebPage):
+
2021-03-08 Brent Fulgham <bfulg...@apple.com>
REGRESSION (r273541): Payloads requiring NSURL in serialization fail
Modified: trunk/Source/WebKit/GPUProcess/GPUProcess.cpp (274116 => 274117)
--- trunk/Source/WebKit/GPUProcess/GPUProcess.cpp 2021-03-09 00:03:44 UTC (rev 274116)
+++ trunk/Source/WebKit/GPUProcess/GPUProcess.cpp 2021-03-09 00:15:45 UTC (rev 274117)
@@ -45,6 +45,7 @@
#include <WebCore/MemoryRelease.h>
#include <WebCore/NowPlayingManager.h>
#include <WebCore/RuntimeApplicationChecks.h>
+#include <WebCore/RuntimeEnabledFeatures.h>
#include <wtf/Algorithms.h>
#include <wtf/CallbackAggregator.h>
#include <wtf/MemoryPressureHandler.h>
@@ -361,6 +362,46 @@
}
#endif
+#if ENABLE(MEDIA_SOURCE) && ENABLE(VP9)
+void GPUProcess::setWebMParserEnabled(bool enabled)
+{
+ if (m_webMParserEnabled == enabled)
+ return;
+ m_webMParserEnabled = enabled;
+ WebCore::RuntimeEnabledFeatures::sharedFeatures().setWebMParserEnabled(m_webMParserEnabled);
+}
+#endif
+
+#if ENABLE(WEBM_FORMAT_READER)
+void GPUProcess::setWebMFormatReaderEnabled(bool enabled)
+{
+ if (m_webMFormatReaderEnabled == enabled)
+ return;
+ m_webMFormatReaderEnabled = enabled;
+ PlatformMediaSessionManager::setWebMFormatReaderEnabled(m_webMParserEnabled);
+}
+#endif
+
+#if ENABLE(OPUS)
+void GPUProcess::setOpusDecoderEnabled(bool enabled)
+{
+ if (m_opusEnabled == enabled)
+ return;
+ m_opusEnabled = enabled;
+ PlatformMediaSessionManager::setOpusDecoderEnabled(m_opusEnabled);
+}
+#endif
+
+#if ENABLE(VORBIS)
+void GPUProcess::setVorbisDecoderEnabled(bool enabled)
+{
+ if (m_vorbisEnabled == enabled)
+ return;
+ m_vorbisEnabled = enabled;
+ PlatformMediaSessionManager::setVorbisDecoderEnabled(m_vorbisEnabled);
+}
+#endif
+
} // namespace WebKit
#endif // ENABLE(GPU_PROCESS)
Modified: trunk/Source/WebKit/GPUProcess/GPUProcess.h (274116 => 274117)
--- trunk/Source/WebKit/GPUProcess/GPUProcess.h 2021-03-09 00:03:44 UTC (rev 274116)
+++ trunk/Source/WebKit/GPUProcess/GPUProcess.h 2021-03-09 00:15:45 UTC (rev 274117)
@@ -126,6 +126,23 @@
void displayConfigurationChanged(CGDirectDisplayID, CGDisplayChangeSummaryFlags);
#endif
+
+#if ENABLE(MEDIA_SOURCE) && ENABLE(VP9)
+ void setWebMParserEnabled(bool);
+#endif
+
+#if ENABLE(WEBM_FORMAT_READER)
+ void setWebMFormatReaderEnabled(bool);
+#endif
+
+#if ENABLE(OPUS)
+ void setOpusDecoderEnabled(bool);
+#endif
+
+#if ENABLE(VORBIS)
+ void setVorbisDecoderEnabled(bool);
+#endif
+
// Connections to WebProcesses.
HashMap<WebCore::ProcessIdentifier, Ref<GPUConnectionToWebProcess>> m_webProcessConnections;
@@ -166,6 +183,18 @@
bool m_enableVP9Decoder { false };
bool m_enableVP9SWDecoder { false };
#endif
+#if ENABLE(MEDIA_SOURCE) && ENABLE(VP9)
+ bool m_webMParserEnabled { false };
+#endif
+#if ENABLE(WEBM_FORMAT_READER)
+ bool m_webMFormatReaderEnabled { false };
+#endif
+#if ENABLE(OPUS)
+ bool m_opusEnabled { false };
+#endif
+#if ENABLE(VORBIS)
+ bool m_vorbisEnabled { false };
+#endif
};
} // namespace WebKit
Modified: trunk/Source/WebKit/GPUProcess/GPUProcess.messages.in (274116 => 274117)
--- trunk/Source/WebKit/GPUProcess/GPUProcess.messages.in 2021-03-09 00:03:44 UTC (rev 274116)
+++ trunk/Source/WebKit/GPUProcess/GPUProcess.messages.in 2021-03-09 00:15:45 UTC (rev 274117)
@@ -48,6 +48,22 @@
#if PLATFORM(MAC)
DisplayConfigurationChanged(CGDirectDisplayID displayID, CGDisplayChangeSummaryFlags flags)
#endif
+
+#if ENABLE(MEDIA_SOURCE) && ENABLE(VP9)
+ SetWebMParserEnabled(bool enabled);
+#endif
+
+#if ENABLE(WEBM_FORMAT_READER)
+ SetWebMFormatReaderEnabled(bool enabled);
+#endif
+
+#if ENABLE(OPUS)
+ SetOpusDecoderEnabled(bool enabled);
+#endif
+
+#if ENABLE(VORBIS)
+ SetVorbisDecoderEnabled(bool enabled);
+#endif
}
#endif // ENABLE(GPU_PROCESS)
Modified: trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp (274116 => 274117)
--- trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp 2021-03-09 00:03:44 UTC (rev 274116)
+++ trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp 2021-03-09 00:15:45 UTC (rev 274117)
@@ -36,8 +36,10 @@
#include "GPUProcessProxyMessages.h"
#include "GPUProcessSessionParameters.h"
#include "Logging.h"
+#include "WebPageGroup.h"
#include "WebPageMessages.h"
#include "WebPageProxy.h"
+#include "WebPreferences.h"
#include "WebProcessMessages.h"
#include "WebProcessPool.h"
#include "WebProcessProxy.h"
@@ -103,6 +105,7 @@
return *existingGPUProcess;
}
auto gpuProcess = adoptRef(*new GPUProcessProxy);
+ gpuProcess->updatePreferences();
singleton() = makeWeakPtr(gpuProcess.get());
return gpuProcess;
}
@@ -420,6 +423,69 @@
}
#endif
+void GPUProcessProxy::updatePreferences()
+{
+ if (!canSendMessage())
+ return;
+
+#if ENABLE(MEDIA_SOURCE) && ENABLE(VP9)
+ bool hasEnabledWebMParser = false;
+#endif
+
+#if ENABLE(WEBM_FORMAT_READER)
+ bool hasEnabledWebMFormatReader = false;
+#endif
+
+#if ENABLE(OPUS)
+ bool hasEnabledOpus = false;
+#endif
+
+#if ENABLE(VORBIS)
+ bool hasEnabledVorbis = false;
+#endif
+
+ WebPageGroup::forEach([&] (auto& group) mutable {
+ if (!group.preferences().useGPUProcessForMediaEnabled())
+ return;
+
+#if ENABLE(OPUS)
+ if (group.preferences().opusDecoderEnabled())
+ hasEnabledOpus = true;
+#endif
+
+#if ENABLE(VORBIS)
+ if (group.preferences().vorbisDecoderEnabled())
+ hasEnabledVorbis = true;
+#endif
+
+#if ENABLE(WEBM_FORMAT_READER)
+ if (group.preferences().webMFormatReaderEnabled())
+ hasEnabledWebMFormatReader = true;
+#endif
+
+#if ENABLE(MEDIA_SOURCE) && ENABLE(VP9)
+ if (group.preferences().webMParserEnabled())
+ hasEnabledWebMParser = true;
+#endif
+ });
+
+#if ENABLE(MEDIA_SOURCE) && ENABLE(VP9)
+ send(Messages::GPUProcess::SetWebMParserEnabled(hasEnabledWebMParser), 0);
+#endif
+
+#if ENABLE(WEBM_FORMAT_READER)
+ send(Messages::GPUProcess::SetWebMFormatReaderEnabled(hasEnabledWebMFormatReader), 0);
+#endif
+
+#if ENABLE(OPUS)
+ send(Messages::GPUProcess::SetOpusDecoderEnabled(hasEnabledOpus), 0);
+#endif
+
+#if ENABLE(VORBIS)
+ send(Messages::GPUProcess::SetVorbisDecoderEnabled(hasEnabledVorbis), 0);
+#endif
+}
+
} // namespace WebKit
#undef MESSAGE_CHECK
Modified: trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.h (274116 => 274117)
--- trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.h 2021-03-09 00:03:44 UTC (rev 274116)
+++ trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.h 2021-03-09 00:15:45 UTC (rev 274117)
@@ -91,6 +91,8 @@
void displayConfigurationChanged(CGDirectDisplayID, CGDisplayChangeSummaryFlags);
#endif
+ void updatePreferences();
+
private:
explicit GPUProcessProxy();
Modified: trunk/Source/WebKit/UIProcess/WebPageGroup.cpp (274116 => 274117)
--- trunk/Source/WebKit/UIProcess/WebPageGroup.cpp 2021-03-09 00:03:44 UTC (rev 274116)
+++ trunk/Source/WebKit/UIProcess/WebPageGroup.cpp 2021-03-09 00:15:45 UTC (rev 274117)
@@ -64,6 +64,15 @@
return webPageGroupMap().get(pageGroupID);
}
+void WebPageGroup::forEach(Function<void(WebPageGroup&)>&& function)
+{
+ auto allGroups = copyToVectorOf<RefPtr<WebPageGroup>>(webPageGroupMap().values());
+ for (auto& group : allGroups) {
+ if (group)
+ function(*group);
+ }
+}
+
static WebPageGroupData pageGroupData(const String& identifier)
{
WebPageGroupData data;
Modified: trunk/Source/WebKit/UIProcess/WebPageGroup.h (274116 => 274117)
--- trunk/Source/WebKit/UIProcess/WebPageGroup.h 2021-03-09 00:03:44 UTC (rev 274116)
+++ trunk/Source/WebKit/UIProcess/WebPageGroup.h 2021-03-09 00:15:45 UTC (rev 274117)
@@ -46,6 +46,7 @@
static Ref<WebPageGroup> create(const String& identifier = { });
static WebPageGroup* get(uint64_t pageGroupID);
+ static void forEach(Function<void(WebPageGroup&)>&&);
virtual ~WebPageGroup();
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (274116 => 274117)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2021-03-09 00:03:44 UTC (rev 274116)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2021-03-09 00:15:45 UTC (rev 274117)
@@ -1078,6 +1078,11 @@
if (wasProcessSwappingOnNavigationEnabled != m_configuration->processSwapsOnNavigation())
m_webProcessCache->updateCapacity(*this);
+#if ENABLE(GPU_PROCESS)
+ if (auto* gpuProcess = GPUProcessProxy::singletonIfCreated())
+ gpuProcess->updatePreferences();
+#endif
+
return page;
}