Diff
Modified: branches/safari-612-branch/Source/WTF/wtf/WorkQueue.cpp (285558 => 285559)
--- branches/safari-612-branch/Source/WTF/wtf/WorkQueue.cpp 2021-11-10 03:29:06 UTC (rev 285558)
+++ branches/safari-612-branch/Source/WTF/wtf/WorkQueue.cpp 2021-11-10 03:29:09 UTC (rev 285559)
@@ -76,6 +76,11 @@
semaphore.wait();
}
+void WorkQueue::dispatchWithQOS(Function<void()>&& function, QOS)
+{
+ dispatch(WTFMove(function));
+}
+
void WorkQueue::concurrentApply(size_t iterations, WTF::Function<void (size_t index)>&& function)
{
if (!iterations)
Modified: branches/safari-612-branch/Source/WTF/wtf/WorkQueue.h (285558 => 285559)
--- branches/safari-612-branch/Source/WTF/wtf/WorkQueue.h 2021-11-10 03:29:06 UTC (rev 285558)
+++ branches/safari-612-branch/Source/WTF/wtf/WorkQueue.h 2021-11-10 03:29:09 UTC (rev 285559)
@@ -56,6 +56,7 @@
~WorkQueue() override;
WTF_EXPORT_PRIVATE void dispatch(Function<void()>&&) override;
+ WTF_EXPORT_PRIVATE void dispatchWithQOS(Function<void()>&&, QOS);
WTF_EXPORT_PRIVATE virtual void dispatchAfter(Seconds, Function<void()>&&);
WTF_EXPORT_PRIVATE virtual void dispatchSync(Function<void()>&&);
Modified: branches/safari-612-branch/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp (285558 => 285559)
--- branches/safari-612-branch/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp 2021-11-10 03:29:06 UTC (rev 285558)
+++ branches/safari-612-branch/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp 2021-11-10 03:29:09 UTC (rev 285559)
@@ -54,6 +54,13 @@
dispatch_async_f(m_dispatchQueue.get(), new DispatchWorkItem { makeRef(*this), WTFMove(function) }, dispatchWorkItem<DispatchWorkItem>);
}
+void WorkQueue::dispatchWithQOS(Function<void()>&& function, QOS qos)
+{
+ dispatch_async(m_dispatchQueue.get(), dispatch_block_create_with_qos_class(DISPATCH_BLOCK_ENFORCE_QOS_CLASS, Thread::dispatchQOSClass(qos), 0, makeBlockPtr([function = WTFMove(function)] {
+ function();
+ }).get()));
+}
+
void WorkQueue::dispatchAfter(Seconds duration, Function<void()>&& function)
{
dispatch_after_f(dispatch_time(DISPATCH_TIME_NOW, duration.nanosecondsAs<int64_t>()), m_dispatchQueue.get(), new DispatchWorkItem { makeRef(*this), WTFMove(function) }, dispatchWorkItem<DispatchWorkItem>);
Modified: branches/safari-612-branch/Source/WebKit/Platform/IPC/Connection.cpp (285558 => 285559)
--- branches/safari-612-branch/Source/WebKit/Platform/IPC/Connection.cpp 2021-11-10 03:29:06 UTC (rev 285558)
+++ branches/safari-612-branch/Source/WebKit/Platform/IPC/Connection.cpp 2021-11-10 03:29:09 UTC (rev 285559)
@@ -454,7 +454,7 @@
return encoder;
}
-bool Connection::sendMessage(UniqueRef<Encoder>&& encoder, OptionSet<SendOption> sendOptions)
+bool Connection::sendMessage(UniqueRef<Encoder>&& encoder, OptionSet<SendOption> sendOptions, std::optional<Thread::QOS> qos)
{
if (!isValid())
return false;
@@ -494,9 +494,14 @@
}
// FIXME: We should add a boolean flag so we don't call this when work has already been scheduled.
- m_connectionQueue->dispatch([protectedThis = makeRef(*this)]() mutable {
+ auto sendOutgoingMessages = [protectedThis = makeRef(*this)]() mutable {
protectedThis->sendOutgoingMessages();
- });
+ };
+ if (qos)
+ m_connectionQueue->dispatchWithQOS(WTFMove(sendOutgoingMessages), *qos);
+ else
+ m_connectionQueue->dispatch(WTFMove(sendOutgoingMessages));
+
return true;
}
Modified: branches/safari-612-branch/Source/WebKit/Platform/IPC/Connection.h (285558 => 285559)
--- branches/safari-612-branch/Source/WebKit/Platform/IPC/Connection.h 2021-11-10 03:29:06 UTC (rev 285558)
+++ branches/safari-612-branch/Source/WebKit/Platform/IPC/Connection.h 2021-11-10 03:29:09 UTC (rev 285559)
@@ -242,8 +242,8 @@
void postConnectionDidCloseOnConnectionWorkQueue();
template<typename T, typename C> uint64_t sendWithAsyncReply(T&& message, C&& completionHandler, uint64_t destinationID = 0, OptionSet<SendOption> = { }); // Thread-safe.
- template<typename T> bool send(T&& message, uint64_t destinationID, OptionSet<SendOption> sendOptions = { }); // Thread-safe.
- template<typename T> static bool send(UniqueID, T&& message, uint64_t destinationID, OptionSet<SendOption> sendOptions = { }); // Thread-safe.
+ template<typename T> bool send(T&& message, uint64_t destinationID, OptionSet<SendOption> sendOptions = { }, std::optional<Thread::QOS> qos = std::nullopt); // Thread-safe.
+ template<typename T> static bool send(UniqueID, T&& message, uint64_t destinationID, OptionSet<SendOption> sendOptions = { }, std::optional<Thread::QOS> qos = std::nullopt); // Thread-safe.
// Sync senders should check the SendSyncResult for true/false in case they need to know if the result was really received.
// Sync senders should hold on to the SendSyncResult in case they reference the contents of the reply via DataRefererence / ArrayReference.
@@ -261,9 +261,9 @@
// Thread-safe.
template<typename T, typename U>
- bool send(T&& message, ObjectIdentifier<U> destinationID, OptionSet<SendOption> sendOptions = { })
+ bool send(T&& message, ObjectIdentifier<U> destinationID, OptionSet<SendOption> sendOptions = { }, std::optional<Thread::QOS> qos = std::nullopt)
{
- return send<T>(WTFMove(message), destinationID.toUInt64(), sendOptions);
+ return send<T>(WTFMove(message), destinationID.toUInt64(), sendOptions, qos);
}
// Main thread only.
@@ -280,7 +280,7 @@
return waitForAndDispatchImmediately<T>(destinationID.toUInt64(), timeout, waitForOptions);
}
- bool sendMessage(UniqueRef<Encoder>&&, OptionSet<SendOption> sendOptions);
+ bool sendMessage(UniqueRef<Encoder>&&, OptionSet<SendOption> sendOptions, std::optional<Thread::QOS> = std::nullopt);
UniqueRef<Encoder> createSyncMessageEncoder(MessageName, uint64_t destinationID, SyncRequestID&);
std::unique_ptr<Decoder> sendSyncMessage(SyncRequestID, UniqueRef<Encoder>&&, Timeout, OptionSet<SendSyncOption> sendSyncOptions);
bool sendSyncReply(UniqueRef<Encoder>&&);
@@ -510,7 +510,7 @@
};
template<typename T>
-bool Connection::send(T&& message, uint64_t destinationID, OptionSet<SendOption> sendOptions)
+bool Connection::send(T&& message, uint64_t destinationID, OptionSet<SendOption> sendOptions, std::optional<Thread::QOS> qos)
{
COMPILE_ASSERT(!T::isSync, AsyncMessageExpected);
@@ -517,17 +517,17 @@
auto encoder = makeUniqueRef<Encoder>(T::name(), destinationID);
encoder.get() << message.arguments();
- return sendMessage(WTFMove(encoder), sendOptions);
+ return sendMessage(WTFMove(encoder), sendOptions, qos);
}
template<typename T>
-bool Connection::send(UniqueID connectionID, T&& message, uint64_t destinationID, OptionSet<SendOption> sendOptions)
+bool Connection::send(UniqueID connectionID, T&& message, uint64_t destinationID, OptionSet<SendOption> sendOptions, std::optional<Thread::QOS> qos)
{
Locker locker { s_connectionMapLock };
auto* connection = connectionMap().get(connectionID);
if (!connection)
return false;
- return connection->send(WTFMove(message), destinationID, sendOptions);
+ return connection->send(WTFMove(message), destinationID, sendOptions, qos);
}
uint64_t nextAsyncReplyHandlerID();
Modified: branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.cpp (285558 => 285559)
--- branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-11-10 03:29:06 UTC (rev 285558)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-11-10 03:29:09 UTC (rev 285559)
@@ -2922,7 +2922,11 @@
m_wheelEventActivityHysteresis.impulse();
#endif
- send(
+ auto* connection = messageSenderConnection();
+ if (!connection)
+ return;
+
+ connection->send(
Messages::EventDispatcher::WheelEvent(
m_webPageID,
event,
@@ -2930,7 +2934,7 @@
shouldUseImplicitRubberBandControl() ? !m_backForwardList->forwardItem() : rubberBandsAtRight(),
rubberBandsAtTop(),
rubberBandsAtBottom()
- ), 0);
+ ), 0, { }, Thread::QOS::UserInteractive);
// Manually ping the web process to check for responsiveness since our wheel
// event will dispatch to a non-main thread, which always responds.
Modified: branches/safari-612-branch/Source/WebKit/UIProcess/mac/DisplayLink.cpp (285558 => 285559)
--- branches/safari-612-branch/Source/WebKit/UIProcess/mac/DisplayLink.cpp 2021-11-10 03:29:06 UTC (rev 285558)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/mac/DisplayLink.cpp 2021-11-10 03:29:09 UTC (rev 285559)
@@ -236,9 +236,9 @@
<< " observers, on background queue " << shouldSendIPCOnBackgroundQueue << " maxFramesPerSecond " << observersMaxFramesPerSecond << " full speed clients " << connectionInfo.fullSpeedUpdatesClientCount << " relevant " << mainThreadWantsUpdate);
if (connectionInfo.fullSpeedUpdatesClientCount) {
- IPC::Connection::send(connectionID, Messages::EventDispatcher::DisplayWasRefreshed(m_displayID, m_currentUpdate, mainThreadWantsUpdate), 0);
+ IPC::Connection::send(connectionID, Messages::EventDispatcher::DisplayWasRefreshed(m_displayID, m_currentUpdate, mainThreadWantsUpdate), 0, { }, Thread::QOS::UserInteractive);
} else if (mainThreadWantsUpdate)
- IPC::Connection::send(connectionID, Messages::WebProcess::DisplayWasRefreshed(m_displayID, m_currentUpdate), 0);
+ IPC::Connection::send(connectionID, Messages::WebProcess::DisplayWasRefreshed(m_displayID, m_currentUpdate), 0, { }, Thread::QOS::UserInteractive);
}
m_currentUpdate = m_currentUpdate.nextUpdate();