https://bugs.webkit.org/show_bug.cgi?id=222835
Reviewed by Simon Fraser.
Source/WTF:
Move UseGPUProcessForCanvasRenderingEnabled from WebPreferencesInternal
to WebPreferencesExperimental so that the WebKitTestRunner will turn it
on by default.
* Scripts/Preferences/WebPreferencesExperimental.yaml:
* Scripts/Preferences/WebPreferencesInternal.yaml:
LayoutTests:
Some of the canvas layout tests are still failing when GPUP is enabled
for 2D Canvas. Skip these tests for now.
* TestExpectations:
* gpu-process/TestExpectations:
* http/tests/canvas/color-fonts/fill-gradient-sbix-2.html:
* http/tests/canvas/color-fonts/fill-gradient-sbix-3.html:
* http/tests/canvas/color-fonts/fill-gradient-sbix-4.html:
* http/tests/canvas/color-fonts/stroke-gradient-sbix-2.html:
* http/tests/canvas/color-fonts/stroke-gradient-sbix-3.html:
* http/tests/canvas/color-fonts/stroke-gradient-sbix-4.html:
webkit.org/b/222881
* inspector/canvas/memory.html:
webkit.org/b/222880
Canonical link: https://commits.webkit.org/235215@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274327 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=222835
Reviewed by Simon Fraser.
Source/WTF:
Move UseGPUProcessForCanvasRenderingEnabled from WebPreferencesInternal
to WebPreferencesExperimental so that the WebKitTestRunner will turn it
on by default.
* Scripts/Preferences/WebPreferencesExperimental.yaml:
* Scripts/Preferences/WebPreferencesInternal.yaml:
LayoutTests:
Some of the canvas layout tests are still failing when GPUP is enabled
for 2D Canvas. Skip these tests for now.
* TestExpectations:
* gpu-process/TestExpectations:
* http/tests/canvas/color-fonts/fill-gradient-sbix-2.html:
* http/tests/canvas/color-fonts/fill-gradient-sbix-3.html:
* http/tests/canvas/color-fonts/fill-gradient-sbix-4.html:
* http/tests/canvas/color-fonts/stroke-gradient-sbix-2.html:
* http/tests/canvas/color-fonts/stroke-gradient-sbix-3.html:
* http/tests/canvas/color-fonts/stroke-gradient-sbix-4.html:
webkit.org/b/222881
* inspector/canvas/memory.html:
webkit.org/b/222880
Canonical link: https://commits.webkit.org/235092@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274171 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=222546
Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-03-08
Reviewed by Wenson Hsieh.
Source/WebCore:
Add a trigger internals.simulateEventForWebGLContext("timeout", context)
to trigger timeout for calls to a WebGL context.
Tests: fast/canvas/webgl/lose-context-on-timeout-async.html
fast/canvas/webgl/lose-context-on-timeout.html
* testing/Internals.cpp:
(WebCore::Internals::simulateEventForWebGLContext):
Source/WebKit:
IPC::StreamClientConnection::tryAcquire would assert on
ASSERT(untrustedLimit < (dataSize() - 1));
The untrustedLimit value would be then:
StreamConnectionBuffer::serverOffsetClientIsWaitingTag.
This would be equivalent of assertion added in this commit:
ASSERT(clientLimit != ClientLimit::clientIsWaitingTag);
This would happen in case of timeout, because upon entering
the wait sequence:
1) The client itself would first write the tag value to the
offset variable.
2) Wait and timeout the wait.
3) run the next iteration of the acquire loop.
The next iteration would load the tag value written before,
e.g. serverOffsetClientIsWaitingTag.
This would be then used in clampedLimit() call.
Fix this by taking it into account that the variable might be
ClientLimit::clientIsWaitingTag within the acquire loop.
Possibly fix future similar problems by not treating the value as
size_t, rather treat it as enum class ClientOffset : size_t. This
enables the compiler to enforce that when checking for the various tag
values, the holder must hold the enum class. When intending to interpret
the value as size_t, holder must explicitly convert.
Do the above change for the ServerOffset.
Tests: fast/canvas/webgl/lose-context-on-timeout-async.html
fast/canvas/webgl/lose-context-on-timeout.html
* GPUProcess/GPUConnectionToWebProcess.cpp:
(WebKit::GPUConnectionToWebProcess::releaseGraphicsContextGL):
Do not assert that the release message actually releases the context.
For testing, the induce the timeout by releasing the context prematurely
and treating the subsequent messages as if they were non-legit messages.
That should be just skipped.
(WebKit::GPUConnectionToWebProcess::releaseGraphicsContextGLForTesting):
Add a public function to invoke from "ForTesting" codepaths.
(WebKit::GPUConnectionToWebProcess::dispatchMessage):
(WebKit::GPUConnectionToWebProcess::dispatchSyncMessage):
Skip RemoteGraphicsContextGL messages that do not get routed to any
instance. These messages can be "non-legit", ones that are sent before
the "context was lost" message reached the sender, or ones that are
sent during simulated timeout.
These do not contain asserts as it is expected that these will occur in
above situations.
* GPUProcess/GPUConnectionToWebProcess.h:
* GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
(WebKit::RemoteGraphicsContextGL::simulateEventForTesting):
* GPUProcess/graphics/RemoteGraphicsContextGL.h:
* GPUProcess/graphics/RemoteGraphicsContextGL.messages.in:
* GPUProcess/graphics/RemoteGraphicsContextGLFunctionsGenerated.h:
Add the simulateEventForTesting function to simulate the
timeout. Simulate via just removing the context, which causes
left-over messages to skipped.
Currently we do not simulate the timeout with an infinite loop
in GPU process threads as that is not supported.
Currently we do not simulate the timeout with a gpu process
crash since it is not supported to be tested (will cause a
reload).
* Platform/IPC/StreamClientConnection.cpp:
(IPC::StreamClientConnection::StreamClientConnection):
* Platform/IPC/StreamClientConnection.h:
(IPC::StreamClientConnection::sendSync):
(IPC::StreamClientConnection::release):
Change size_t usage to -> ClientOffset, ServerOffset
(IPC::StreamClientConnection::tryAcquire):
Fix the assertion of equivalent of ASSERT(clientLimit != ClientLimit::clientIsWaitingTag);
by reorganizing the acquire loop.
(IPC::StreamClientConnection::toLimit const):
Fix the off-by-one in assertion error
( < dataSize() - 1 vs <= dataSize() - 1)
Rename from clampedLimit() to toLimit(), as the
clamping is confusing as the client trusts the
server.
* Platform/IPC/StreamConnectionBuffer.cpp:
(IPC::StreamConnectionBuffer::StreamConnectionBuffer):
(IPC::StreamConnectionBuffer::operator=):
(IPC::StreamConnectionBuffer::encode const):
* Platform/IPC/StreamConnectionBuffer.h:
(IPC::StreamConnectionBuffer::clientOffset):
(IPC::StreamConnectionBuffer::serverOffset):
(IPC::StreamConnectionBuffer::clientWaitSemaphore):
(IPC::StreamConnectionBuffer::maximumSize):
* Platform/IPC/StreamServerConnection.cpp:
(IPC::StreamServerConnectionBase::tryAquire):
(IPC::StreamServerConnectionBase::release):
Change size_t usage to -> ClientOffset, ServerOffset
(IPC::StreamServerConnectionBase::clampedLimit const):
Fix the off-by-one in assertion error
( < dataSize() - 1 vs <= dataSize() - 1)
* Platform/IPC/StreamServerConnection.h:
(IPC::StreamServerConnectionBase::sharedServerLimit):
(IPC::StreamServerConnectionBase::sharedServerOffset):
* WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp:
(WebKit::RemoteGraphicsContextGLProxy::synthesizeGLError):
(WebKit::RemoteGraphicsContextGLProxy::getError):
For the cases where the timeout would happen in these two functions,
call the markContextLost() instead of wasLost(). This is to clarify
all the context lost handling to use the same pattern.
(WebKit::RemoteGraphicsContextGLProxy::simulateEventForTesting):
* WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h:
* WebProcess/GPU/graphics/RemoteGraphicsContextGLProxyFunctionsGenerated.cpp:
LayoutTests:
Add tests to test the case where a WebGL call times out.
Add two variants: one which most probably times out on
synchronous call, and one which most probably times out on
asynchronous call.
* fast/canvas/webgl/lose-context-on-status-failure.html:
The testing APIs were changed, so replace use of
Internals.setFailNextGPUStatusCheck()
with Internals.simulateEventForWebGLContext()
* fast/canvas/webgl/lose-context-on-timeout-async-expected.txt: Added.
* fast/canvas/webgl/lose-context-on-timeout-async.html: Added.
* fast/canvas/webgl/lose-context-on-timeout-expected.txt: Added.
* fast/canvas/webgl/lose-context-on-timeout.html: Added.
* fast/canvas/webgl/webglcontextchangedevent.html:
Canonical link: https://commits.webkit.org/235002@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274066 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=222855
Reviewed by Simon Fraser.
Source/WebCore:
After appending BeginTransparencyLayer item, the alpha of lastDrawingState
should be reset. So any subsequent setAlpha() should be accumulated even
if the new alpha equals to the last alpha which was set in lastDrawingState.
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::beginTransparencyLayer):
(WebCore::GraphicsContext::endTransparencyLayer):
* platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::Recorder::beginTransparencyLayer):
(WebCore::DisplayList::Recorder::endTransparencyLayer):
* platform/graphics/displaylists/DisplayListRecorder.h:
(WebCore::DisplayList::Recorder::ContextState::cloneForTransparencyLayer const):
LayoutTests:
* gpu-process/TestExpectations:
Canonical link: https://commits.webkit.org/234993@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274057 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=222500
Reviewed by Jer Noble.
r273568 adds the support to paint GPU process hosted video in the WebContent process to
2D canvas and WebGL surfaces. This function is used by layout tests no matter
"GPU Process: Canvas Rendering" and "GPU Process: WebGL" are enabled or not.
A lot of tests depending on it are passing now.
* gpu-process/TestExpectations:
* platform/mac-wk2/TestExpectations:
* platform/wk2/TestExpectations:
Canonical link: https://commits.webkit.org/234662@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273616 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=222456
Reviewed by Simon Fraser.
* gpu-process/TestExpectations:
Remove a duplicated expectation (imported/w3c/web-platform-tests/fetch/range/general.window.html).
Move webaudio related test expectations to platform/wk2/TestExpectations.
* platform/ios-wk2/TestExpectations:
webkit.org/b/221821 has been fixed in r273504.
* platform/mac-wk2/TestExpectations:
Two media capabilities test failures have been fixed in r273504.
Move a test expectation (platform/mac/media/media-source/videoplaybackquality-decompressionsession.html)
to platform/mac/TestExpectations.
Reorganize expectations for tests in webgl/2.0.0/conformance2/textures/video.
* platform/mac/TestExpectations:
Remove a duplicated test expectation (mediaElementAudioSourceToScriptProcessorTest.html).
* platform/wk2/TestExpectations:
Track all modern-media-controls test failures in one bug.
Track all canvas related media test failures in one bug.
Canonical link: https://commits.webkit.org/234619@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273559 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=222348
Reviewed by Simon Fraser.
Source/WebKit:
The default implementation ImageBufferBackend::bytesPerRow() is not correct
for ImageBufferShareableBitmapBackend because ShareableBitmap aligns the
rows using IOSurfaceAlignProperty(kIOSurfaceBytesPerRow, ...).
* Shared/ShareableBitmap.h:
(WebKit::ShareableBitmap::bytesPerRow const):
* WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp:
(WebKit::ImageBufferShareableBitmapBackend::bytesPerRow const):
* WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.h:
LayoutTests:
* gpu-process/TestExpectations:
Canonical link: https://commits.webkit.org/234517@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273406 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=222101
Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-02-23
Reviewed by Simon Fraser.
Source/WebKit:
Implement RemoteImageBufferProxy::copyImage and
RemoteImageBufferProxy::copyNativeImage.
Implement by asking the data from the GPU process.
Previously, with AcceleratedImageBufferShareableMappedBackend
the HTMLCanvasElement::copiedImage() would construct the copy
by copying the CGContext backed by the IOSurface that is accessible
by both processes. This would succeed. After a draw to the image,
the second copy would not reflect the draw but contain the same
image as the first copy.
Fix by not using the fact that the IOSurface is accessible by both
processes. In the end, IOSurfaces will not be available in
Web process.
Converts NativeImage to ShareableBitmap with WebCore::CompositeOperator::Copy
since the ImageBuffers might have unpremultiplied contents. Also, ShareableBitmap
does not have contents, so blending is overhead.
No new tests, enables ~150 tests.
* GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
(WebKit::RemoteGraphicsContextGL::copyTextureFromMedia):
* GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::getShareableBitmapForImageBuffer):
* GPUProcess/graphics/RemoteRenderingBackend.h:
* GPUProcess/graphics/RemoteRenderingBackend.messages.in:
* WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
* WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
(WebKit::RemoteRenderingBackendProxy::getShareableBitmap):
* WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h:
LayoutTests:
* gpu-process/TestExpectations:
Canonical link: https://commits.webkit.org/234461@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273301 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=222230
Reviewed by Simon Fraser.
Source/WebCore:
Instead of encoding and decoding the clipping commands as a separate
DisplayList, the recorder will insert a "begin" and "end" markers before
and after the clipping commands.
When replaying the "begin" mark, the replayer will create a mask ImageBuffer
and force using its context for the following items.
When replaying the "end" mark, it will clip the original context to the
mask ImageBuffer.
* platform/graphics/displaylists/DisplayList.cpp:
(WebCore::DisplayList::DisplayList::append):
* platform/graphics/displaylists/DisplayListItemBuffer.cpp:
(WebCore::DisplayList::ItemHandle::apply):
(WebCore::DisplayList::ItemHandle::destroy):
(WebCore::DisplayList::ItemHandle::safeCopy const):
* platform/graphics/displaylists/DisplayListItemType.cpp:
(WebCore::DisplayList::sizeOfItemInBytes):
(WebCore::DisplayList::isDrawingItem):
(WebCore::DisplayList::isInlineItem):
* platform/graphics/displaylists/DisplayListItemType.h:
* platform/graphics/displaylists/DisplayListItems.cpp:
(WebCore::DisplayList::operator<<):
(WebCore::DisplayList::ClipToDrawingCommands::apply const): Deleted.
* platform/graphics/displaylists/DisplayListItems.h:
(WebCore::DisplayList::BeginClipToDrawingCommands::BeginClipToDrawingCommands):
(WebCore::DisplayList::BeginClipToDrawingCommands::colorSpace const):
(WebCore::DisplayList::EndClipToDrawingCommands::EndClipToDrawingCommands):
(WebCore::DisplayList::EndClipToDrawingCommands::destination const):
(WebCore::DisplayList::ClipToDrawingCommands::ClipToDrawingCommands): Deleted.
(WebCore::DisplayList::ClipToDrawingCommands::operator=): Deleted.
(WebCore::DisplayList::ClipToDrawingCommands::destination const): Deleted.
(WebCore::DisplayList::ClipToDrawingCommands::colorSpace const): Deleted.
(WebCore::DisplayList::ClipToDrawingCommands::drawingCommands const): Deleted.
(WebCore::DisplayList::ClipToDrawingCommands::encode const): Deleted.
(WebCore::DisplayList::ClipToDrawingCommands::decode): Deleted.
* platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::Recorder::clipToDrawingCommands):
* platform/graphics/displaylists/DisplayListReplayer.cpp:
(WebCore::DisplayList::Replayer::context const):
(WebCore::DisplayList::Replayer::applyItem):
* platform/graphics/displaylists/DisplayListReplayer.h:
Source/WebKit:
Replace the DisplayList item ClipToDrawingCommands by the pair items
BeginClipToDrawingCommands and EndClipToDrawingCommands.
* GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::decodeItem):
* WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
LayoutTests:
The text with gradient tests will be fixed by this change.
* gpu-process/TestExpectations:
Canonical link: https://commits.webkit.org/234453@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273291 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=219641
<rdar://problem/72340651>
Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-02-20
Reviewed by Geoff Garen.
Source/WebKit:
Implement a concept of a message buffer. This is a similar concept as
"command buffer" or "display list" in some graphics APIs. Messages
can be added to the buffer by a client and then played back by a
server.
Current implementation adds a specific pseudo-infinite,
semi-duplex message buffer type IPC::StreamConnectionBuffer. This
is a buffer that can be attached to stream connection, an object
that can deliver IPC messages either through the message buffer
or through normal IPC::Connection. The stream connection is
implemented as IPC::StreamClientConnection and IPC::StreamServerConnection.
The connection has server and client distinction, similar to
IPC::Connection. Unlike IPC::Connection, a stream connection is asymmetric
in features: the client can send messages and receive replies, where
as the server can receive messages and send replies.
Messages received through IPC::StreamServerConnection can be
processed by StreamConnectionWorkQueue.
Currently asynchronous messages are added to the stream. Synchronous messages
and their replies are dispatched through normal IPC.
WebGL is implemented by having one StreamConnectionWorkQueue for all WebGL
in the browser. Currently each web process WebGL context in has one
StreamClientConnection attached to one 2mb StreamConnectionBuffer.
Later on, there will be only one WebGL stream connection and connection
buffer shared between all contexts in particular thread in Web process.
The implementation is "optimized" for the later on case. Due to single-
process nature of each page, it does not make much sense to have buffer
per context. However, it is anticipated that many of the successive calls
are to same context. The SHM message format implements an optimization
where the destination id is maintained as part of the stream connection
state.
In GPU process side, all WebGL is processed in one task queue,
"RemoteGraphicsContextGL task queue". It will process up to 1000 commands
per connection per iteration.
Implemented as follows:
Sender shares the shared memory area with the destination when creating
the destination.
If the message fits to the stream shared memory area, write it there.
Otherwise send it via normal IPC as out of line message.
Messages to the destination arrive as before, in order. For each out of line
message, an entry is pushed to the stream. Receiver will stop processing the
stream and processing will continue once the out-of-line
message has been processed.
Sender can write messages to the stream simultaneous to the receiver reading
the messages. This is implemented as a ring buffer with atomic sender and receiver
pointers.
Stream connection processing is implemented as a shared semaphore. This semaphore
is notified if the receiver is waiting on it.
Performance impact (iMac Pro):
- MotionMark triangles: 300 points -> 4000 points
(~7000 points no-GPUP)
- WebGL samples Aquarium: 1000 fish ~60fps -> 5000 fish ~60fps
(~5000 fish with no-GPUP)
No new tests, tested by existing tests.
* GPUProcess/GPUConnectionToWebProcess.cpp:
(WebKit::GPUConnectionToWebProcess::createGraphicsContextGL):
* GPUProcess/GPUConnectionToWebProcess.h:
* GPUProcess/GPUConnectionToWebProcess.messages.in:
* GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
(WebKit::remoteGraphicsContextGLStreamWorkQueue):
(WebKit::RemoteGraphicsContextGL::create):
(WebKit::RemoteGraphicsContextGL::RemoteGraphicsContextGL):
(WebKit::RemoteGraphicsContextGL::~RemoteGraphicsContextGL):
(WebKit::RemoteGraphicsContextGL::initialize):
(WebKit::RemoteGraphicsContextGL::connectWebProcessConnection):
(WebKit::RemoteGraphicsContextGL::disconnectWebProcessConnection):
(WebKit::RemoteGraphicsContextGL::workQueueInitialize):
(WebKit::RemoteGraphicsContextGL::workQueueUninitialize):
Initialize the OpenGL context in the work queue, since OpenGL
has various limitations wrt thread mobility.
(WebKit::RemoteGraphicsContextGL::forceContextLost):
(WebKit::RemoteGraphicsContextGL::dispatchContextChangedNotification):
* GPUProcess/graphics/RemoteGraphicsContextGL.h:
(WebKit::RemoteGraphicsContextGL::platformWorkQueueInitialize):
(WebKit::RemoteGraphicsContextGL::send const):
* GPUProcess/graphics/RemoteGraphicsContextGL.messages.in:
* GPUProcess/graphics/RemoteGraphicsContextGLCocoa.cpp:
(WebKit::RemoteGraphicsContextGL::create):
(WebKit::RemoteGraphicsContextGLCocoa::RemoteGraphicsContextGLCocoa):
(WebKit::RemoteGraphicsContextGLCocoa::platformWorkQueueInitialize):
* NetworkProcess/webrtc/NetworkRTCProvider.h:
* Platform/IPC/ArgumentCoder.h:
* Platform/IPC/ArgumentCoders.cpp:
* Platform/IPC/ArgumentCoders.h:
Make it possible to use multiple different Encoder classes to encode
the IPC data.
* Platform/IPC/Connection.cpp:
(IPC::Connection::processIncomingMessage):
(IPC::Connection::dispatchDidReceiveInvalidMessage):
* Platform/IPC/Connection.h:
Add possibility for the stream decoding logic to send the didReceiveInvalidMessage
notification to the connection client.
* Platform/IPC/Decoder.cpp:
(IPC::Decoder::Decoder):
(IPC::m_bufferDeallocator):
(IPC::m_destinationID):
* Platform/IPC/Decoder.h:
Add a constructor for Decoder for constructing a decoder in place in
the stream buffer.
* Platform/IPC/HandleMessage.h:
(IPC::handleMessageSynchronous):
Adds a stream-specific handleMessageSynchronous.
The old ones are unneccessarily complex, as they need redundant calls through redundant
generated send functions.
The old ones need the reply encoder passed in, which is redundant and problematic
for the upcoming case where the stream messaging will mainly reply through the stream itself,
constructing the IPC::StreamConnectionEncoder instead of normal IPC::Encoder.
* Platform/IPC/StreamClientConnection.cpp: Copied from Source/WebKit/Platform/IPC/cocoa/MachPort.h.
(IPC::StreamClientConnection::StreamClientConnection):
(IPC::StreamClientConnection::setWakeUpSemaphore):
Add function to set the connection receive side wakeup semaphore.
Currently the semaphore is the semaphore that StreamConnectionWorkQueue
waits on. All streams processed by the same work queue will receive the same
semaphore and will notify it when they have written new data.
(IPC::StreamClientConnection::wakeUpReceiver):
* Platform/IPC/StreamClientConnection.h: Added.
(IPC::StreamClientConnection::send):
(IPC::StreamClientConnection::sendSync):
(IPC::StreamClientConnection::trySendDestinationIDIfNeeded):
(IPC::StreamClientConnection::sendProcessOutOfStreamMessage):
(IPC::StreamClientConnection::tryAcquire):
(IPC::StreamClientConnection::release):
(IPC::StreamClientConnection::alignedSpan):
(IPC::StreamClientConnection::size):
(IPC::StreamClientConnection::clampedLimit const):
Add the implementation for sending data through the shared memory.
* Platform/IPC/StreamConnectionBuffer.cpp: Added.
(IPC::createMemory):
(IPC::StreamConnectionBuffer::StreamConnectionBuffer):
(IPC::StreamConnectionBuffer::operator=):
(IPC::StreamConnectionBuffer::encode const):
(IPC::StreamConnectionBuffer::decode):
* Platform/IPC/StreamConnectionBuffer.h: Added.
(IPC::StreamConnectionBuffer::wrapOffset const):
(IPC::StreamConnectionBuffer::alignOffset const):
(IPC::StreamConnectionBuffer::senderOffset):
(IPC::StreamConnectionBuffer::receiverOffset):
(IPC::StreamConnectionBuffer::data const):
(IPC::StreamConnectionBuffer::dataSize const):
(IPC::StreamConnectionBuffer::senderWaitSemaphore):
(IPC::StreamConnectionBuffer::header const):
(IPC::StreamConnectionBuffer::headerSize):
Add the common implementation for the shared memory ring buffer.
This is the common implementation used by both the sender side
as well as the receiver side.
Due to the selection of how the size is marked up, the
common implementation does not contain all the non-trivial code.
The "algorithm" uses a "hole indicator" to differentiate between
cases of "buffer is empty" and "buffer is full". The other
alternative could be better and maybe explored later.
* Platform/IPC/StreamConnectionEncoder.h: Added.
* Platform/IPC/StreamConnectionWorkQueue.cpp: Added.
(IPC::StreamConnectionWorkQueue::StreamConnectionWorkQueue):
(IPC::StreamConnectionWorkQueue::dispatch):
(IPC::StreamConnectionWorkQueue::addStreamConnection):
(IPC::StreamConnectionWorkQueue::removeStreamConnection):
(IPC::StreamConnectionWorkQueue::stop):
(IPC::StreamConnectionWorkQueue::wakeUp):
(IPC::StreamConnectionWorkQueue::wakeUpSemaphore):
(IPC::StreamConnectionWorkQueue::wakeUpProcessingThread):
(IPC::StreamConnectionWorkQueue::processStreams):
Work queue contains multiple StreamServerConnection instances.
For each iteration of the work queue thread, it will process
1000 items from each connection. If none of the connections contain
work, the queue will sleep on the work queue semaphore.
The senders will send through StreamClientConnection which
will wake up the work queue by signaling the semaphore.
* Platform/IPC/StreamConnectionWorkQueue.h: Copied from Source/WebKit/Platform/IPC/cocoa/MachPort.h.
* Platform/IPC/StreamServerConnection.cpp: Added.
(IPC::StreamServerConnectionBase::StreamServerConnectionBase):
(IPC::StreamServerConnectionBase::startReceivingMessagesImpl):
(IPC::StreamServerConnectionBase::stopReceivingMessagesImpl):
(IPC::StreamServerConnectionBase::enqueueMessage):
(IPC::StreamServerConnectionBase::tryAquire):
(IPC::StreamServerConnectionBase::release):
(IPC::StreamServerConnectionBase::alignedSpan):
(IPC::StreamServerConnectionBase::size):
(IPC::StreamServerConnectionBase::clampedLimit const):
* Platform/IPC/StreamServerConnection.h: Added.
(IPC::StreamServerConnectionBase::connection):
(IPC::StreamServerConnectionBase::wrapOffset const):
(IPC::StreamServerConnectionBase::alignOffset const):
(IPC::StreamServerConnectionBase::sharedSenderOffset):
(IPC::StreamServerConnectionBase::sharedReceiverOffset):
(IPC::StreamServerConnectionBase::data const):
(IPC::StreamServerConnectionBase::dataSize const):
(IPC::StreamServerConnectionBase::sendSyncReply):
(IPC::StreamServerConnection<Receiver>::startReceivingMessages):
(IPC::StreamServerConnection<Receiver>::stopReceivingMessages):
(IPC::StreamServerConnection<Receiver>::dispatchStreamMessages):
(IPC::StreamServerConnection<Receiver>::processSetStreamDestinationID):
(IPC::StreamServerConnection<Receiver>::dispatchStreamMessage):
(IPC::StreamServerConnection<Receiver>::dispatchOutOfStreamMessage):
StreamServerConnection will process the message buffer and dispatch
messages based on the buffer contents. The class is a template so
that the message data decode switch (generated by the normal IPC
generator) is perhaps inlined to the message unpack loop.
* Platform/IPC/cocoa/MachPort.h:
* Scripts/webkit/messages.py:
* Scripts/webkit/messages_unittest.py:
Implements a 'Stream' attribute for the message receiver. When marked as
'Stream', the receiver message handler is didReceiveStreamMessage and it
will be called for all messages, stream or normal IPC, sync or async.
* Scripts/webkit/model.py:
Adds IPC control message ProcessOutOfStreamMessage that is acted on if
it is part of the stream messages. It means that the stream processing
should stop until one normal IPC message, sync or non-synch, should be
processed.
Adds IPC control message SetStreamDestinationID that is acted on if it
is part of the stream messages. It will set the destination ID for all
the subsequent stream messages, until another SetStreamDestinationID
message is seen.
* Scripts/webkit/tests/Makefile:
* Scripts/webkit/tests/MessageNames.cpp:
(IPC::description):
(IPC::receiverName):
(IPC::isValidMessageName):
* Scripts/webkit/tests/MessageNames.h:
* Scripts/webkit/tests/TestWithStream.messages.in: Copied from Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.messages.in.
* Scripts/webkit/tests/TestWithStreamBuffer.messages.in: Copied from Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.messages.in.
* Scripts/webkit/tests/TestWithStreamBufferMessageReceiver.cpp: Added.
(WebKit::TestWithStreamBuffer::didReceiveMessage):
* Scripts/webkit/tests/TestWithStreamBufferMessages.h: Added.
(Messages::TestWithStreamBuffer::messageReceiverName):
(Messages::TestWithStreamBuffer::SendStreamBuffer::name):
(Messages::TestWithStreamBuffer::SendStreamBuffer::SendStreamBuffer):
(Messages::TestWithStreamBuffer::SendStreamBuffer::arguments const):
* Scripts/webkit/tests/TestWithStreamBufferMessagesReplies.h: Added.
* Scripts/webkit/tests/TestWithStreamMessageReceiver.cpp: Added.
(WebKit::TestWithStream::didReceiveStreamMessage):
* Scripts/webkit/tests/TestWithStreamMessages.h: Added.
(Messages::TestWithStream::messageReceiverName):
(Messages::TestWithStream::SendString::name):
(Messages::TestWithStream::SendString::SendString):
(Messages::TestWithStream::SendString::arguments const):
(Messages::TestWithStream::SendStringSynchronized::name):
(Messages::TestWithStream::SendStringSynchronized::SendStringSynchronized):
(Messages::TestWithStream::SendStringSynchronized::arguments const):
* Scripts/webkit/tests/TestWithStreamMessagesReplies.h: Added.
* Sources.txt:
* UIProcess/Downloads/DownloadProxy.h:
* UIProcess/ProvisionalPageProxy.cpp:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp:
(WebKit::RemoteGraphicsContextGLProxy::RemoteGraphicsContextGLProxy):
(WebKit::RemoteGraphicsContextGLProxy::wasCreated):
Send the work queue wakeup semaphore as a result of the context creation.
* Platform/IPC/ScopedActiveMessageReceiveQueue.h: Added.
(IPC::ScopedActiveMessageReceiveQueue::ScopedActiveMessageReceiveQueue):
(IPC::ScopedActiveMessageReceiveQueue::operator=):
(IPC::ScopedActiveMessageReceiveQueue::~ScopedActiveMessageReceiveQueue):
(IPC::ScopedActiveMessageReceiveQueue::reset):
(IPC::ScopedActiveMessageReceiveQueue::get const):
(IPC::ScopedActiveMessageReceiveQueue::stopListeningForIPCAndRelease):
Add a holder to replace previous RemoteRenderingBackendWrapper.
Now other classes can be held similarly.
* WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h:
* WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.messages.in:
* WebProcess/Network/webrtc/LibWebRTCNetwork.h:
Tools:
Mark RemoteGraphicsContextGL message receiver as "Stream",
a new variant of receiver.
* Scripts/generate-gpup-webgl:
LayoutTests:
Mark few tests as not timing out now that the implementation is not so slow.
* gpu-process/TestExpectations:
Canonical link: https://commits.webkit.org/234390@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273204 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=221811
Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-02-18
Reviewed by Darin Adler.
Source/WebCore:
Implements rudimentary support for reading the WebGL context and transfering
it to a ImageBuffer.
Fixes many tests that are removed from gpu-process/TestExpectations.
* html/OffscreenCanvas.cpp:
(WebCore::OffscreenCanvas::transferToImageBitmap):
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::paintRenderingResultsToCanvas):
* platform/graphics/GraphicsContextGL.h:
Make paintRenderingResultsToCanvas and paintCompositedResultsToCanvas
take ImageBuffer& instead of ImageBuffer*, since the buffer always
exists.
* platform/graphics/cairo/GraphicsContextGLCairo.cpp:
(WebCore::GraphicsContextGLOpenGL::paintToCanvas):
* platform/graphics/cg/GraphicsContextGLCG.cpp:
(WebCore::GraphicsContextGLOpenGL::paintToCanvas):
Change the function signature so that it can be called from
other thread and without GraphicsContextGL instance.
It is not really a GraphicsContextGLOpenGL related function..
* platform/graphics/cocoa/GraphicsContextGLIOSurfaceSwapChain.cpp:
(WebCore::GraphicsContextGLIOSurfaceSwapChain::displayBuffer const):
(WebCore::GraphicsContextGLIOSurfaceSwapChain::recycleBuffer):
(WebCore::GraphicsContextGLIOSurfaceSwapChain::detachClient):
(WebCore::GraphicsContextGLIOSurfaceSwapChain::present):
* platform/graphics/cocoa/GraphicsContextGLIOSurfaceSwapChain.h:
* platform/graphics/cocoa/WebGLLayer.mm:
(WebGLLayerSwapChain::present):
Move the triple buffering implementation to the base class.
The implementation is now also used in GPU process side,
since the GPU process needs to be able to read the composited
results.
Previously the same logic was split between Web process and GPU process.
* platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:
(WebCore::GraphicsContextGLOpenGL::paintRenderingResultsToCanvas):
(WebCore::GraphicsContextGLOpenGL::paintCompositedResultsToCanvas):
(WebCore::GraphicsContextGLOpenGL::paintRenderingResultsToImageData):
(WebCore::GraphicsContextGLOpenGL::readRenderingResultsForPainting):
(WebCore::GraphicsContextGLOpenGL::readCompositedResultsForPainting):
* platform/graphics/opengl/GraphicsContextGLOpenGL.h:
Expose public functions to get ImageData out of drawing buffer and
display buffer.
Source/WebKit:
Implements rudimentary support for reading the WebGL context and transfering
it to a ImageBuffer.
Fixes many tests that are removed from gpu-process/TestExpectations.
* GPUProcess/GPUConnectionToWebProcess.cpp:
(WebKit::GPUConnectionToWebProcess::createGraphicsContextGL):
* GPUProcess/GPUConnectionToWebProcess.h:
(WebKit::GPUConnectionToWebProcess::RemoteRenderingBackendWrapper::get const):
* GPUProcess/GPUConnectionToWebProcess.messages.in:
* GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
(WebKit::RemoteGraphicsContextGL::create):
(WebKit::RemoteGraphicsContextGL::RemoteGraphicsContextGL):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::createGraphicsContextGL const):
* GPUProcess/graphics/RemoteGraphicsContextGLCocoa.cpp:
(WebKit::RemoteGraphicsContextGL::create):
(WebKit::RemoteGraphicsContextGLCocoa::RemoteGraphicsContextGLCocoa):
* WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h:
(WebKit::RemoteRenderingBackendProxy::renderingBackendIdentifier const):
RemoteGraphicsContextGL takes a ref of the respective RemoteRenderingBackend.
RemoteRenderingBackend is the one that can handle ImageBuffers.
(WebKit::RemoteGraphicsContextGL::paintRenderingResultsToCanvas):
(WebKit::RemoteGraphicsContextGL::paintCompositedResultsToCanvas):
(WebKit::RemoteGraphicsContextGL::paintImageDataToImageBuffer):
* GPUProcess/graphics/RemoteGraphicsContextGL.h:
* GPUProcess/graphics/RemoteGraphicsContextGL.messages.in:
Implement the functions by:
1) Wait for the pending changes to the ImageBuffer
2) Send a synchronous message from Web process to GPU process WebGL sequence
3) Reading the buffer, post the task to RenderingBackend sequence
4) Paint the results to the ImageBuffer
5) Return the synchronous message result
(WebKit::RemoteGraphicsContextGLCocoa::prepareForDisplay):
RemoteGraphicsContextGL now retains the reference to display buffer.
Before, just sent the display buffer to Web process and forgot
about it.
* GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::dispatch):
* GPUProcess/graphics/RemoteRenderingBackend.h:
Add function to dispatch work to rendering backend sequence.
* WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp:
(WebKit::RemoteGraphicsContextGLProxy::create):
(WebKit::RemoteGraphicsContextGLProxy::RemoteGraphicsContextGLProxy):
(WebKit::RemoteGraphicsContextGLProxy::paintRenderingResultsToCanvas):
(WebKit::RemoteGraphicsContextGLProxy::paintCompositedResultsToCanvas):
* WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h:
Send the messages.
* WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
(WebKit::RemoteRenderingBackendProxy::connectToGPUProcess):
Use IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply to
send CreateRenderingBackend. It must be dispatched in order compared to other
messages such as CreateRemoteGraphicsContextGL.
Tools:
Update two signatures for manually implemented messages.
* Scripts/generate-gpup-webgl:
LayoutTests:
Remove now passing tests from the expectations.
* gpu-process/TestExpectations:
Canonical link: https://commits.webkit.org/234278@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273080 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Make Pattern hold a NativeImage instead of an Image
https://bugs.webkit.org/show_bug.cgi?id=221637
Reviewed by Simon Fraser.
This will make caching the Pattern data in the GPUP straightforward since
all we need is to cache the NativeImage and encode the pattern data.
* html/canvas/CanvasPattern.cpp:
(WebCore::CanvasPattern::create):
(WebCore::CanvasPattern::CanvasPattern):
* html/canvas/CanvasPattern.h:
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::createPattern):
* inspector/InspectorCanvas.cpp:
(WebCore::InspectorCanvas::buildArrayForCanvasPattern):
Extract a NativeImage of an Image. The platform Patterns deal with
NativeImages only.
* platform/graphics/Image.h:
Remove ImageHandle.
* platform/graphics/Pattern.cpp:
(WebCore::Pattern::create):
(WebCore::Pattern::Pattern):
(WebCore::Pattern::setPatternSpaceTransform):
* platform/graphics/Pattern.h:
(WebCore::Pattern::Parameters::encode const):
(WebCore::Pattern::Parameters::decode):
(WebCore::Pattern::encode const): Deleted.
(WebCore::Pattern::decode): Deleted.
Make the new struct 'Parameters' holds all the members other than the
NativeImage. This struct + RenderingResourceIdentifer of the NativeImage
will be recorded for the strokePattern and the fillPattern.
* platform/graphics/cairo/CairoOperations.cpp:
(WebCore::Cairo::FillSource::FillSource):
* platform/graphics/cairo/PatternCairo.cpp:
(WebCore::Pattern::createPlatformPattern const):
* platform/graphics/cg/PatternCG.cpp:
(WebCore::Pattern::createPlatformPattern const):
The platform Pattern deals only with NativeImages.
* platform/graphics/displaylists/DisplayList.cpp:
(WebCore::DisplayList::DisplayList::shouldDumpForFlags):
SetState::state() is renamed to SetStateItem::stateChange() since it
returns GraphicsContextStateChange.
* platform/graphics/displaylists/DisplayListItemBuffer.cpp:
(WebCore::DisplayList::ItemHandle::apply):
SetState::apply() has to be a special case.
* platform/graphics/displaylists/DisplayListItems.cpp:
(WebCore::DisplayList::SetState::SetState):
(WebCore::DisplayList::SetState::apply):
(WebCore::DisplayList::operator<<):
(WebCore::DisplayList::SetState::apply const): Deleted.
Add a new constructor for SetState to be used by the decoder. All the
members of GraphicsContextStateChange will be copied but strokePattern
and fillPattern will be created only when their NativeImages are resolved
in the SetState::apply().
* platform/graphics/displaylists/DisplayListItems.h:
(WebCore::DisplayList::SetState::stateChange const):
(WebCore::DisplayList::SetState::strokePatternParameters const):
(WebCore::DisplayList::SetState::fillPatternParameters const):
(WebCore::DisplayList::SetState::strokePatternImageIdentifier const):
(WebCore::DisplayList::SetState::fillPatternImageIdentifier const):
(WebCore::DisplayList::SetState::encode const):
(WebCore::DisplayList::SetState::decode):
(WebCore::DisplayList::SetState::state const): Deleted.
Specialize the encode and the decoding of strokePattern and fillPattern
by using the Pattern::Parameters and the RenderingResourceIdentifer of
the NativeImage.
* platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::Recorder::cacheNativeImage):
(WebCore::DisplayList::Recorder::appendStateChangeItem):
(WebCore::DisplayList::Recorder::drawNativeImage):
(WebCore::DisplayList::Recorder::drawPattern):
* platform/graphics/displaylists/DisplayListRecorder.h:
Cache the NativeImages of strokePattern and fillPattern.
* platform/graphics/displaylists/DisplayListReplayer.cpp:
(WebCore::DisplayList::applySetStateItem):
(WebCore::DisplayList::Replayer::applyItem):
Resolve the NativeImages of strokePattern and fillPattern from the cached
NativeImages.
* platform/graphics/filters/FETile.cpp:
(WebCore::FETile::platformApplySoftware):
* rendering/RenderLayerBacking.cpp:
(WebCore::patternForDescription):
* rendering/svg/RenderSVGResourcePattern.cpp:
(WebCore::RenderSVGResourcePattern::buildPattern):
Patterns should be created with NativeImages.
Source/WebKit:
Make Pattern hold a NativeImage instead of an Image
https://bugs.webkit.org/show_bug.cgi?id=221637
Reviewed by Simon Fraser.
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<ImageHandle>::encode): Deleted.
(IPC::ArgumentCoder<ImageHandle>::decode): Deleted.
* Shared/WebCoreArgumentCoders.h:
Delete the encoding and decoding of Image since it is not used anymore
LayoutTests:
[GPU Process] Implement SetState DisplayList item
https://bugs.webkit.org/show_bug.cgi?id=219468
Reviewed by Simon Fraser.
* gpu-process/TestExpectations:
Unmark tests that are no longer crash.
Canonical link: https://commits.webkit.org/234012@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272776 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=221695
Reviewed by Eric Carlson.
Source/WebCore:
No new tests, covered by unskipped layout tests.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerEngineUpdated):
(WebCore::HTMLMediaElement::mediaPlayerDidInitializeMediaEngine):
We were calling HTMLMediaElement::audioSourceProvider() in mediaPlayerEngineUpdated() which
happens right after we've constructed the MediaPlayerPrivate but before we've called
load() on the MediaPlayerPrivate. The issue was that calling audioSourceProvider() would
initialize the AudioSourceProvider and end up sending the RemoteMediaPlayerProxy::CreateAudioSourceProvider
IPC to the GPUProcess. RemoteMediaPlayerProxy::createAudioSourceProvider() would return early
because m_player->audioSourceProvider() returns null. The reason m_player->audioSourceProvider()
returns null is because it's MediaPlayerPrivate is still a NullMediaPlayerPrivate, because
MediaPlayer::load() has not been called in the GPUProcess yet. For this reason, I moved the
audioSourceProvider() initialization from mediaPlayerEngineUpdated() to
mediaPlayerDidInitializeMediaEngine(). mediaPlayerDidInitializeMediaEngine() happens right
after we've called MediaPlayerPrivate::load() which will end up calling MediaPlayer::load()
in the GPUProcess.
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::loadWithNextMediaEngine):
Pass an empty ContentType to MediaPlayerPrivate::load() when we did not have a content type
but guessed one based on the extension. This ends up getting passed to the MediaPlayer
in the GPUProcess and it is important it knows it does not have a content type so that
it can guess one from the extension and try the next media engine if it cannot find one.
LayoutTests:
Unskip tests that are no longer timing out.
* gpu-process/TestExpectations:
Canonical link: https://commits.webkit.org/233990@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272750 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=221396
Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-02-10
Reviewed by Simon Fraser.
Source/WebKit:
Implement support for RemoteGraphicsContextGLProxy acting on
losing the context in RemoteGraphicsContextGL.
Implement support for RemoteGraphicsContextGLProxy timing out on message
sends. Force the context to be lost.
Implement support for GPUProcessConnection disconnect. Force the context
be lost.
* GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
Send a bool via WasCreated method, so that the
receiver knows if creation was successful or not.
Currently the creation always succeeds.
Previously it was designed to use wasLost instead,
but this has the problem that the client will wait
for WasCreated in particular cases to ensure initialization,
and thus we cannot wait for "WasCreated OR WasLost".
(WebKit::RemoteGraphicsContextGL::RemoteGraphicsContextGL):
(WebKit::RemoteGraphicsContextGL::synthesizeGLError):
(WebKit::RemoteGraphicsContextGL::getError):
Manually implement few methods that contain custom client-side
logic wrt. lost context.
* GPUProcess/graphics/RemoteGraphicsContextGL.h:
* GPUProcess/graphics/RemoteGraphicsContextGL.messages.in:
* GPUProcess/graphics/RemoteGraphicsContextGLFunctionsGenerated.h:
(setFailNextGPUStatusCheck):
(getBooleanv):
* WebProcess/GPU/GPUProcessConnection.cpp:
(WebKit::GPUProcessConnection::dispatchMessage):
Skip the RemoteGraphicsContextGLProxy messages that do not have
a receiver. This is expected, as we cannot assume that only expected
messages arrive to the message hander.
The client, i.e. the web process, might
- just delete the proxy
- force the context to be lost
- notice a timeout and force the context to be lost
while the GPU process cannot know this. RemoteGraphicsContextGL might
already have sent messages to the Proxy.
* WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp:
(WebKit::RemoteGraphicsContextGLProxy::create):
(WebKit::RemoteGraphicsContextGLProxy::RemoteGraphicsContextGLProxy):
(WebKit::RemoteGraphicsContextGLProxy::~RemoteGraphicsContextGLProxy):
Listen to GPUProcessConnection::Client notifications about
connection closure. When the connection closes, mark the context object
lost.
Store the reference to GPUProcessConnection so that when the connection
is shut down and new one is instantiated, RemoteGraphicsContextGLProxy
destruction logic will correctly refer to the one it was using.
(WebKit::RemoteGraphicsContextGLProxy::reshape):
(WebKit::RemoteGraphicsContextGLProxy::prepareForDisplay):
(WebKit::RemoteGraphicsContextGLProxy::ensureExtensionEnabled):
(WebKit::RemoteGraphicsContextGLProxy::notifyMarkContextChanged):
(WebKit::RemoteGraphicsContextGLProxy::synthesizeGLError):
(WebKit::RemoteGraphicsContextGLProxy::getError):
(WebKit::RemoteGraphicsContextGLProxy::wasCreated):
(WebKit::RemoteGraphicsContextGLProxy::wasLost):
When the context lost event happens, disconnect with
the GPUProcessConnection.
(WebKit::RemoteGraphicsContextGLProxy::wasChanged):
(WebKit::RemoteGraphicsContextGLProxy::markContextLost):
(WebKit::RemoteGraphicsContextGLProxy::waitUntilInitialized):
(WebKit::RemoteGraphicsContextGLProxy::gpuProcessConnectionDidClose):
When the connection closes, mark the context object
lost.
(WebKit::RemoteGraphicsContextGLProxy::disconnect):
* WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h:
* WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.messages.in:
* WebProcess/GPU/graphics/RemoteGraphicsContextGLProxyFunctionsGenerated.cpp:
Changes generated by the code-generator wrt handling timeouts from the sends.
Tools:
Generate calls to lose the context on timeouts.
Generate the send calls as calls to the helper functions to send the
messages. The helper functions will provide the non-changing arguments.
Move few messages to be implemented by hand.
* Scripts/generate-gpup-webgl:
LayoutTests:
Fix the lose-context-on-status-failure.html. The test was using
an internal function to lose the context and then synchronously
checking that the context was lost. With GPU process this is not
possible, so check after normal Canvas webglcontextlost event.
Enable the test for --use-gpu-process.
* fast/canvas/webgl/lose-context-on-status-failure.html:
* gpu-process/TestExpectations:
Canonical link: https://commits.webkit.org/233904@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272645 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=220964
Reviewed by Jer Noble.
Source/WebCore:
This patch removes `initializationSegmentIsHandledSemaphore` from both `SourceBufferParserAVFObjC`
and `SourceBufferParserWebM`, and implements a media sample cache mechanism in `SourceBufferPrivateAVFObjC`
to ensure that "Coded Frame Processing" steps execute after `SourceBufferPrivate` has handled the
initialization segment and enabled video/audio tracks. Without the cache mechanism, some media
samples following the initialization segment may be dropped when we run `SourceBufferPrivateAVFObjC`
in the GPU process, and the media element won't fire "canplaythrough" event because it cannot change
its ready state to a value greater than HAVE_METADATA.
This patch also implements the mechanism to make sure `SourceBufferPrivateAVFObjC::appendCompleted()`
runs after all media samples have gone through the "Coded Frame Processing" steps, so that the source
buffer object will fire "update" and "updateend" event after the parser has completedly parsed the
appended buffer.
* platform/graphics/avfoundation/objc/SourceBufferParserAVFObjC.h:
* platform/graphics/avfoundation/objc/SourceBufferParserAVFObjC.mm:
(WebCore::SourceBufferParserAVFObjC::SourceBufferParserAVFObjC):
(WebCore::SourceBufferParserAVFObjC::~SourceBufferParserAVFObjC):
(WebCore::SourceBufferParserAVFObjC::appendData):
Add a parameter "CompletionHandler" to notify the caller that the parser has parsed the whole buffer.
(WebCore::SourceBufferParserAVFObjC::flushPendingMediaData):
(WebCore::SourceBufferParserAVFObjC::resetParserState):
(WebCore::SourceBufferParserAVFObjC::invalidate):
(WebCore::SourceBufferParserAVFObjC::didParseStreamDataAsAsset):
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC):
(WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC):
(WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData):
After `SourceBufferPrivateClient` has done the configuration with the initialization segment, we need to
push the cached media samples (if any) to `SourceBufferPrivate` to run the "Coded Frame Processing" steps.
And we need to call "appendCompleted()" if there is a pending callback.
(WebCore::SourceBufferPrivateAVFObjC::didProvideMediaDataForTrackId):
`SourceBufferPrivateAVFObjC` needs to cache the media sample if the initialization segment has not been
processed by `SourceBufferPrivateClient` yet.
(WebCore::SourceBufferPrivateAVFObjC::append):
We need to postpone the "appendCompleted()" callback if there are cached media samples.
(WebCore::SourceBufferPrivateAVFObjC::appendCompleted):
(WebCore::SourceBufferPrivateAVFObjC::abort):
(WebCore::SourceBufferPrivateAVFObjC::setVideoLayer):
(WebCore::SourceBufferPrivateAVFObjC::didProvideMediaDataForTrackID): Deleted.
* platform/graphics/cocoa/SourceBufferParser.h:
* platform/graphics/cocoa/SourceBufferParserWebM.cpp:
(WebCore::SourceBufferParserWebM::SourceBufferParserWebM):
(WebCore::SourceBufferParserWebM::~SourceBufferParserWebM):
(WebCore::SourceBufferParserWebM::appendData):
(WebCore::SourceBufferParserWebM::flushPendingMediaData):
(WebCore::SourceBufferParserWebM::resetParserState):
(WebCore::SourceBufferParserWebM::invalidate):
(WebCore::SourceBufferParserWebM::OnClusterBegin):
* platform/graphics/cocoa/SourceBufferParserWebM.h:
Source/WebKit:
* Shared/mac/MediaFormatReader/MediaFormatReader.cpp:
(WebKit::MediaFormatReader::parseByteSource):
LayoutTests:
* gpu-process/TestExpectations:
* media/media-source/media-source-webm-append-buffer-after-abort-expected.txt: Added.
* media/media-source/media-source-webm-append-buffer-after-abort.html: Added.
* platform/mac/TestExpectations:
Canonical link: https://commits.webkit.org/233458@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272039 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=220411
Reviewed by Wenson Hsieh.
Source/WebCore:
MediaStreamTrack video player is running in WebProcess as WebProcess gets each video sample.
There is no corresponding remote media player.
Disable the GPU code path for painting the video element and use the in-process one instead.
Covered by test in GPU process mode.
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::paintFrameForMedia):
* platform/graphics/GraphicsContextImpl.h:
* platform/graphics/cairo/GraphicsContextImplCairo.h:
* platform/graphics/displaylists/DisplayListRecorder.cpp:
(WebCore::DisplayList::Recorder::canPaintFrameForMedia const):
(WebCore::DisplayList::Recorder::paintFrameForMedia):
* platform/graphics/displaylists/DisplayListRecorder.h:
* platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h:
* platform/graphics/win/GraphicsContextImplDirect2D.h:
LayoutTests:
* gpu-process/TestExpectations:
Canonical link: https://commits.webkit.org/232874@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271295 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=220334
Reviewed by Eric Carlson.
Source/WebCore:
Add a completion handler parameter to SourceBufferPrivate::removeCodedFrames(),
and the caller (SourceBuffer) will fire `update` and `updateend` events when
the completion handler is called.
No new tests. Fix failures of the following tests:
- imported/w3c/web-platform-tests/media-source/mediasource-config-change-webm-v-framesize.html
- imported/w3c/web-platform-tests/media-source/mediasource-config-change-mp4-av-audio-bitrate.html
- imported/w3c/web-platform-tests/media-source/mediasource-config-change-mp4-av-video-bitrate.html
* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::removeTimerFired):
* platform/graphics/SourceBufferPrivate.cpp:
(WebCore::SourceBufferPrivate::removeCodedFrames):
* platform/graphics/SourceBufferPrivate.h:
(WebCore::SourceBufferPrivate::removeCodedFrames):
Source/WebKit:
Update the IPC message RemoteSourceBufferProxy::RemoveCodedFrames to implement
SourceBufferPrivateRemote::removeCodedFrames().
* GPUProcess/media/RemoteSourceBufferProxy.cpp:
(WebKit::RemoteSourceBufferProxy::removeCodedFrames):
* GPUProcess/media/RemoteSourceBufferProxy.h:
* GPUProcess/media/RemoteSourceBufferProxy.messages.in:
* WebProcess/GPU/media/SourceBufferPrivateRemote.cpp:
(WebKit::SourceBufferPrivateRemote::removeCodedFrames):
* WebProcess/GPU/media/SourceBufferPrivateRemote.h:
LayoutTests:
* gpu-process/TestExpectations:
Canonical link: https://commits.webkit.org/232775@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271178 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=220119
Reviewed by Eric Carlson.
Source/WebKit:
Implement `RemoteMediaPlayerProxy::mediaPlayerSizeChanged()` to forward the video
resize callback from MSE media player to web process.
No new tests, covered by existing failing layout test.
* GPUProcess/media/RemoteMediaPlayerProxy.cpp:
(WebKit::RemoteMediaPlayerProxy::mediaPlayerSizeChanged):
* GPUProcess/media/RemoteMediaPlayerProxy.h:
LayoutTests:
* gpu-process/TestExpectations:
Canonical link: https://commits.webkit.org/232673@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271076 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=219998
Reviewed by Jer Noble.
Source/WebCore:
No new tests, fix layout test failures.
* platform/graphics/SourceBufferPrivate.h:
(WebCore::SourceBufferPrivate::setTimestampOffset):
(WebCore::SourceBufferPrivate::setAppendWindowStart):
(WebCore::SourceBufferPrivate::setAppendWindowEnd):
(WebCore::SourceBufferPrivate::hasVideo const):
(WebCore::SourceBufferPrivate::timestampOffset const):
Change these functions to virtual because `SourceBufferPrivateRemote` needs to override them.
Source/WebKit:
Implement some track buffer related functions of `SourceBufferPrivateRemote` with new IPC messages.
* GPUProcess/media/RemoteSourceBufferProxy.cpp:
(WebKit::RemoteSourceBufferProxy::resetTrackBuffers):
(WebKit::RemoteSourceBufferProxy::clearTrackBuffers):
(WebKit::RemoteSourceBufferProxy::resetTimestampOffsetInTrackBuffers):
(WebKit::RemoteSourceBufferProxy::setTimestampOffset):
(WebKit::RemoteSourceBufferProxy::setAppendWindowStart):
(WebKit::RemoteSourceBufferProxy::setAppendWindowEnd):
(WebKit::RemoteSourceBufferProxy::updateTrackIds):
* GPUProcess/media/RemoteSourceBufferProxy.h:
* GPUProcess/media/RemoteSourceBufferProxy.messages.in:
* WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
(WebKit::MediaPlayerPrivateRemote::addRemoteAudioTrack):
(WebKit::MediaPlayerPrivateRemote::addRemoteTextTrack):
(WebKit::MediaPlayerPrivateRemote::addRemoteVideoTrack):
`MediaSource` manages the track information for the MSE media player, so we should not call
`MediaPlayer::addAudioTrack()`, `MediaPlayer::addTextTrack()` and `MediaPlayer::addVideoTrack()`.
* WebProcess/GPU/media/SourceBufferPrivateRemote.cpp:
(WebKit::SourceBufferPrivateRemote::resetTrackBuffers):
(WebKit::SourceBufferPrivateRemote::clearTrackBuffers):
(WebKit::SourceBufferPrivateRemote::resetTimestampOffsetInTrackBuffers):
(WebKit::SourceBufferPrivateRemote::setTimestampOffset):
(WebKit::SourceBufferPrivateRemote::setAppendWindowStart):
(WebKit::SourceBufferPrivateRemote::setAppendWindowEnd):
(WebKit::SourceBufferPrivateRemote::updateTrackIds):
* WebProcess/GPU/media/SourceBufferPrivateRemote.h:
LayoutTests:
* gpu-process/TestExpectations:
Canonical link: https://commits.webkit.org/232598@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270987 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=218106
<rdar://problem/70226170>
Reviewed by Jer Noble.
Source/WebCore:
No new tests, enabled existing test in the GPU process.
* platform/SerializedPlatformDataCueValue.h:
(WebCore::SerializedPlatformDataCueValue::SerializedPlatformDataCueValue):
(WebCore::SerializedPlatformDataCueValue::nativeValue const):
Make m_nativeValue a RetainPtr<> so the ownership and lifetime of the object is
explicit and managed correctly.
* platform/mac/SerializedPlatformDataCueMac.mm:
(WebCore::SerializedPlatformDataCueMac::encodableValue const): Update for change
to native value.
(WebCore::jsValueWithAVMetadataItemInContext): Ditto.
(WebCore::NSDictionaryWithAVMetadataItem): Return a RetainPtr<NSDictionary> instead
of an auto-released dictionary.
Source/WebKit:
* Shared/mac/WebCoreArgumentCodersMac.mm:
(IPC::ArgumentCoder<WebCore::SerializedPlatformDataCueValue>::encodePlatformData):
SerializedPlatformDataCueValue::nativeValue() is a RetainPtr<>.
LayoutTests:
* gpu-process/TestExpectations: Mark test as passing.
Canonical link: https://commits.webkit.org/230845@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268939 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=217663
Reviewed by Geoff Garen.
Source/WebCore:
No new tests, unskipped existing tests.
* WebCore.xcodeproj/project.pbxproj:
* platform/audio/PushPullFIFO.h:
Export PushPullFIFO so that it can be used at WebKit layer.
Source/WebKit:
WebAudio tests were crashing in debug when enabling the GPU process because it did audio
processing on the WebContent process's main thread. To address the issue, I made
RemoteAudioDestinationProxy a ThreadMessageReceiver so that it receives IPC on an audio
thread instead of the main thread. IPC messages are processed directly on the AudioWorklet
thread when active or on an audio thread constructed by RemoteAudioDestinationProxy
otherwise.
* GPUProcess/media/RemoteAudioDestinationManager.cpp:
(WebKit::RemoteAudioDestination::RemoteAudioDestination):
Use a PushPullFIFO structure in render() to avoid hanging the audio rendering thread
on a semaphore. Hanging the rendering thread was terrible for performance and was also
a source of deadlock since the underlying framework is holding a lock while render() is
called. We could process a RemoteAudioDestination::CreateAudioDestination sync IPC on the
main thread and deadlock on that lock.
* GPUProcess/webrtc/LibWebRTCCodecsProxy.h:
* GPUProcess/webrtc/RemoteAudioMediaStreamTrackRendererManager.h:
* GPUProcess/webrtc/RemoteSampleBufferDisplayLayerManager.h:
* NetworkProcess/IndexedDB/WebIDBServer.h:
* NetworkProcess/webrtc/NetworkRTCProvider.h:
* WebProcess/Network/webrtc/LibWebRTCNetwork.h:
* WebProcess/cocoa/RemoteCaptureSampleManager.h:
Use ThreadMessageReceiverRefCounted instead of ThreadMessageReceiver since those classes
do not provide their own RefCounting.
* Platform/IPC/Connection.cpp:
(IPC::Connection::addWorkQueueMessageReceiver):
(IPC::Connection::removeWorkQueueMessageReceiver):
(IPC::Connection::addThreadMessageReceiver):
(IPC::Connection::removeThreadMessageReceiver):
(IPC::Connection::processIncomingMessage):
(IPC::Connection::dispatchMessageToWorkQueueReceiver):
(IPC::Connection::dispatchMessageToThreadReceiver):
* Platform/IPC/Connection.h:
(IPC::Connection::ThreadMessageReceiver::ref):
(IPC::Connection::ThreadMessageReceiver::deref):
- Add support for passing a destinationID when registering a WorkQueueMessageReceiver or a
ThreadMessageReceiver, similarly to regular MessageReceivers. This was needed here since
The GPUProcess sends IPC messages to the RemoteAudioDestinationProxy with a given
destinationID and since RemoteAudioDestinationProxy is now a ThreadMessageReceiver.
- Stop having ThreadMessageReceiver subclass ThreadSafeRefCounted since
RemoteAudioDestinationProxy already subclasses ThreadSafeRefCounted indirectly. A new
ThreadMessageReceiverRefCounted class was added for convenience for existing code that
relied on its refcounting.
* WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp:
(WebKit::RemoteAudioDestinationProxy::RemoteAudioDestinationProxy):
(WebKit::RemoteAudioDestinationProxy::~RemoteAudioDestinationProxy):
(WebKit::RemoteAudioDestinationProxy::start):
(WebKit::RemoteAudioDestinationProxy::stop):
(WebKit::RemoteAudioDestinationProxy::renderBuffer):
(WebKit::RemoteAudioDestinationProxy::didChangeIsPlaying):
(WebKit::RemoteAudioDestinationProxy::dispatchToThread):
* WebProcess/GPU/media/RemoteAudioDestinationProxy.h:
Use a PushPullFIFO container in render() to avoid handing the audio rendering thread on
a semaphore while the Render IPC is getting processed by the WebProcess.
Source/WTF:
* wtf/CrossThreadQueue.h:
(WTF::CrossThreadQueue<DataType>::waitForMessage):
If CrossThreadQueue::kill() gets called while another thread is waiting on a
CrossThreadQueue::waitForMessage() call, make it so that waitForMessage()
returns a default-constructed DataType instead of crashing trying to
dequeue (since the queue is empty).
LayoutTests:
Unskip webaudio tests when the GPU process is enabled.
* gpu-process/TestExpectations:
Canonical link: https://commits.webkit.org/230420@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268423 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=217532
Reviewed by Tim Horton.
Source/WebCore:
Add support for using `video` elements as sources for `createImageBitmap` and `createPattern` by ensuring that
we use display-list-backed image buffers for painting when using the GPU process for media. See below for more
details.
Tests: fast/canvas/canvas-createPattern-video-loading.html
fast/canvas/canvas-createPattern-video-modify.html
imported/w3c/web-platform-tests/html/canvas/element/imagebitmap/canvas-createImageBitmap-video-resize.html
imported/w3c/web-platform-tests/html/canvas/element/imagebitmap/createImageBitmap-drawImage.html
imported/w3c/web-platform-tests/html/canvas/element/imagebitmap/createImageBitmap-flipY.html
* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::createBufferForPainting const):
* html/HTMLVideoElement.h:
Add a helper function to create an `ImageBuffer` compatible with this video element, for the purpose of
painting video frames. In particular, if GPU process for media is enabled, we'll create a display-list-backed
remote image buffer.
* html/ImageBitmap.cpp:
(WebCore::ImageBitmap::createPromise):
Call into `HTMLVideoElement::createBufferForPainting` to construct the `ImageBuffer`.
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::createPattern):
Call into `HTMLVideoElement::createBufferForPainting` to construct the `ImageBuffer`.
* platform/graphics/RenderingMode.h:
Add a "purpose" enum value for media painting.
* platform/graphics/displaylists/DisplayListImageBuffer.h:
Adjust this to avoid forcing the platform context to be created in the case where there are no display list
items to flush. Needed to avoid crashing when creating `CanvasPattern` with a video element.
Source/WebKit:
See WebCore/ChangeLog for more details.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::shouldUseRemoteRenderingFor):
LayoutTests:
Unskip several layout tests that pass after this change.
* gpu-process/TestExpectations:
Canonical link: https://commits.webkit.org/230324@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268299 268f45cc-cd09-0410-ab3c-d52691b4dbfc