Diff
Modified: trunk/Source/WTF/ChangeLog (270805 => 270806)
--- trunk/Source/WTF/ChangeLog 2020-12-14 22:55:25 UTC (rev 270805)
+++ trunk/Source/WTF/ChangeLog 2020-12-14 23:44:32 UTC (rev 270806)
@@ -1,3 +1,27 @@
+2020-12-14 Chris Dumez <[email protected]>
+
+ [GPUProcess] Bump QoS to UserInteractive for real-time audio rendering thread
+ https://bugs.webkit.org/show_bug.cgi?id=219873
+
+ Reviewed by Eric Carlson.
+
+ Add QOS parameter to the Thread construct (similarly to WorkQueue) so that the caller can
+ specify which QoS to use for the thread. Previously, the code was using UserInteractive
+ QoS unconditionally, which may be too high is some cases and too low in others.
+
+ * wtf/Threading.cpp:
+ (WTF::Thread::create):
+ * wtf/Threading.h:
+ * wtf/WorkQueue.h:
+ * wtf/cocoa/WorkQueueCocoa.cpp:
+ (WTF::WorkQueue::platformInitialize):
+ (WTF::dispatchQOSClass): Deleted.
+ * wtf/posix/ThreadingPOSIX.cpp:
+ (WTF::Thread::dispatchQOSClass):
+ (WTF::Thread::establishHandle):
+ * wtf/win/ThreadingWin.cpp:
+ (WTF::Thread::establishHandle):
+
2020-12-14 Tadeu Zagallo <[email protected]>
Move some of the work from JSLock to VMEntryScope
Modified: trunk/Source/WTF/wtf/Threading.cpp (270805 => 270806)
--- trunk/Source/WTF/wtf/Threading.cpp 2020-12-14 22:55:25 UTC (rev 270805)
+++ trunk/Source/WTF/wtf/Threading.cpp 2020-12-14 23:44:32 UTC (rev 270806)
@@ -181,7 +181,7 @@
function();
}
-Ref<Thread> Thread::create(const char* name, Function<void()>&& entryPoint, ThreadType threadType)
+Ref<Thread> Thread::create(const char* name, Function<void()>&& entryPoint, ThreadType threadType, QOS qos)
{
WTF::initialize();
Ref<Thread> thread = adoptRef(*new Thread());
@@ -194,7 +194,7 @@
context->ref();
{
MutexLocker locker(context->mutex);
- bool success = thread->establishHandle(context.ptr(), stackSize(threadType));
+ bool success = thread->establishHandle(context.ptr(), stackSize(threadType), qos);
RELEASE_ASSERT(success);
context->stage = NewThreadContext::Stage::EstablishedHandle;
Modified: trunk/Source/WTF/wtf/Threading.h (270805 => 270806)
--- trunk/Source/WTF/wtf/Threading.h 2020-12-14 22:55:25 UTC (rev 270805)
+++ trunk/Source/WTF/wtf/Threading.h 2020-12-14 23:44:32 UTC (rev 270806)
@@ -56,6 +56,10 @@
#include <array>
#endif
+#if HAVE(QOS_CLASSES)
+#include <dispatch/dispatch.h>
+#endif
+
namespace WTF {
class AbstractLocker;
@@ -99,9 +103,21 @@
WTF_EXPORT_PRIVATE ~Thread();
+ enum class QOS {
+ UserInteractive,
+ UserInitiated,
+ Default,
+ Utility,
+ Background
+ };
+
+#if HAVE(QOS_CLASSES)
+ static dispatch_qos_class_t dispatchQOSClass(QOS);
+#endif
+
// Returns nullptr if thread creation failed.
// The thread name must be a literal since on some platforms it's passed in to the thread.
- WTF_EXPORT_PRIVATE static Ref<Thread> create(const char* threadName, Function<void()>&&, ThreadType threadType = ThreadType::Unknown);
+ WTF_EXPORT_PRIVATE static Ref<Thread> create(const char* threadName, Function<void()>&&, ThreadType = ThreadType::Unknown, QOS = QOS::UserInitiated);
// Returns Thread object.
static Thread& current();
@@ -174,7 +190,6 @@
#if HAVE(QOS_CLASSES)
WTF_EXPORT_PRIVATE static void setGlobalMaxQOSClass(qos_class_t);
- WTF_EXPORT_PRIVATE static qos_class_t adjustedQOSClass(qos_class_t);
#endif
// Called in the thread during initialization.
@@ -251,7 +266,7 @@
void initializeInThread();
// Internal platform-specific Thread establishment implementation.
- bool establishHandle(NewThreadContext*, Optional<size_t>);
+ bool establishHandle(NewThreadContext*, Optional<size_t> stackSize, QOS);
#if USE(PTHREADS)
void establishPlatformSpecificHandle(PlatformThreadHandle);
@@ -263,6 +278,10 @@
static void signalHandlerSuspendResume(int, siginfo_t*, void* ucontext);
#endif
+#if HAVE(QOS_CLASSES)
+ static qos_class_t adjustedQOSClass(qos_class_t);
+#endif
+
static const char* normalizeThreadName(const char* threadName);
enum JoinableState : uint8_t {
Modified: trunk/Source/WTF/wtf/WorkQueue.h (270805 => 270806)
--- trunk/Source/WTF/wtf/WorkQueue.h 2020-12-14 22:55:25 UTC (rev 270805)
+++ trunk/Source/WTF/wtf/WorkQueue.h 2020-12-14 23:44:32 UTC (rev 270806)
@@ -47,13 +47,7 @@
Serial,
Concurrent
};
- enum class QOS {
- UserInteractive,
- UserInitiated,
- Default,
- Utility,
- Background
- };
+ using QOS = Thread::QOS;
WTF_EXPORT_PRIVATE static Ref<WorkQueue> create(const char* name, Type = Type::Serial, QOS = QOS::Default);
~WorkQueue() final;
Modified: trunk/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp (270805 => 270806)
--- trunk/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp 2020-12-14 22:55:25 UTC (rev 270805)
+++ trunk/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp 2020-12-14 23:44:32 UTC (rev 270806)
@@ -45,26 +45,10 @@
}).get());
}
-static dispatch_qos_class_t dispatchQOSClass(WorkQueue::QOS qos)
-{
- switch (qos) {
- case WorkQueue::QOS::UserInteractive:
- return Thread::adjustedQOSClass(QOS_CLASS_USER_INTERACTIVE);
- case WorkQueue::QOS::UserInitiated:
- return Thread::adjustedQOSClass(QOS_CLASS_USER_INITIATED);
- case WorkQueue::QOS::Default:
- return Thread::adjustedQOSClass(QOS_CLASS_DEFAULT);
- case WorkQueue::QOS::Utility:
- return Thread::adjustedQOSClass(QOS_CLASS_UTILITY);
- case WorkQueue::QOS::Background:
- return Thread::adjustedQOSClass(QOS_CLASS_BACKGROUND);
- }
-}
-
void WorkQueue::platformInitialize(const char* name, Type type, QOS qos)
{
dispatch_queue_attr_t attr = type == Type::Concurrent ? DISPATCH_QUEUE_CONCURRENT : DISPATCH_QUEUE_SERIAL;
- attr = dispatch_queue_attr_make_with_qos_class(attr, dispatchQOSClass(qos), 0);
+ attr = dispatch_queue_attr_make_with_qos_class(attr, Thread::dispatchQOSClass(qos), 0);
m_dispatchQueue = dispatch_queue_create(name, attr);
dispatch_set_context(m_dispatchQueue, this);
}
Modified: trunk/Source/WTF/wtf/posix/ThreadingPOSIX.cpp (270805 => 270806)
--- trunk/Source/WTF/wtf/posix/ThreadingPOSIX.cpp 2020-12-14 22:55:25 UTC (rev 270805)
+++ trunk/Source/WTF/wtf/posix/ThreadingPOSIX.cpp 2020-12-14 23:44:32 UTC (rev 270806)
@@ -214,13 +214,33 @@
return nullptr;
}
-bool Thread::establishHandle(NewThreadContext* context, Optional<size_t> stackSize)
+#if HAVE(QOS_CLASSES)
+dispatch_qos_class_t Thread::dispatchQOSClass(QOS qos)
{
+ switch (qos) {
+ case QOS::UserInteractive:
+ return adjustedQOSClass(QOS_CLASS_USER_INTERACTIVE);
+ case QOS::UserInitiated:
+ return adjustedQOSClass(QOS_CLASS_USER_INITIATED);
+ case QOS::Default:
+ return adjustedQOSClass(QOS_CLASS_DEFAULT);
+ case QOS::Utility:
+ return adjustedQOSClass(QOS_CLASS_UTILITY);
+ case QOS::Background:
+ return adjustedQOSClass(QOS_CLASS_BACKGROUND);
+ }
+}
+#endif
+
+bool Thread::establishHandle(NewThreadContext* context, Optional<size_t> stackSize, QOS qos)
+{
pthread_t threadHandle;
pthread_attr_t attr;
pthread_attr_init(&attr);
#if HAVE(QOS_CLASSES)
- pthread_attr_set_qos_class_np(&attr, adjustedQOSClass(QOS_CLASS_USER_INITIATED), 0);
+ pthread_attr_set_qos_class_np(&attr, dispatchQOSClass(qos), 0);
+#else
+ UNUSED_PARAM(qos);
#endif
if (stackSize)
pthread_attr_setstacksize(&attr, stackSize.value());
Modified: trunk/Source/WTF/wtf/win/ThreadingWin.cpp (270805 => 270806)
--- trunk/Source/WTF/wtf/win/ThreadingWin.cpp 2020-12-14 22:55:25 UTC (rev 270805)
+++ trunk/Source/WTF/wtf/win/ThreadingWin.cpp 2020-12-14 23:44:32 UTC (rev 270806)
@@ -153,7 +153,7 @@
return 0;
}
-bool Thread::establishHandle(NewThreadContext* data, Optional<size_t> stackSize)
+bool Thread::establishHandle(NewThreadContext* data, Optional<size_t> stackSize, QOS)
{
unsigned threadIdentifier = 0;
unsigned initFlag = stackSize ? STACK_SIZE_PARAM_IS_A_RESERVATION : 0;
Modified: trunk/Source/WebCore/ChangeLog (270805 => 270806)
--- trunk/Source/WebCore/ChangeLog 2020-12-14 22:55:25 UTC (rev 270805)
+++ trunk/Source/WebCore/ChangeLog 2020-12-14 23:44:32 UTC (rev 270806)
@@ -1,3 +1,25 @@
+2020-12-14 Chris Dumez <[email protected]>
+
+ [GPUProcess] Bump QoS to UserInteractive for real-time audio rendering thread
+ https://bugs.webkit.org/show_bug.cgi?id=219873
+
+ Reviewed by Eric Carlson.
+
+ Use Default QoS for offline audio rendering and UserInteractive for real-time audio
+ rendering. Previously, we were using always UserInitiated QoS for all audio threads,
+ which is lower than UserInteractive [1].
+
+ [1] https://developer.apple.com/library/archive/documentation/Performance/Conceptual/power_efficiency_guidelines_osx/PrioritizeWorkAtTheTaskLevel.html#//apple_ref/doc/uid/TP40013929-CH35-SW1
+
+ * Modules/webaudio/AudioWorkletMessagingProxy.cpp:
+ (WebCore::generateWorkletParameters):
+ * Modules/webaudio/AudioWorkletThread.cpp:
+ (WebCore::AudioWorkletThread::createThread):
+ * Modules/webaudio/OfflineAudioDestinationNode.cpp:
+ (WebCore::OfflineAudioDestinationNode::startRendering):
+ * worklets/WorkletParameters.h:
+ (WebCore::WorkletParameters::isolatedCopy const):
+
2020-12-14 Peng Liu <[email protected]>
[Media in GPU Process][MSE] WebM source buffer parser is not enabled
Modified: trunk/Source/WebCore/Modules/webaudio/AudioWorkletMessagingProxy.cpp (270805 => 270806)
--- trunk/Source/WebCore/Modules/webaudio/AudioWorkletMessagingProxy.cpp 2020-12-14 22:55:25 UTC (rev 270805)
+++ trunk/Source/WebCore/Modules/webaudio/AudioWorkletMessagingProxy.cpp 2020-12-14 23:44:32 UTC (rev 270806)
@@ -53,7 +53,8 @@
jsRuntimeFlags,
worklet.audioContext() ? worklet.audioContext()->sampleRate() : 0.0f,
worklet.identifier(),
- document->settingsValues()
+ document->settingsValues(),
+ worklet.audioContext() ? !worklet.audioContext()->isOfflineContext() : false
};
}
Modified: trunk/Source/WebCore/Modules/webaudio/AudioWorkletThread.cpp (270805 => 270806)
--- trunk/Source/WebCore/Modules/webaudio/AudioWorkletThread.cpp 2020-12-14 22:55:25 UTC (rev 270805)
+++ trunk/Source/WebCore/Modules/webaudio/AudioWorkletThread.cpp 2020-12-14 23:44:32 UTC (rev 270806)
@@ -66,7 +66,7 @@
{
return Thread::create("WebCore: AudioWorklet", [this] {
workerOrWorkletThread();
- }, ThreadType::Audio);
+ }, ThreadType::Audio, m_parameters.isAudioContextRealTime ? Thread::QOS::UserInteractive : Thread::QOS::Default);
}
AudioWorkletGlobalScope* AudioWorkletThread::globalScope() const
Modified: trunk/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp (270805 => 270806)
--- trunk/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp 2020-12-14 22:55:25 UTC (rev 270805)
+++ trunk/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp 2020-12-14 23:44:32 UTC (rev 270806)
@@ -127,7 +127,7 @@
}
// FIXME: We should probably limit the number of threads we create for offline audio.
- m_renderThread = Thread::create("offline renderer", WTFMove(offThreadRendering), ThreadType::Audio);
+ m_renderThread = Thread::create("offline renderer", WTFMove(offThreadRendering), ThreadType::Audio, Thread::QOS::Default);
completionHandler(WTF::nullopt);
}
Modified: trunk/Source/WebCore/worklets/WorkletParameters.h (270805 => 270806)
--- trunk/Source/WebCore/worklets/WorkletParameters.h 2020-12-14 22:55:25 UTC (rev 270805)
+++ trunk/Source/WebCore/worklets/WorkletParameters.h 2020-12-14 23:44:32 UTC (rev 270806)
@@ -37,6 +37,7 @@
float sampleRate;
String identifier;
Settings::Values settingsValues;
+ bool isAudioContextRealTime;
WorkletParameters isolatedCopy() const
{
@@ -45,7 +46,8 @@
jsRuntimeFlags,
sampleRate,
identifier.isolatedCopy(),
- settingsValues.isolatedCopy()
+ settingsValues.isolatedCopy(),
+ isAudioContextRealTime
};
}
};
Modified: trunk/Source/WebKit/ChangeLog (270805 => 270806)
--- trunk/Source/WebKit/ChangeLog 2020-12-14 22:55:25 UTC (rev 270805)
+++ trunk/Source/WebKit/ChangeLog 2020-12-14 23:44:32 UTC (rev 270806)
@@ -1,3 +1,13 @@
+2020-12-14 Chris Dumez <[email protected]>
+
+ [GPUProcess] Bump QoS to UserInteractive for real-time audio rendering thread
+ https://bugs.webkit.org/show_bug.cgi?id=219873
+
+ Reviewed by Eric Carlson.
+
+ * WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp:
+ (WebKit::RemoteAudioDestinationProxy::RemoteAudioDestinationProxy):
+
2020-12-14 Peng Liu <[email protected]>
[Media in GPU Process][MSE] WebM source buffer parser is not enabled
Modified: trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp (270805 => 270806)
--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp 2020-12-14 22:55:25 UTC (rev 270805)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp 2020-12-14 23:44:32 UTC (rev 270806)
@@ -72,7 +72,7 @@
task();
}
};
- m_renderThread = Thread::create("RemoteAudioDestinationProxy render thread", WTFMove(offThreadRendering), ThreadType::Audio);
+ m_renderThread = Thread::create("RemoteAudioDestinationProxy render thread", WTFMove(offThreadRendering), ThreadType::Audio, Thread::QOS::UserInteractive);
connectToGPUProcess();
}