- Revision
- 271212
- Author
- [email protected]
- Date
- 2021-01-06 12:35:27 -0800 (Wed, 06 Jan 2021)
Log Message
[Concurrent Display Lists] GPU process should not immediately sleep after reading all available display list items
https://bugs.webkit.org/show_bug.cgi?id=219586
<rdar://problem/72275412>
Reviewed by Chris Dumez.
This patch adds a mechanism for the GPU process to wait for a short duration (~30 microseconds) after it has
finished reading all available data in its shared item buffer; if the web process writes additional data to the
item buffer (thereby bumping the unread bytes counter) during this time, we immediately resume processing the
new display list items in the GPU process, rather than wait for a new wakeup message.
This allows us to avoid the cost of going to sleep just to immediately wake up in the GPU process, in the case
where the web process is writing display list items at a very fast rate and the GPU process just happens to
catch up (i.e. advance `unreadBytes()` to 0).
See below for more details.
* GPUProcess/GPUConnectionToWebProcess.cpp:
(WebKit::GPUConnectionToWebProcess::createRenderingBackend):
Refactor the rendering backend creation message from the web process to the GPU process, so that the rendering
backend creation arguments are encapsulated in a single struct, RemoteRenderingBackendCreationParameters. This
struct contains the rendering backend identifier and, on Cocoa platforms, a mach send right that can be used to
construct the corresponding display list wakeup semaphore in the GPU process.
* GPUProcess/GPUConnectionToWebProcess.h:
* GPUProcess/GPUConnectionToWebProcess.messages.in:
* GPUProcess/graphics/DisplayListReaderHandle.h:
(WebKit::DisplayListReaderHandle::startWaiting):
(WebKit::DisplayListReaderHandle::stopWaiting):
Add helper methods for the GPU process to start and stop waiting for new items. See the call site in
RemoteRenderingBackend for more detail, as well as the comments in SharedDisplayListHandle below.
* GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::create):
(WebKit::RemoteRenderingBackend::RemoteRenderingBackend):
Refactor this codepath to take RemoteRenderingBackendCreationParameters instead of just an identifier.
(WebKit::RemoteRenderingBackend::nextDestinationImageBufferAfterApplyingDisplayLists):
In the case where we received the wakeup message due to exceeding the display list item count hysteresis, wait
for a short duration using the semaphore after we hit an unread count of 0. This allows the web process to write
more items and signal the semaphore, so that we can resume reading in the GPU process.
(WebKit::RemoteRenderingBackend::wakeUpAndApplyDisplayList):
(WebKit::RemoteRenderingBackend::setNextItemBufferToRead):
* GPUProcess/graphics/RemoteRenderingBackend.h:
* Shared/GPUProcessWakeupMessageArguments.h:
(WebKit::GPUProcessWakeupMessageArguments::encode const):
(WebKit::GPUProcessWakeupMessageArguments::decode):
Plumb a GPUProcessWakeupReason enum flag over to the GPU process, via wake-up arguments. This flag is used by
the GPU process to determine whether we should expect additional items to eventually enter the stream, and
whether we should eagerly go to sleep after processing all known items. In other words, if the wakeup message is
being sent as a result of flushing the image buffer, we don't want to unnecessarily wait for more items;
however, if the wakeup message is being sent as a result of exceeding the (currently) 512-item hysteresis, then
we can probably expect more items to stream in, so it's more optimal to wait after finishing all known display
list items.
* Shared/RemoteRenderingBackendCreationParameters.h: Copied from Source/WebKit/Shared/GPUProcessWakeupMessageArguments.h.
(WebKit::RemoteRenderingBackendCreationParameters::encode const):
(WebKit::RemoteRenderingBackendCreationParameters::decode):
See above for more details.
* Shared/SharedDisplayListHandle.h:
(WebKit::SharedDisplayListHandle::header const):
Adds a new WaitingStatus enum type internal to SharedDisplayListHandle and its subclasses, which is used to
coordinate the act of waiting for new item data in the GPU process. A shared display list handle now contains
an atomic `waitingStatus` flag indicating whether the GPU process is in the process of waiting for more items,
and also whether the web process has acknowledged the fact that the GPU process is waiting (thereby putting the
GPU process in a state where it is waiting to resume processing). Along with this enum, we also add two new
8-byte values to the header section: an offset to begin reading item data after resuming, and 8 bytes for an
identifier indicating the new destination (for the purposes of display list rendering, this is a
RenderingResourceIdentifier, though this will be different for WebGL).
+--> NotWaiting <--+
| | |
| | | [3a]
| [3b] | [1] |
| | |
Resuming +----> Waiting
^ |
| [2] |
+------------------+
There are three main ways in which this state machine may transition, numbered [1]-[3] in the above diagram.
[1] When the GPU process finishes processing available items, it enters Waiting state, indicating that it is now
waiting for additional item data. This corresponds to the call to `DisplayListReaderHandle::startWaiting`.
[2] When the web process bumps the unread count of an item buffer, if it has a pending wakeup message or would
otherwise need to schedule a pending wakeup message, see if we can instead simply tell the GPU process to
resume processing, instead of sending a wakeup message. This corresponds to a call to the helper method
`DisplayListWriterHandle::tryToResume`.
[3] If the maximum wait duration (~30 microseconds) has passed (i.e. scenario 3a) or if the web process has
transitioned us from Waiting to Resuming state (i.e. scenario 3b), then transition back to NotWaiting. In
both scenarios, this corresponds to a call to `DisplayListReaderHandle::stopWaiting`. In the case where we
transitioned from Resuming state, we can immediately continue processing display list items.
In the case where we successfully resume, we're essentially "re-waking" the GPU process without the overhead of
an additional IPC message, using the same shared display list handle. Since this would've otherwise been a
separate wakeup message, we need to be careful that we continue processing display list items from the correct
offset into the shared display list handle, and using the correct destination image buffer. This is because the
writable offset of the item buffer may have been reset in the middle of waiting by the web process, or the
destination image buffer may have changed while waiting. To handle these scenarios, we introduce the
`ResumeReadingInformation` struct, which contains both of these pieces of information. An instance of this
struct exists in the shared memory header section; this is written by the web process immediately prior to
transitioning to Resuming state, and read by the GPU process when transitioning from Resuming to NotWaiting.
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/GPU/graphics/DisplayListWriterHandle.h:
(WebKit::DisplayListWriterHandle::tryToResume):
Add a helper method for the web process to try and notify the GPU process that it should try and resume
display list processing. See the call site in RemoteRenderingBackendProxy for more detail, as well as the
comments in SharedDisplayListHandle above.
* WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
(WebKit::RemoteRenderingBackendProxy::connectToGPUProcess):
(WebKit::RemoteRenderingBackendProxy::didAppendData):
Rather than always schedule (or send) a wakeup message here in the case where the unread count is 0, see if we
can instead tell the GPU process to stop waiting and resume display list processing. To do this, we use the new
DisplayListWriterHandle::tryToResume method, giving it the new offset to begin reading items from as well as the
destination image buffer to which we should apply display list items. If we successfully tell the GPU process to
resume reading, then we can clear out (or avoid storing) wakeup message arguments and avoid sending an IPC
wakeup message.
* WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h:
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (271211 => 271212)
--- trunk/Source/WebKit/ChangeLog 2021-01-06 20:31:23 UTC (rev 271211)
+++ trunk/Source/WebKit/ChangeLog 2021-01-06 20:35:27 UTC (rev 271212)
@@ -1,3 +1,140 @@
+2021-01-06 Wenson Hsieh <[email protected]>
+
+ [Concurrent Display Lists] GPU process should not immediately sleep after reading all available display list items
+ https://bugs.webkit.org/show_bug.cgi?id=219586
+ <rdar://problem/72275412>
+
+ Reviewed by Chris Dumez.
+
+ This patch adds a mechanism for the GPU process to wait for a short duration (~30 microseconds) after it has
+ finished reading all available data in its shared item buffer; if the web process writes additional data to the
+ item buffer (thereby bumping the unread bytes counter) during this time, we immediately resume processing the
+ new display list items in the GPU process, rather than wait for a new wakeup message.
+
+ This allows us to avoid the cost of going to sleep just to immediately wake up in the GPU process, in the case
+ where the web process is writing display list items at a very fast rate and the GPU process just happens to
+ catch up (i.e. advance `unreadBytes()` to 0).
+
+ See below for more details.
+
+ * GPUProcess/GPUConnectionToWebProcess.cpp:
+ (WebKit::GPUConnectionToWebProcess::createRenderingBackend):
+
+ Refactor the rendering backend creation message from the web process to the GPU process, so that the rendering
+ backend creation arguments are encapsulated in a single struct, RemoteRenderingBackendCreationParameters. This
+ struct contains the rendering backend identifier and, on Cocoa platforms, a mach send right that can be used to
+ construct the corresponding display list wakeup semaphore in the GPU process.
+
+ * GPUProcess/GPUConnectionToWebProcess.h:
+ * GPUProcess/GPUConnectionToWebProcess.messages.in:
+ * GPUProcess/graphics/DisplayListReaderHandle.h:
+ (WebKit::DisplayListReaderHandle::startWaiting):
+ (WebKit::DisplayListReaderHandle::stopWaiting):
+
+ Add helper methods for the GPU process to start and stop waiting for new items. See the call site in
+ RemoteRenderingBackend for more detail, as well as the comments in SharedDisplayListHandle below.
+
+ * GPUProcess/graphics/RemoteRenderingBackend.cpp:
+ (WebKit::RemoteRenderingBackend::create):
+ (WebKit::RemoteRenderingBackend::RemoteRenderingBackend):
+
+ Refactor this codepath to take RemoteRenderingBackendCreationParameters instead of just an identifier.
+
+ (WebKit::RemoteRenderingBackend::nextDestinationImageBufferAfterApplyingDisplayLists):
+
+ In the case where we received the wakeup message due to exceeding the display list item count hysteresis, wait
+ for a short duration using the semaphore after we hit an unread count of 0. This allows the web process to write
+ more items and signal the semaphore, so that we can resume reading in the GPU process.
+
+ (WebKit::RemoteRenderingBackend::wakeUpAndApplyDisplayList):
+ (WebKit::RemoteRenderingBackend::setNextItemBufferToRead):
+ * GPUProcess/graphics/RemoteRenderingBackend.h:
+ * Shared/GPUProcessWakeupMessageArguments.h:
+ (WebKit::GPUProcessWakeupMessageArguments::encode const):
+ (WebKit::GPUProcessWakeupMessageArguments::decode):
+
+ Plumb a GPUProcessWakeupReason enum flag over to the GPU process, via wake-up arguments. This flag is used by
+ the GPU process to determine whether we should expect additional items to eventually enter the stream, and
+ whether we should eagerly go to sleep after processing all known items. In other words, if the wakeup message is
+ being sent as a result of flushing the image buffer, we don't want to unnecessarily wait for more items;
+ however, if the wakeup message is being sent as a result of exceeding the (currently) 512-item hysteresis, then
+ we can probably expect more items to stream in, so it's more optimal to wait after finishing all known display
+ list items.
+
+ * Shared/RemoteRenderingBackendCreationParameters.h: Copied from Source/WebKit/Shared/GPUProcessWakeupMessageArguments.h.
+ (WebKit::RemoteRenderingBackendCreationParameters::encode const):
+ (WebKit::RemoteRenderingBackendCreationParameters::decode):
+
+ See above for more details.
+
+ * Shared/SharedDisplayListHandle.h:
+ (WebKit::SharedDisplayListHandle::header const):
+
+ Adds a new WaitingStatus enum type internal to SharedDisplayListHandle and its subclasses, which is used to
+ coordinate the act of waiting for new item data in the GPU process. A shared display list handle now contains
+ an atomic `waitingStatus` flag indicating whether the GPU process is in the process of waiting for more items,
+ and also whether the web process has acknowledged the fact that the GPU process is waiting (thereby putting the
+ GPU process in a state where it is waiting to resume processing). Along with this enum, we also add two new
+ 8-byte values to the header section: an offset to begin reading item data after resuming, and 8 bytes for an
+ identifier indicating the new destination (for the purposes of display list rendering, this is a
+ RenderingResourceIdentifier, though this will be different for WebGL).
+
+ +--> NotWaiting <--+
+ | | |
+ | | | [3a]
+ | [3b] | [1] |
+ | | |
+ Resuming +----> Waiting
+ ^ |
+ | [2] |
+ +------------------+
+
+ There are three main ways in which this state machine may transition, numbered [1]-[3] in the above diagram.
+
+ [1] When the GPU process finishes processing available items, it enters Waiting state, indicating that it is now
+ waiting for additional item data. This corresponds to the call to `DisplayListReaderHandle::startWaiting`.
+
+ [2] When the web process bumps the unread count of an item buffer, if it has a pending wakeup message or would
+ otherwise need to schedule a pending wakeup message, see if we can instead simply tell the GPU process to
+ resume processing, instead of sending a wakeup message. This corresponds to a call to the helper method
+ `DisplayListWriterHandle::tryToResume`.
+
+ [3] If the maximum wait duration (~30 microseconds) has passed (i.e. scenario 3a) or if the web process has
+ transitioned us from Waiting to Resuming state (i.e. scenario 3b), then transition back to NotWaiting. In
+ both scenarios, this corresponds to a call to `DisplayListReaderHandle::stopWaiting`. In the case where we
+ transitioned from Resuming state, we can immediately continue processing display list items.
+
+ In the case where we successfully resume, we're essentially "re-waking" the GPU process without the overhead of
+ an additional IPC message, using the same shared display list handle. Since this would've otherwise been a
+ separate wakeup message, we need to be careful that we continue processing display list items from the correct
+ offset into the shared display list handle, and using the correct destination image buffer. This is because the
+ writable offset of the item buffer may have been reset in the middle of waiting by the web process, or the
+ destination image buffer may have changed while waiting. To handle these scenarios, we introduce the
+ `ResumeReadingInformation` struct, which contains both of these pieces of information. An instance of this
+ struct exists in the shared memory header section; this is written by the web process immediately prior to
+ transitioning to Resuming state, and read by the GPU process when transitioning from Resuming to NotWaiting.
+
+ * WebKit.xcodeproj/project.pbxproj:
+ * WebProcess/GPU/graphics/DisplayListWriterHandle.h:
+ (WebKit::DisplayListWriterHandle::tryToResume):
+
+ Add a helper method for the web process to try and notify the GPU process that it should try and resume
+ display list processing. See the call site in RemoteRenderingBackendProxy for more detail, as well as the
+ comments in SharedDisplayListHandle above.
+
+ * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
+ (WebKit::RemoteRenderingBackendProxy::connectToGPUProcess):
+ (WebKit::RemoteRenderingBackendProxy::didAppendData):
+
+ Rather than always schedule (or send) a wakeup message here in the case where the unread count is 0, see if we
+ can instead tell the GPU process to stop waiting and resume display list processing. To do this, we use the new
+ DisplayListWriterHandle::tryToResume method, giving it the new offset to begin reading items from as well as the
+ destination image buffer to which we should apply display list items. If we successfully tell the GPU process to
+ resume reading, then we can clear out (or avoid storing) wakeup message arguments and avoid sending an IPC
+ wakeup message.
+
+ * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h:
+
2021-01-06 Alex Christensen <[email protected]>
Add SPI to determine whether a regex is supported in WKContentRuleList
Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp (271211 => 271212)
--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp 2021-01-06 20:31:23 UTC (rev 271211)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp 2021-01-06 20:35:27 UTC (rev 271212)
@@ -48,6 +48,7 @@
#include "RemoteMediaResourceManager.h"
#include "RemoteMediaResourceManagerMessages.h"
#include "RemoteRenderingBackend.h"
+#include "RemoteRenderingBackendCreationParameters.h"
#include "RemoteSampleBufferDisplayLayerManager.h"
#include "RemoteSampleBufferDisplayLayerManagerMessages.h"
#include "RemoteSampleBufferDisplayLayerMessages.h"
@@ -288,10 +289,10 @@
}
#endif
-void GPUConnectionToWebProcess::createRenderingBackend(RenderingBackendIdentifier renderingBackendIdentifier)
+void GPUConnectionToWebProcess::createRenderingBackend(RemoteRenderingBackendCreationParameters&& parameters)
{
- auto addResult = m_remoteRenderingBackendMap.ensure(renderingBackendIdentifier, [&]() {
- return RemoteRenderingBackend::create(*this, renderingBackendIdentifier);
+ auto addResult = m_remoteRenderingBackendMap.ensure(parameters.identifier, [&]() {
+ return RemoteRenderingBackend::create(*this, WTFMove(parameters));
});
ASSERT_UNUSED(addResult, addResult.isNewEntry);
}
Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h (271211 => 271212)
--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h 2021-01-06 20:31:23 UTC (rev 271211)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h 2021-01-06 20:35:27 UTC (rev 271212)
@@ -65,6 +65,7 @@
class RemoteSampleBufferDisplayLayerManager;
class UserMediaCaptureManagerProxy;
struct RemoteAudioSessionConfiguration;
+struct RemoteRenderingBackendCreationParameters;
class GPUConnectionToWebProcess
: public RefCounted<GPUConnectionToWebProcess>
@@ -124,7 +125,7 @@
#endif
#endif
- void createRenderingBackend(RenderingBackendIdentifier);
+ void createRenderingBackend(RemoteRenderingBackendCreationParameters&&);
void releaseRenderingBackend(RenderingBackendIdentifier);
#if ENABLE(WEBGL)
Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in (271211 => 271212)
--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in 2021-01-06 20:31:23 UTC (rev 271211)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in 2021-01-06 20:35:27 UTC (rev 271212)
@@ -23,7 +23,7 @@
#if ENABLE(GPU_PROCESS)
messages -> GPUConnectionToWebProcess WantsDispatchMessage {
- void CreateRenderingBackend(WebKit::RenderingBackendIdentifier renderingBackendIdentifier)
+ void CreateRenderingBackend(struct WebKit::RemoteRenderingBackendCreationParameters parameters)
void ReleaseRenderingBackend(WebKit::RenderingBackendIdentifier renderingBackendIdentifier)
#if ENABLE(WEBGL)
void CreateGraphicsContextGL(struct WebCore::GraphicsContextGLAttributes attributes, WebKit::GraphicsContextGLIdentifier graphicsContextGLIdentifier)
Modified: trunk/Source/WebKit/GPUProcess/graphics/DisplayListReaderHandle.h (271211 => 271212)
--- trunk/Source/WebKit/GPUProcess/graphics/DisplayListReaderHandle.h 2021-01-06 20:31:23 UTC (rev 271211)
+++ trunk/Source/WebKit/GPUProcess/graphics/DisplayListReaderHandle.h 2021-01-06 20:35:27 UTC (rev 271212)
@@ -41,6 +41,20 @@
size_t advance(size_t amount) override;
std::unique_ptr<WebCore::DisplayList::DisplayList> displayListForReading(size_t offset, size_t capacity, WebCore::DisplayList::ItemBufferReadingClient&) const;
+ void startWaiting()
+ {
+ header().waitingStatus.store(SharedDisplayListHandle::WaitingStatus::Waiting);
+ }
+
+ Optional<SharedDisplayListHandle::ResumeReadingInformation> stopWaiting()
+ {
+ auto& header = this->header();
+ if (header.waitingStatus.exchange(SharedDisplayListHandle::WaitingStatus::NotWaiting) == SharedDisplayListHandle::WaitingStatus::Resuming)
+ return { header.resumeReadingInfo };
+
+ return WTF::nullopt;
+ }
+
private:
DisplayListReaderHandle(WebCore::DisplayList::ItemBufferIdentifier identifier, Ref<SharedMemory>&& sharedMemory)
: SharedDisplayListHandle(identifier, WTFMove(sharedMemory))
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp (271211 => 271212)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp 2021-01-06 20:31:23 UTC (rev 271211)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp 2021-01-06 20:35:27 UTC (rev 271212)
@@ -33,25 +33,33 @@
#include "PlatformRemoteImageBuffer.h"
#include "RemoteMediaPlayerManagerProxy.h"
#include "RemoteMediaPlayerProxy.h"
+#include "RemoteRenderingBackendCreationParameters.h"
#include "RemoteRenderingBackendMessages.h"
#include "RemoteRenderingBackendProxyMessages.h"
#include <wtf/CheckedArithmetic.h>
#include <wtf/SystemTracing.h>
+#if PLATFORM(COCOA)
+#include <wtf/cocoa/MachSemaphore.h>
+#endif
+
namespace WebKit {
using namespace WebCore;
-std::unique_ptr<RemoteRenderingBackend> RemoteRenderingBackend::create(GPUConnectionToWebProcess& gpuConnectionToWebProcess, RenderingBackendIdentifier renderingBackendIdentifier)
+std::unique_ptr<RemoteRenderingBackend> RemoteRenderingBackend::create(GPUConnectionToWebProcess& gpuConnectionToWebProcess, RemoteRenderingBackendCreationParameters&& parameters)
{
- return std::unique_ptr<RemoteRenderingBackend>(new RemoteRenderingBackend(gpuConnectionToWebProcess, renderingBackendIdentifier));
+ return std::unique_ptr<RemoteRenderingBackend>(new RemoteRenderingBackend(gpuConnectionToWebProcess, WTFMove(parameters)));
}
-RemoteRenderingBackend::RemoteRenderingBackend(GPUConnectionToWebProcess& gpuConnectionToWebProcess, RenderingBackendIdentifier renderingBackendIdentifier)
+RemoteRenderingBackend::RemoteRenderingBackend(GPUConnectionToWebProcess& gpuConnectionToWebProcess, RemoteRenderingBackendCreationParameters&& parameters)
: m_gpuConnectionToWebProcess(makeWeakPtr(gpuConnectionToWebProcess))
- , m_renderingBackendIdentifier(renderingBackendIdentifier)
+ , m_renderingBackendIdentifier(parameters.identifier)
+#if PLATFORM(COCOA)
+ , m_resumeDisplayListSemaphore(makeUnique<MachSemaphore>(WTFMove(parameters.sendRightForResumeDisplayListSemaphore)))
+#endif
{
if (auto* gpuConnectionToWebProcess = m_gpuConnectionToWebProcess.get())
- gpuConnectionToWebProcess->messageReceiverMap().addMessageReceiver(Messages::RemoteRenderingBackend::messageReceiverName(), renderingBackendIdentifier.toUInt64(), *this);
+ gpuConnectionToWebProcess->messageReceiverMap().addMessageReceiver(Messages::RemoteRenderingBackend::messageReceiverName(), m_renderingBackendIdentifier.toUInt64(), *this);
}
RemoteRenderingBackend::~RemoteRenderingBackend()
@@ -153,7 +161,7 @@
}.replay();
}
-RefPtr<ImageBuffer> RemoteRenderingBackend::nextDestinationImageBufferAfterApplyingDisplayLists(ImageBuffer& initialDestination, size_t initialOffset, DisplayListReaderHandle& handle)
+RefPtr<ImageBuffer> RemoteRenderingBackend::nextDestinationImageBufferAfterApplyingDisplayLists(ImageBuffer& initialDestination, size_t initialOffset, DisplayListReaderHandle& handle, GPUProcessWakeupReason reason)
{
auto destination = makeRefPtr(initialDestination);
auto handleProtector = makeRef(handle);
@@ -195,13 +203,13 @@
destination = makeRefPtr(m_remoteResourceCache.cachedImageBuffer(*result.nextDestinationImageBuffer));
if (!destination) {
ASSERT(!m_pendingWakeupInfo);
- m_pendingWakeupInfo = {{{ handle.identifier(), offset, *result.nextDestinationImageBuffer }, WTF::nullopt }};
+ m_pendingWakeupInfo = {{{ handle.identifier(), offset, *result.nextDestinationImageBuffer, reason }, WTF::nullopt }};
}
}
if (result.reasonForStopping == DisplayList::StopReplayReason::MissingCachedResource) {
m_pendingWakeupInfo = {{
- { handle.identifier(), offset, destination->renderingResourceIdentifier() },
+ { handle.identifier(), offset, destination->renderingResourceIdentifier(), reason },
result.missingCachedResourceIdentifier
}};
}
@@ -209,8 +217,51 @@
if (m_pendingWakeupInfo)
break;
- if (!sizeToRead)
- break;
+ if (!sizeToRead) {
+ if (reason != GPUProcessWakeupReason::ItemCountHysteresisExceeded)
+ break;
+
+ handle.startWaiting();
+#if PLATFORM(COCOA)
+ m_resumeDisplayListSemaphore->waitFor(30_us);
+#else
+ sleep(30_us);
+#endif
+
+ auto resumeReadingInfo = handle.stopWaiting();
+ if (!resumeReadingInfo)
+ break;
+
+ sizeToRead = handle.unreadBytes();
+ if (UNLIKELY(!sizeToRead)) {
+ // FIXME: Add a message check to terminate the web process.
+ ASSERT_NOT_REACHED();
+ break;
+ }
+
+ auto newDestinationIdentifier = makeObjectIdentifier<RenderingResourceIdentifierType>(resumeReadingInfo->destination);
+ if (UNLIKELY(!newDestinationIdentifier)) {
+ // FIXME: Add a message check to terminate the web process.
+ ASSERT_NOT_REACHED();
+ break;
+ }
+
+ destination = makeRefPtr(m_remoteResourceCache.cachedImageBuffer(newDestinationIdentifier));
+
+ if (UNLIKELY(!destination)) {
+ // FIXME: Add a message check to terminate the web process.
+ ASSERT_NOT_REACHED();
+ break;
+ }
+
+ offset = resumeReadingInfo->offset;
+
+ if (!destination) {
+ ASSERT(!m_pendingWakeupInfo);
+ m_pendingWakeupInfo = {{{ handle.identifier(), offset, newDestinationIdentifier, reason }, WTF::nullopt }};
+ break;
+ }
+ }
}
return destination;
@@ -233,7 +284,7 @@
return;
}
- destinationImageBuffer = nextDestinationImageBufferAfterApplyingDisplayLists(*destinationImageBuffer, arguments.offset, *initialHandle);
+ destinationImageBuffer = nextDestinationImageBufferAfterApplyingDisplayLists(*destinationImageBuffer, arguments.offset, *initialHandle, arguments.reason);
if (!destinationImageBuffer) {
RELEASE_ASSERT(m_pendingWakeupInfo);
return;
@@ -252,7 +303,7 @@
// Otherwise, continue reading the next display list item buffer from the start.
auto arguments = std::exchange(m_pendingWakeupInfo, WTF::nullopt)->arguments;
- destinationImageBuffer = nextDestinationImageBufferAfterApplyingDisplayLists(*destinationImageBuffer, arguments.offset, *nextHandle);
+ destinationImageBuffer = nextDestinationImageBufferAfterApplyingDisplayLists(*destinationImageBuffer, arguments.offset, *nextHandle, arguments.reason);
if (!destinationImageBuffer) {
RELEASE_ASSERT(m_pendingWakeupInfo);
break;
@@ -267,7 +318,7 @@
ASSERT_NOT_REACHED();
return;
}
- m_pendingWakeupInfo = {{{ identifier, SharedDisplayListHandle::headerSize(), destinationIdentifier }, WTF::nullopt }};
+ m_pendingWakeupInfo = {{{ identifier, SharedDisplayListHandle::headerSize(), destinationIdentifier, GPUProcessWakeupReason::Unspecified }, WTF::nullopt }};
}
void RemoteRenderingBackend::getImageData(AlphaPremultiplication outputFormat, IntRect srcRect, RenderingResourceIdentifier renderingResourceIdentifier, CompletionHandler<void(IPC::ImageDataReference&&)>&& completionHandler)
Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h (271211 => 271212)
--- trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h 2021-01-06 20:31:23 UTC (rev 271211)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h 2021-01-06 20:35:27 UTC (rev 271212)
@@ -41,6 +41,12 @@
#include <WebCore/DisplayListReplayer.h>
#include <wtf/WeakPtr.h>
+#if PLATFORM(COCOA)
+namespace WTF {
+class MachSemaphore;
+}
+#endif
+
namespace WebCore {
namespace DisplayList {
class DisplayList;
@@ -56,6 +62,7 @@
class DisplayListReaderHandle;
class GPUConnectionToWebProcess;
+struct RemoteRenderingBackendCreationParameters;
class RemoteRenderingBackend
: public IPC::MessageSender
@@ -62,7 +69,7 @@
, private IPC::MessageReceiver
, public WebCore::DisplayList::ItemBufferReadingClient {
public:
- static std::unique_ptr<RemoteRenderingBackend> create(GPUConnectionToWebProcess&, RenderingBackendIdentifier);
+ static std::unique_ptr<RemoteRenderingBackend> create(GPUConnectionToWebProcess&, RemoteRenderingBackendCreationParameters&&);
virtual ~RemoteRenderingBackend();
GPUConnectionToWebProcess* gpuConnectionToWebProcess() const;
@@ -78,7 +85,7 @@
void setNextItemBufferToRead(WebCore::DisplayList::ItemBufferIdentifier, WebCore::RenderingResourceIdentifier destination);
private:
- RemoteRenderingBackend(GPUConnectionToWebProcess&, RenderingBackendIdentifier);
+ RemoteRenderingBackend(GPUConnectionToWebProcess&, RemoteRenderingBackendCreationParameters&&);
Optional<WebCore::DisplayList::ItemHandle> WARN_UNUSED_RETURN decodeItem(const uint8_t* data, size_t length, WebCore::DisplayList::ItemType, uint8_t* handleLocation) override;
@@ -95,7 +102,7 @@
}
WebCore::DisplayList::ReplayResult submit(const WebCore::DisplayList::DisplayList&, WebCore::ImageBuffer& destination);
- RefPtr<WebCore::ImageBuffer> nextDestinationImageBufferAfterApplyingDisplayLists(WebCore::ImageBuffer& initialDestination, size_t initialOffset, DisplayListReaderHandle&);
+ RefPtr<WebCore::ImageBuffer> nextDestinationImageBufferAfterApplyingDisplayLists(WebCore::ImageBuffer& initialDestination, size_t initialOffset, DisplayListReaderHandle&, GPUProcessWakeupReason);
// IPC::MessageSender.
IPC::Connection* messageSenderConnection() const override;
@@ -139,6 +146,9 @@
RenderingBackendIdentifier m_renderingBackendIdentifier;
HashMap<WebCore::DisplayList::ItemBufferIdentifier, RefPtr<DisplayListReaderHandle>> m_sharedDisplayListHandles;
Optional<PendingWakeupInformation> m_pendingWakeupInfo;
+#if PLATFORM(COCOA)
+ std::unique_ptr<WTF::MachSemaphore> m_resumeDisplayListSemaphore;
+#endif
};
} // namespace WebKit
Modified: trunk/Source/WebKit/Shared/GPUProcessWakeupMessageArguments.h (271211 => 271212)
--- trunk/Source/WebKit/Shared/GPUProcessWakeupMessageArguments.h 2021-01-06 20:31:23 UTC (rev 271211)
+++ trunk/Source/WebKit/Shared/GPUProcessWakeupMessageArguments.h 2021-01-06 20:35:27 UTC (rev 271212)
@@ -32,10 +32,16 @@
namespace WebKit {
+enum class GPUProcessWakeupReason : uint8_t {
+ Unspecified,
+ ItemCountHysteresisExceeded
+};
+
struct GPUProcessWakeupMessageArguments {
WebCore::DisplayList::ItemBufferIdentifier itemBufferIdentifier;
uint64_t offset { 0 };
WebCore::RenderingResourceIdentifier destinationImageBufferIdentifier;
+ GPUProcessWakeupReason reason { GPUProcessWakeupReason::Unspecified };
template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static Optional<GPUProcessWakeupMessageArguments> decode(Decoder&);
@@ -47,6 +53,7 @@
encoder << itemBufferIdentifier;
encoder << offset;
encoder << destinationImageBufferIdentifier;
+ encoder << reason;
}
template<class Decoder>
@@ -67,9 +74,26 @@
if (!destinationImageBufferIdentifier)
return WTF::nullopt;
- return {{ *itemBufferIdentifier, *offset, *destinationImageBufferIdentifier }};
+ Optional<GPUProcessWakeupReason> reason;
+ decoder >> reason;
+ if (!reason)
+ return WTF::nullopt;
+
+ return {{ *itemBufferIdentifier, *offset, *destinationImageBufferIdentifier, *reason }};
}
} // namespace WebKit
+namespace WTF {
+
+template<> struct EnumTraits<WebKit::GPUProcessWakeupReason> {
+ using values = EnumValues<
+ WebKit::GPUProcessWakeupReason,
+ WebKit::GPUProcessWakeupReason::Unspecified,
+ WebKit::GPUProcessWakeupReason::ItemCountHysteresisExceeded
+ >;
+};
+
+} // namespace WTF
+
#endif // ENABLE(GPU_PROCESS)
Copied: trunk/Source/WebKit/Shared/RemoteRenderingBackendCreationParameters.h (from rev 271211, trunk/Source/WebKit/Shared/GPUProcessWakeupMessageArguments.h) (0 => 271212)
--- trunk/Source/WebKit/Shared/RemoteRenderingBackendCreationParameters.h (rev 0)
+++ trunk/Source/WebKit/Shared/RemoteRenderingBackendCreationParameters.h 2021-01-06 20:35:27 UTC (rev 271212)
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(GPU_PROCESS)
+
+#include "RenderingBackendIdentifier.h"
+#include <wtf/MachSendRight.h>
+
+namespace WebKit {
+
+struct RemoteRenderingBackendCreationParameters {
+ RenderingBackendIdentifier identifier;
+#if PLATFORM(COCOA)
+ MachSendRight sendRightForResumeDisplayListSemaphore;
+#endif
+
+ template<class Encoder> void encode(Encoder&) const;
+ template<class Decoder> static Optional<RemoteRenderingBackendCreationParameters> decode(Decoder&);
+};
+
+template<class Encoder>
+void RemoteRenderingBackendCreationParameters::encode(Encoder& encoder) const
+{
+ encoder << identifier;
+#if PLATFORM(COCOA)
+ encoder << sendRightForResumeDisplayListSemaphore;
+#endif
+}
+
+template<class Decoder>
+Optional<RemoteRenderingBackendCreationParameters> RemoteRenderingBackendCreationParameters::decode(Decoder& decoder)
+{
+ RemoteRenderingBackendCreationParameters parameters;
+
+ Optional<RenderingBackendIdentifier> identifier;
+ decoder >> identifier;
+ if (!identifier)
+ return WTF::nullopt;
+
+ parameters.identifier = *identifier;
+
+#if PLATFORM(COCOA)
+ Optional<MachSendRight> sendRightForResumeDisplayListSemaphore;
+ decoder >> sendRightForResumeDisplayListSemaphore;
+ if (!sendRightForResumeDisplayListSemaphore)
+ return WTF::nullopt;
+
+ parameters.sendRightForResumeDisplayListSemaphore = WTFMove(*sendRightForResumeDisplayListSemaphore);
+#endif
+
+ return parameters;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(GPU_PROCESS)
Modified: trunk/Source/WebKit/Shared/SharedDisplayListHandle.h (271211 => 271212)
--- trunk/Source/WebKit/Shared/SharedDisplayListHandle.h 2021-01-06 20:31:23 UTC (rev 271211)
+++ trunk/Source/WebKit/Shared/SharedDisplayListHandle.h 2021-01-06 20:35:27 UTC (rev 271212)
@@ -55,6 +55,17 @@
virtual size_t advance(size_t amount) = 0;
+ enum class WaitingStatus : uint8_t {
+ NotWaiting,
+ Waiting,
+ Resuming
+ };
+
+ struct ResumeReadingInformation {
+ uint64_t offset;
+ uint64_t destination;
+ };
+
protected:
SharedDisplayListHandle(WebCore::DisplayList::ItemBufferIdentifier identifier, Ref<SharedMemory>&& sharedMemory)
: m_identifier(identifier)
@@ -67,8 +78,11 @@
~DisplayListSharedMemoryHeader() = delete;
Atomic<uint64_t> unreadBytes;
+ ResumeReadingInformation resumeReadingInfo;
+ Atomic<WaitingStatus> waitingStatus;
};
+ const DisplayListSharedMemoryHeader& header() const { return *reinterpret_cast<const DisplayListSharedMemoryHeader*>(data()); }
DisplayListSharedMemoryHeader& header() { return *reinterpret_cast<DisplayListSharedMemoryHeader*>(data()); }
private:
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (271211 => 271212)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-01-06 20:31:23 UTC (rev 271211)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-01-06 20:35:27 UTC (rev 271212)
@@ -1968,6 +1968,7 @@
F42D634122A0EFDF00D2FB3A /* WebAutocorrectionData.h in Headers */ = {isa = PBXBuildFile; fileRef = F42D633F22A0EFD300D2FB3A /* WebAutocorrectionData.h */; };
F430E9422247335F005FE053 /* WebsiteMetaViewportPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = F430E941224732A9005FE053 /* WebsiteMetaViewportPolicy.h */; };
F430E94422473DFF005FE053 /* WebContentMode.h in Headers */ = {isa = PBXBuildFile; fileRef = F430E94322473DB8005FE053 /* WebContentMode.h */; };
+ F437C8D92593B7E300DB8A1C /* RemoteRenderingBackendCreationParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = F437C8D82593B7E300DB8A1C /* RemoteRenderingBackendCreationParameters.h */; };
F438CD1C2241421400DE6DDA /* WKWebpagePreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = F438CD1B224140A600DE6DDA /* WKWebpagePreferences.h */; settings = {ATTRIBUTES = (Public, ); }; };
F438CD1F22414D4000DE6DDA /* WKWebpagePreferencesInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = F438CD1E22414D4000DE6DDA /* WKWebpagePreferencesInternal.h */; };
F438CD212241F69500DE6DDA /* WKWebpagePreferencesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = F438CD202241F69500DE6DDA /* WKWebpagePreferencesPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -5777,6 +5778,7 @@
F42D634022A0EFD300D2FB3A /* WebAutocorrectionData.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebAutocorrectionData.mm; path = ios/WebAutocorrectionData.mm; sourceTree = "<group>"; };
F430E941224732A9005FE053 /* WebsiteMetaViewportPolicy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebsiteMetaViewportPolicy.h; sourceTree = "<group>"; };
F430E94322473DB8005FE053 /* WebContentMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebContentMode.h; sourceTree = "<group>"; };
+ F437C8D82593B7E300DB8A1C /* RemoteRenderingBackendCreationParameters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteRenderingBackendCreationParameters.h; sourceTree = "<group>"; };
F438CD1B224140A600DE6DDA /* WKWebpagePreferences.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWebpagePreferences.h; sourceTree = "<group>"; };
F438CD1D22414AD600DE6DDA /* WKWebpagePreferences.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebpagePreferences.mm; sourceTree = "<group>"; };
F438CD1E22414D4000DE6DDA /* WKWebpagePreferencesInternal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWebpagePreferencesInternal.h; sourceTree = "<group>"; };
@@ -6514,6 +6516,7 @@
E1CC1B8E12D7EADF00625838 /* PrintInfo.h */,
463FD4811EB94EAD00A2982C /* ProcessTerminationReason.h */,
9B1229D023FF2A5E008CA751 /* RemoteAudioDestinationIdentifier.h */,
+ F437C8D82593B7E300DB8A1C /* RemoteRenderingBackendCreationParameters.h */,
5CB7AFE623C681B000E49CF3 /* ResourceLoadInfo.h */,
5C00993B2417FB7E00D53C25 /* ResourceLoadStatisticsParameters.h */,
410482CB1DDD2FB500F006D0 /* RTCNetwork.cpp */,
@@ -11848,6 +11851,7 @@
1A5704FC1BE1751100874AF1 /* RemoteObjectInvocation.h in Headers */,
1AC1338018590AE400F3EC05 /* RemoteObjectRegistry.h in Headers */,
1AC1338618590C4600F3EC05 /* RemoteObjectRegistryMessages.h in Headers */,
+ F437C8D92593B7E300DB8A1C /* RemoteRenderingBackendCreationParameters.h in Headers */,
0F594790187B3B3A00437857 /* RemoteScrollingCoordinator.h in Headers */,
0F5947A8187B517600437857 /* RemoteScrollingCoordinatorMessages.h in Headers */,
0F59479B187B3B6000437857 /* RemoteScrollingCoordinatorProxy.h in Headers */,
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/DisplayListWriterHandle.h (271211 => 271212)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/DisplayListWriterHandle.h 2021-01-06 20:31:23 UTC (rev 271211)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/DisplayListWriterHandle.h 2021-01-06 20:35:27 UTC (rev 271212)
@@ -46,6 +46,13 @@
size_t advance(size_t amount) override;
WebCore::DisplayList::ItemBufferHandle createHandle() const;
+ bool tryToResume(SharedDisplayListHandle::ResumeReadingInformation&& info)
+ {
+ auto& header = this->header();
+ header.resumeReadingInfo = WTFMove(info);
+ return header.waitingStatus.compareExchangeWeak(SharedDisplayListHandle::WaitingStatus::Waiting, SharedDisplayListHandle::WaitingStatus::Resuming);
+ }
+
private:
DisplayListWriterHandle(WebCore::DisplayList::ItemBufferIdentifier identifier, Ref<SharedMemory>&& sharedMemory)
: SharedDisplayListHandle(identifier, WTFMove(sharedMemory))
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp (271211 => 271212)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp 2021-01-06 20:31:23 UTC (rev 271211)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp 2021-01-06 20:35:27 UTC (rev 271212)
@@ -32,6 +32,7 @@
#include "GPUConnectionToWebProcess.h"
#include "ImageDataReference.h"
#include "PlatformRemoteImageBufferProxy.h"
+#include "RemoteRenderingBackendCreationParameters.h"
#include "RemoteRenderingBackendMessages.h"
#include "RemoteRenderingBackendProxyMessages.h"
#include "SharedMemory.h"
@@ -66,8 +67,12 @@
auto& connection = WebProcess::singleton().ensureGPUProcessConnection();
connection.addClient(*this);
connection.messageReceiverMap().addMessageReceiver(Messages::RemoteRenderingBackendProxy::messageReceiverName(), m_renderingBackendIdentifier.toUInt64(), *this);
-
- send(Messages::GPUConnectionToWebProcess::CreateRenderingBackend(m_renderingBackendIdentifier), 0);
+ send(Messages::GPUConnectionToWebProcess::CreateRenderingBackend({
+ m_renderingBackendIdentifier,
+#if PLATFORM(COCOA)
+ m_resumeDisplayListSemaphore.createSendRight(),
+#endif
+ }), 0);
}
void RemoteRenderingBackendProxy::reestablishGPUProcessConnection()
@@ -272,13 +277,31 @@
bool wasEmpty = sharedHandle->advance(numberOfBytes) == numberOfBytes;
if (!wasEmpty || didChangeItemBuffer == DisplayList::DidChangeItemBuffer::Yes) {
- if (m_deferredWakeupMessageArguments && !--m_remainingItemsToAppendBeforeSendingWakeup)
- sendWakeupMessage(*std::exchange(m_deferredWakeupMessageArguments, WTF::nullopt));
+ if (m_deferredWakeupMessageArguments) {
+ if (sharedHandle->tryToResume({ m_deferredWakeupMessageArguments->offset, m_deferredWakeupMessageArguments->destinationImageBufferIdentifier.toUInt64() })) {
+#if PLATFORM(COCOA)
+ m_resumeDisplayListSemaphore.signal();
+#endif
+ m_deferredWakeupMessageArguments = WTF::nullopt;
+ m_remainingItemsToAppendBeforeSendingWakeup = 0;
+ } else if (!--m_remainingItemsToAppendBeforeSendingWakeup) {
+ m_deferredWakeupMessageArguments->reason = GPUProcessWakeupReason::ItemCountHysteresisExceeded;
+ sendWakeupMessage(*std::exchange(m_deferredWakeupMessageArguments, WTF::nullopt));
+ }
+ }
return;
}
sendDeferredWakeupMessageIfNeeded();
+ auto offsetToRead = sharedHandle->writableOffset() - numberOfBytes;
+ if (sharedHandle->tryToResume({ offsetToRead, destinationImageBuffer.toUInt64() })) {
+#if PLATFORM(COCOA)
+ m_resumeDisplayListSemaphore.signal();
+#endif
+ return;
+ }
+
// Instead of sending the wakeup message immediately, wait for some additional data. This gives the
// web process a "head start", decreasing the likelihood that the GPU process will encounter frequent
// wakeups when processing a large amount of display list items.
@@ -285,11 +308,7 @@
constexpr unsigned itemCountHysteresisBeforeSendingWakeup = 512;
m_remainingItemsToAppendBeforeSendingWakeup = itemCountHysteresisBeforeSendingWakeup;
- m_deferredWakeupMessageArguments = {{
- handle.identifier,
- sharedHandle->writableOffset() - numberOfBytes,
- destinationImageBuffer
- }};
+ m_deferredWakeupMessageArguments = {{ handle.identifier, offsetToRead, destinationImageBuffer }};
}
RefPtr<DisplayListWriterHandle> RemoteRenderingBackendProxy::mostRecentlyUsedDisplayListHandle()
Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h (271211 => 271212)
--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h 2021-01-06 20:31:23 UTC (rev 271211)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h 2021-01-06 20:35:27 UTC (rev 271212)
@@ -39,6 +39,10 @@
#include <wtf/Deque.h>
#include <wtf/WeakPtr.h>
+#if PLATFORM(COCOA)
+#include <wtf/cocoa/MachSemaphore.h>
+#endif
+
namespace WebCore {
namespace DisplayList {
class DisplayList;
@@ -122,6 +126,9 @@
Optional<WebCore::RenderingResourceIdentifier> m_currentDestinationImageBufferIdentifier;
Optional<GPUProcessWakeupMessageArguments> m_deferredWakeupMessageArguments;
unsigned m_remainingItemsToAppendBeforeSendingWakeup { 0 };
+#if PLATFORM(COCOA)
+ MachSemaphore m_resumeDisplayListSemaphore;
+#endif
};
} // namespace WebKit