⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 293723 in webkit


Ignore:
Timestamp:
May 3, 2022, 7:16:55 AM (4 years ago)
Author:
commit-queue@webkit.org
Message:

IPC stream connection sends should fail immediately when connection closes
​https://bugs.webkit.org/show_bug.cgi?id=238253

Patch by Kimmo Kinnunen <​kkinnunen@apple.com> on 2022-05-03
Reviewed by Simon Fraser.

Source/WebKit:

Send the StreamClientConnection client wait semaphore from
StreamServerConnection. This way the client will fail the wait
when the server crashes.

Test: ipc/stream-sync-crash-no-timeout.html

  • GPUProcess/graphics/RemoteGraphicsContextGL.cpp:

(WebKit::RemoteGraphicsContextGL::workQueueInitialize):

  • GPUProcess/graphics/RemoteRenderingBackend.cpp:

(WebKit::RemoteRenderingBackend::startListeningForIPC):

  • GPUProcess/graphics/WebGPU/RemoteGPU.cpp:

(WebKit::RemoteGPU::workQueueInitialize):

  • Platform/IPC/StreamClientConnection.cpp:

(IPC::StreamClientConnection::setSemaphores):
(IPC::StreamClientConnection::wakeUpServer):

  • Platform/IPC/StreamClientConnection.h:

(IPC::StreamClientConnection::tryAcquire):
(IPC::StreamClientConnection::tryAcquireAll):

  • Platform/IPC/StreamConnectionBuffer.cpp:

(IPC::StreamConnectionBuffer::StreamConnectionBuffer):
(IPC::StreamConnectionBuffer::operator=):
(IPC::StreamConnectionBuffer::encode const):
(IPC::StreamConnectionBuffer::decode):

  • Platform/IPC/StreamConnectionBuffer.h:

(IPC::StreamConnectionBuffer::dataSize const):

  • Platform/IPC/StreamServerConnection.cpp:

(IPC::StreamServerConnection::release):
(IPC::StreamServerConnection::releaseAll):

  • Platform/IPC/StreamServerConnection.h:
  • Shared/IPCStreamTester.cpp:

(WebKit::IPCStreamTester::initialize):
(WebKit::IPCStreamTester::syncCrashOnZero):

  • Shared/IPCStreamTester.h:
  • Shared/IPCStreamTester.messages.in:
  • Shared/IPCStreamTesterProxy.h:
  • Shared/IPCStreamTesterProxy.messages.in:
  • WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp:

(WebKit::RemoteGraphicsContextGLProxy::wasCreated):

  • WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h:
  • WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.messages.in:
  • WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:

(WebKit::RemoteRenderingBackendProxy::streamConnection):
(WebKit::RemoteRenderingBackendProxy::didInitialize):

  • WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h:
  • WebProcess/GPU/graphics/RemoteRenderingBackendProxy.messages.in:
  • WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.cpp:

(WebKit::RemoteGPUProxy::wasCreated):

  • WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.h:
  • WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.messages.in:
  • WebProcess/WebPage/IPCTestingAPI.cpp:

(WebKit::IPCTestingAPI::JSIPCStreamClientConnection::setSemaphores):
(WebKit::IPCTestingAPI::JSIPCStreamClientConnection::staticFunctions):
(WebKit::IPCTestingAPI::JSIPCStreamClientConnection::sendIPCStreamTesterSyncCrashOnZero):

LayoutTests:

The test works on minibrowser but GPUP startup code fails in run-webkit-tests,
thus disabled.

  • TestExpectations:
  • ipc/stream-sync-crash-no-timeout-expected.txt: Added.
  • ipc/stream-sync-crash-no-timeout.html: Added.
  • ipc/stream-sync-reply-shared-memory.html: Adjust after API change.
Location:
trunk
Files:
2 added
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r293719 r293723  
     12022-05-03  Kimmo Kinnunen  <kkinnunen@apple.com>
     2
     3        IPC stream connection sends should fail immediately when connection closes
     4        https://bugs.webkit.org/show_bug.cgi?id=238253
     5
     6        Reviewed by Simon Fraser.
     7
     8        The test works on minibrowser but GPUP startup code fails in run-webkit-tests,
     9        thus disabled.
     10
     11        * TestExpectations:
     12        * ipc/stream-sync-crash-no-timeout-expected.txt: Added.
     13        * ipc/stream-sync-crash-no-timeout.html: Added.
     14        * ipc/stream-sync-reply-shared-memory.html: Adjust after API change.
     15
    1162022-05-03  Youenn Fablet  <youenn@apple.com>
    217
  • trunk/LayoutTests/TestExpectations

    r293719 r293723  
    50945094[ Debug ] ipc/send-invalid-message.html [ Skip ]
    50955095
     5096# Restarted GPUP seems to crash.
     5097webkit.org/b/239959 ipc/stream-sync-crash-no-timeout.html [ Skip ]
     5098
    50965099# The test invokes random messages, potentially produces random results.
    50975100ipc/start-message-testing.html [ Skip ]
  • trunk/LayoutTests/ipc/stream-sync-reply-shared-memory.html

    r290505 r293723  
    1717        ]);
    1818        const arguments = IPC.waitForMessage(processTarget, streamTesterID, IPC.messages.IPCStreamTesterProxy_WasCreated.name, defaultTimeout);
    19         streamConnection.setWakeUpSemaphore(arguments[0].value);
     19        streamConnection.setSemaphores(arguments[0].value, arguments[1].value);
    2020
    2121        // Test starts here.
  • trunk/Source/WebKit/ChangeLog

    r293716 r293723  
     12022-05-03  Kimmo Kinnunen  <kkinnunen@apple.com>
     2
     3        IPC stream connection sends should fail immediately when connection closes
     4        https://bugs.webkit.org/show_bug.cgi?id=238253
     5
     6        Reviewed by Simon Fraser.
     7
     8        Send the StreamClientConnection client wait semaphore from
     9        StreamServerConnection. This way the client will fail the wait
     10        when the server crashes.
     11
     12        Test: ipc/stream-sync-crash-no-timeout.html
     13
     14        * GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
     15        (WebKit::RemoteGraphicsContextGL::workQueueInitialize):
     16        * GPUProcess/graphics/RemoteRenderingBackend.cpp:
     17        (WebKit::RemoteRenderingBackend::startListeningForIPC):
     18        * GPUProcess/graphics/WebGPU/RemoteGPU.cpp:
     19        (WebKit::RemoteGPU::workQueueInitialize):
     20        * Platform/IPC/StreamClientConnection.cpp:
     21        (IPC::StreamClientConnection::setSemaphores):
     22        (IPC::StreamClientConnection::wakeUpServer):
     23        * Platform/IPC/StreamClientConnection.h:
     24        (IPC::StreamClientConnection::tryAcquire):
     25        (IPC::StreamClientConnection::tryAcquireAll):
     26        * Platform/IPC/StreamConnectionBuffer.cpp:
     27        (IPC::StreamConnectionBuffer::StreamConnectionBuffer):
     28        (IPC::StreamConnectionBuffer::operator=):
     29        (IPC::StreamConnectionBuffer::encode const):
     30        (IPC::StreamConnectionBuffer::decode):
     31        * Platform/IPC/StreamConnectionBuffer.h:
     32        (IPC::StreamConnectionBuffer::dataSize const):
     33        * Platform/IPC/StreamServerConnection.cpp:
     34        (IPC::StreamServerConnection::release):
     35        (IPC::StreamServerConnection::releaseAll):
     36        * Platform/IPC/StreamServerConnection.h:
     37        * Shared/IPCStreamTester.cpp:
     38        (WebKit::IPCStreamTester::initialize):
     39        (WebKit::IPCStreamTester::syncCrashOnZero):
     40        * Shared/IPCStreamTester.h:
     41        * Shared/IPCStreamTester.messages.in:
     42        * Shared/IPCStreamTesterProxy.h:
     43        * Shared/IPCStreamTesterProxy.messages.in:
     44        * WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp:
     45        (WebKit::RemoteGraphicsContextGLProxy::wasCreated):
     46        * WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h:
     47        * WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.messages.in:
     48        * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
     49        (WebKit::RemoteRenderingBackendProxy::streamConnection):
     50        (WebKit::RemoteRenderingBackendProxy::didInitialize):
     51        * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h:
     52        * WebProcess/GPU/graphics/RemoteRenderingBackendProxy.messages.in:
     53        * WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.cpp:
     54        (WebKit::RemoteGPUProxy::wasCreated):
     55        * WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.h:
     56        * WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.messages.in:
     57        * WebProcess/WebPage/IPCTestingAPI.cpp:
     58        (WebKit::IPCTestingAPI::JSIPCStreamClientConnection::setSemaphores):
     59        (WebKit::IPCTestingAPI::JSIPCStreamClientConnection::staticFunctions):
     60        (WebKit::IPCTestingAPI::JSIPCStreamClientConnection::sendIPCStreamTesterSyncCrashOnZero):
     61
    1622022-05-02  Tim Horton  <timothy_horton@apple.com>
    263
  • trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp

    r293211 r293723  
    132132        String extensions = m_context->getString(GraphicsContextGL::EXTENSIONS);
    133133        String requestableExtensions = m_context->getString(GraphicsContextGL::REQUESTABLE_EXTENSIONS_ANGLE);
    134         send(Messages::RemoteGraphicsContextGLProxy::WasCreated(true, remoteGraphicsContextGLStreamWorkQueue().wakeUpSemaphore(), extensions, requestableExtensions));
     134        send(Messages::RemoteGraphicsContextGLProxy::WasCreated(true, remoteGraphicsContextGLStreamWorkQueue().wakeUpSemaphore(), m_streamConnection->clientWaitSemaphore(), extensions, requestableExtensions));
    135135    } else
    136         send(Messages::RemoteGraphicsContextGLProxy::WasCreated(false, IPC::Semaphore { }, emptyString(), emptyString()));
     136        send(Messages::RemoteGraphicsContextGLProxy::WasCreated(false, { }, { }, emptyString(), emptyString()));
    137137}
    138138
  • trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp

    r293683 r293723  
    112112    m_streamConnection->startReceivingMessages(*this, Messages::RemoteRenderingBackend::messageReceiverName(), m_renderingBackendIdentifier.toUInt64());
    113113    m_streamConnection->open();
    114     send(Messages::RemoteRenderingBackendProxy::DidCreateWakeUpSemaphoreForDisplayListStream(m_workQueue->wakeUpSemaphore()), m_renderingBackendIdentifier);
     114    send(Messages::RemoteRenderingBackendProxy::DidInitialize(m_workQueue->wakeUpSemaphore(), m_streamConnection->clientWaitSemaphore()), m_renderingBackendIdentifier);
    115115}
    116116
  • trunk/Source/WebKit/GPUProcess/graphics/WebGPU/RemoteGPU.cpp

    r293106 r293723  
    9595    if (backing) {
    9696        m_backing = backing.releaseNonNull();
    97         send(Messages::RemoteGPUProxy::WasCreated(true, workQueue().wakeUpSemaphore()));
     97        send(Messages::RemoteGPUProxy::WasCreated(true, workQueue().wakeUpSemaphore(), m_streamConnection->clientWaitSemaphore()));
    9898    } else
    99         send(Messages::RemoteGPUProxy::WasCreated(false, workQueue().wakeUpSemaphore()));
     99        send(Messages::RemoteGPUProxy::WasCreated(false, { }, { }));
    100100}
    101101
  • trunk/Source/WebKit/Platform/IPC/StreamClientConnection.cpp

    r292803 r293723  
    9797}
    9898
    99 void StreamClientConnection::setWakeUpSemaphore(IPC::Semaphore&& semaphore)
     99void StreamClientConnection::setSemaphores(IPC::Semaphore&& wakeUp, IPC::Semaphore&& clientWait)
    100100{
    101     m_wakeUpSemaphore = WTFMove(semaphore);
     101    m_semaphores = { WTFMove(wakeUp), WTFMove(clientWait) };
    102102    wakeUpServer();
    103103}
    … …  
    105105void StreamClientConnection::wakeUpServer()
    106106{
    107     if (!m_wakeUpSemaphore)
     107    if (!m_semaphores)
    108108        return;
    109109
    110     m_wakeUpSemaphore->signal();
     110    m_semaphores->wakeUp.signal();
    111111    m_remainingMessageCountBeforeSendingWakeUp = 0;
    112112}
  • trunk/Source/WebKit/Platform/IPC/StreamClientConnection.h

    r292803 r293723  
    8484
    8585    StreamConnectionBuffer& streamBuffer() { return m_buffer; }
    86     void setWakeUpSemaphore(IPC::Semaphore&&);
    87     bool hasWakeUpSemaphore() const { return m_wakeUpSemaphore.has_value(); }
     86    void setSemaphores(IPC::Semaphore&& wakeUp, IPC::Semaphore&& clientWait);
     87    bool hasSemaphores() const { return m_semaphores.has_value(); }
    8888
    8989    void setWakeUpMessageHysteresis(unsigned hysteresis)
    … …  
    156156    size_t m_clientOffset { 0 };
    157157    StreamConnectionBuffer m_buffer;
    158     std::optional<Semaphore> m_wakeUpSemaphore;
     158    struct Semaphores {
     159        Semaphore wakeUp;
     160        Semaphore clientWait;
     161    };
     162    std::optional<Semaphores> m_semaphores;
    159163    unsigned m_remainingMessageCountBeforeSendingWakeUp { 0 };
    160164    unsigned m_wakeUpMessageHysteresis { 0 };
    … …  
    308312        ClientLimit oldClientLimit = sharedClientLimit().compareExchangeStrong(clientLimit, ClientLimit::clientIsWaitingTag, std::memory_order_acq_rel, std::memory_order_acq_rel);
    309313        if (clientLimit == oldClientLimit) {
    310             m_buffer.clientWaitSemaphore().waitFor(timeout);
     314            if (!m_semaphores || !m_semaphores->clientWait.waitFor(timeout))
     315                return std::nullopt;
    311316            clientLimit = sharedClientLimit().load(std::memory_order_acquire);
    312317        } else
    … …  
    339344            break;
    340345
    341         m_buffer.clientWaitSemaphore().waitFor(timeout);
     346        if (!m_semaphores || !m_semaphores->clientWait.waitFor(timeout))
     347            return std::nullopt;
    342348        if (timeout.didTimeOut())
    343349            return std::nullopt;
  • trunk/Source/WebKit/Platform/IPC/StreamConnectionBuffer.cpp

    r291428 r293723  
    4747}
    4848
    49 StreamConnectionBuffer::StreamConnectionBuffer(Ref<WebKit::SharedMemory>&& memory, size_t memorySize, Semaphore&& clientWaitSemaphore)
     49StreamConnectionBuffer::StreamConnectionBuffer(Ref<WebKit::SharedMemory>&& memory, size_t memorySize)
    5050    : m_dataSize(memorySize - headerSize())
    5151    , m_sharedMemory(WTFMove(memory))
    52     , m_clientWaitSemaphore(WTFMove(clientWaitSemaphore))
    5352{
    5453    ASSERT(m_dataSize > 0);
    … …  
    6564        m_dataSize = other.m_dataSize;
    6665        m_sharedMemory = WTFMove(other.m_sharedMemory);
    67         m_clientWaitSemaphore = WTFMove(other.m_clientWaitSemaphore);
    6866    }
    6967    return *this;
    … …  
    7775    WebKit::SharedMemory::IPCHandle ipcHandle { WTFMove(handle), m_sharedMemory->size() };
    7876    encoder << ipcHandle;
    79     encoder << m_clientWaitSemaphore;
    8077}
    8178
    … …  
    8582    decoder >> ipcHandle;
    8683    if (!ipcHandle)
    87         return std::nullopt;
    88     std::optional<Semaphore> semaphore;
    89     decoder >> semaphore;
    90     if (!semaphore)
    9184        return std::nullopt;
    9285    size_t dataSize = static_cast<size_t>(ipcHandle->dataSize);
    … …  
    9891    if (sharedMemory->size() < dataSize)
    9992        return std::nullopt;
    100     return StreamConnectionBuffer { sharedMemory.releaseNonNull(), dataSize,  WTFMove(*semaphore) };
     93    return StreamConnectionBuffer { sharedMemory.releaseNonNull(), dataSize };
    10194}
    10295
  • trunk/Source/WebKit/Platform/IPC/StreamConnectionBuffer.h

    r291428 r293723  
    2727
    2828#include "Decoder.h"
    29 #include "IPCSemaphore.h"
    3029#include "SharedMemory.h"
    3130#include <wtf/Atomics.h>
    … …  
    110109    uint8_t* data() const { return static_cast<uint8_t*>(m_sharedMemory->data()) + headerSize(); }
    111110    size_t dataSize() const { return m_dataSize; }
    112     Semaphore& clientWaitSemaphore() { return m_clientWaitSemaphore; }
    113111
    114112    static constexpr size_t maximumSize() { return std::min(static_cast<size_t>(ClientOffset::serverIsSleepingTag), static_cast<size_t>(ClientOffset::serverIsSleepingTag)) - 1; }
    … …  
    120118
    121119private:
    122     StreamConnectionBuffer(Ref<WebKit::SharedMemory>&&, size_t memorySize, Semaphore&& clientWaitSemaphore);
     120    StreamConnectionBuffer(Ref<WebKit::SharedMemory>&&, size_t memorySize);
    123121
    124122    struct Header {
    … …  
    133131    size_t m_dataSize { 0 };
    134132    Ref<WebKit::SharedMemory> m_sharedMemory;
    135     Semaphore m_clientWaitSemaphore;
    136133};
    137134
  • trunk/Source/WebKit/Platform/IPC/StreamServerConnection.cpp

    r292803 r293723  
    173173    // If the client wrote over serverOffset, it means the client is waiting.
    174174    if (oldServerOffset == ServerOffset::clientIsWaitingTag)
    175         m_buffer.clientWaitSemaphore().signal();
     175        m_clientWaitSemaphore.signal();
    176176    else
    177177        ASSERT(!(oldServerOffset & ServerOffset::clientIsWaitingTag));
    … …  
    186186    // If the client wrote over serverOffset, it means the client is waiting.
    187187    if (oldServerOffset == ServerOffset::clientIsWaitingTag)
    188         m_buffer.clientWaitSemaphore().signal();
     188        m_clientWaitSemaphore.signal();
    189189    else
    190190        ASSERT(!(oldServerOffset & ServerOffset::clientIsWaitingTag));
  • trunk/Source/WebKit/Platform/IPC/StreamServerConnection.h

    r292863 r293723  
    2929#include "Decoder.h"
    3030#include "Encoder.h"
     31#include "IPCSemaphore.h"
    3132#include "MessageNames.h"
    3233#include "StreamConnectionBuffer.h"
    … …  
    8788    void sendSyncReply(Connection::SyncRequestID, Arguments&&...);
    8889
     90    Semaphore& clientWaitSemaphore() { return m_clientWaitSemaphore; }
     91
    8992private:
    9093    enum class HasDedicatedConnection : bool { No, Yes };
    … …  
    121124
    122125    Ref<IPC::Connection> m_connection;
     126    Semaphore m_clientWaitSemaphore;
    123127    StreamConnectionWorkQueue& m_workQueue;
    124128
  • trunk/Source/WebKit/Shared/IPCStreamTester.cpp

    r292803 r293723  
    5858    m_streamConnection->open();
    5959    workQueue().dispatch([this] {
    60         m_streamConnection->connection().send(Messages::IPCStreamTesterProxy::WasCreated(workQueue().wakeUpSemaphore()), m_identifier);
     60        m_streamConnection->connection().send(Messages::IPCStreamTesterProxy::WasCreated(workQueue().wakeUpSemaphore(), m_streamConnection->clientWaitSemaphore()), m_identifier);
    6161    });
    6262}
    … …  
    8888}
    8989
     90void IPCStreamTester::syncCrashOnZero(int32_t value, CompletionHandler<void(int32_t)>&& completionHandler)
     91{
     92    if (!value) {
     93        // Use exit so that we don't leave a crash report.
     94#if OS(WINDOWS)
     95        // Calling _exit in non-main threads may cause a deadlock in WTF::Thread::ThreadHolder::~ThreadHolder.
     96        TerminateProcess(GetCurrentProcess(), EXIT_SUCCESS);
     97#else
     98        _exit(EXIT_SUCCESS);
     99#endif
     100    }
     101    completionHandler(value);
     102}
     103
    90104}
    91105
  • trunk/Source/WebKit/Shared/IPCStreamTester.h

    r292280 r293723  
    5959    // Messages.
    6060    void syncMessageReturningSharedMemory1(uint32_t byteCount, CompletionHandler<void(SharedMemory::IPCHandle)>&&);
     61    void syncCrashOnZero(int32_t, CompletionHandler<void(int32_t)>&&);
    6162
    6263    const Ref<IPC::StreamConnectionWorkQueue> m_workQueue;
  • trunk/Source/WebKit/Shared/IPCStreamTester.messages.in

    r290505 r293723  
    2525messages -> IPCStreamTester NotRefCounted Stream {
    2626    SyncMessageReturningSharedMemory1(uint32_t byteCount) -> (WebKit::SharedMemory::IPCHandle handle) Synchronous NotStreamEncodableReply
     27    SyncCrashOnZero(int32_t value) -> (int32_t sameValue) Synchronous
    2728}
    2829
  • trunk/Source/WebKit/Shared/IPCStreamTesterProxy.h

    r290594 r293723  
    5050
    5151    // Messages.
    52     void wasCreated(IPC::Semaphore&&) { }
     52    void wasCreated(IPC::Semaphore&&, IPC::Semaphore&&) { }
    5353};
    5454
  • trunk/Source/WebKit/Shared/IPCStreamTesterProxy.messages.in

    r290505 r293723  
    2424
    2525messages -> IPCStreamTesterProxy NotRefCounted {
    26     void WasCreated(IPC::Semaphore streamWakeUpSemaphore)
     26    void WasCreated(IPC::Semaphore streamWakeUpSemaphore, IPC::Semaphore streamClientWaitSemaphore)
    2727}
    2828
  • trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp

    r293211 r293723  
    318318}
    319319
    320 void RemoteGraphicsContextGLProxy::wasCreated(bool didSucceed, IPC::Semaphore&& semaphore, String&& availableExtensions, String&& requestedExtensions)
     320void RemoteGraphicsContextGLProxy::wasCreated(bool didSucceed, IPC::Semaphore&& wakeUpSemaphore, IPC::Semaphore&& clientWaitSemaphore, String&& availableExtensions, String&& requestedExtensions)
    321321{
    322322    if (isContextLost())
    … …  
    327327    }
    328328    ASSERT(!m_didInitialize);
    329     m_streamConnection.setWakeUpSemaphore(WTFMove(semaphore));
     329    m_streamConnection.setSemaphores(WTFMove(wakeUpSemaphore), WTFMove(clientWaitSemaphore));
    330330    m_didInitialize = true;
    331331    initialize(availableExtensions, requestedExtensions);
  • trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h

    r293211 r293723  
    347347private:
    348348    // Messages to be received.
    349     void wasCreated(bool didSucceed, IPC::Semaphore&&, String&& availableExtensions, String&& requestedExtensions);
     349    void wasCreated(bool didSucceed, IPC::Semaphore&&, IPC::Semaphore&&, String&& availableExtensions, String&& requestedExtensions);
    350350    void wasLost();
    351351    void wasChanged();
  • trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.messages.in

    r273204 r293723  
    2424
    2525messages -> RemoteGraphicsContextGLProxy NotRefCounted {
    26     void WasCreated(bool didSucceed, IPC::Semaphore streamWakeUpSemaphore, String availableExtensions, String requestableExtensions)
     26    void WasCreated(bool didSucceed, IPC::Semaphore streamWakeUpSemaphore, IPC::Semaphore streamClientWaitSemaphore, String availableExtensions, String requestableExtensions)
    2727    void WasLost()
    2828    void WasChanged()
  • trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp

    r293683 r293723  
    428428{
    429429    ensureGPUProcessConnection();
    430     if (UNLIKELY(!m_streamConnection->hasWakeUpSemaphore()))
    431         m_streamConnection->waitForAndDispatchImmediately<Messages::RemoteRenderingBackendProxy::DidCreateWakeUpSemaphoreForDisplayListStream>(renderingBackendIdentifier(), 3_s, IPC::WaitForOption::InterruptWaitingIfSyncMessageArrives);
     430    if (UNLIKELY(!m_streamConnection->hasSemaphores()))
     431        m_streamConnection->waitForAndDispatchImmediately<Messages::RemoteRenderingBackendProxy::DidInitialize>(renderingBackendIdentifier(), 3_s, IPC::WaitForOption::InterruptWaitingIfSyncMessageArrives);
    432432    return *m_streamConnection;
    433433}
    434434
    435 void RemoteRenderingBackendProxy::didCreateWakeUpSemaphoreForDisplayListStream(IPC::Semaphore&& semaphore)
     435void RemoteRenderingBackendProxy::didInitialize(IPC::Semaphore&& wakeUp, IPC::Semaphore&& clientWait)
    436436{
    437437    if (!m_streamConnection) {
    … …  
    439439        return;
    440440    }
    441     m_streamConnection->setWakeUpSemaphore(WTFMove(semaphore));
     441    m_streamConnection->setSemaphores(WTFMove(wakeUp), WTFMove(clientWait));
    442442}
    443443
  • trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h

    r293683 r293723  
    134134    bool isGPUProcessConnectionClosed() const { return !m_gpuProcessConnection; }
    135135
    136     void didCreateWakeUpSemaphoreForDisplayListStream(IPC::Semaphore&&);
     136    void didInitialize(IPC::Semaphore&& wakeUpSemaphore, IPC::Semaphore&& clientWaitSemaphore);
    137137
    138138    template<typename T, typename U>
  • trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.messages.in

    r293683 r293723  
    2727    DidFlush(WebCore::GraphicsContextFlushIdentifier flushIdentifier, WebCore::RenderingResourceIdentifier renderingResourceIdentifier)
    2828    DidFinalizeRenderingUpdate(WebKit::RenderingUpdateID didRenderingUpdateID)
    29     DidCreateWakeUpSemaphoreForDisplayListStream(IPC::Semaphore wakeUpSemaphore)
     29    DidInitialize(IPC::Semaphore wakeUpSemaphore, IPC::Semaphore clientWaitSemaphore)
    3030    DidMarkLayersAsVolatile(WebKit::MarkSurfacesAsVolatileRequestIdentifier requestIdentifier, Vector<WebCore::RenderingResourceIdentifier> markedVolatileBufferIdentifiers, bool didMarkAllLayersAsVolatile)
    3131}
  • trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.cpp

    r292803 r293723  
    7676}
    7777
    78 void RemoteGPUProxy::wasCreated(bool didSucceed, IPC::Semaphore&& semaphore)
     78void RemoteGPUProxy::wasCreated(bool didSucceed, IPC::Semaphore&& wakeUpSemaphore, IPC::Semaphore&& clientWaitSemaphore)
    7979{
    8080    ASSERT(!m_didInitialize);
    81     m_streamConnection.setWakeUpSemaphore(WTFMove(semaphore));
     81    m_streamConnection.setSemaphores(WTFMove(wakeUpSemaphore), WTFMove(clientWaitSemaphore));
    8282    m_didInitialize = true;
    8383    m_lost = !didSucceed;
  • trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.h

    r291323 r293723  
    7777
    7878    // Messages to be received.
    79     void wasCreated(bool didSucceed, IPC::Semaphore&&);
     79    void wasCreated(bool didSucceed, IPC::Semaphore&& wakeUpSemaphore, IPC::Semaphore&& clientWaitSemaphore);
    8080
    8181    void waitUntilInitialized();
  • trunk/Source/WebKit/WebProcess/GPU/graphics/WebGPU/RemoteGPUProxy.messages.in

    r286320 r293723  
    2424
    2525messages -> RemoteGPUProxy NotRefCounted {
    26     void WasCreated(bool didSucceed, IPC::Semaphore streamWakeUpSemaphore)
     26    void WasCreated(bool didSucceed, IPC::Semaphore streamWakeUpSemaphore, IPC::Semaphore streamClientWaitSemaphore)
    2727}
    2828
  • trunk/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp

    r293612 r293723  
    3333#include "GPUProcessConnection.h"
    3434#include "IPCSemaphore.h"
     35#include "IPCStreamTesterMessages.h"
    3536#include "JSIPCBinding.h"
    3637#include "MessageArgumentDescriptions.h"
    … …  
    194195    { }
    195196
    196     void setWakeUpSemaphore(JSIPCSemaphore& jsSemaphore) { m_streamConnection.setWakeUpSemaphore(jsSemaphore.exchange()); }
     197    void setSemaphores(JSIPCSemaphore& jsWakeUpSemaphore, JSIPCSemaphore& jsClientWaitSemaphore) { m_streamConnection.setSemaphores(jsWakeUpSemaphore.exchange(), jsClientWaitSemaphore.exchange()); }
    197198
    198199    static JSClassRef wrapperClass();
    … …  
    205206    static const JSStaticFunction* staticFunctions();
    206207    static JSValueRef streamBuffer(JSContextRef, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
    207     static JSValueRef setWakeUpSemaphore(JSContextRef, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
     208    static JSValueRef setSemaphores(JSContextRef, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
    208209    static JSValueRef sendMessage(JSContextRef, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
    209210    static JSValueRef sendSyncMessage(JSContextRef, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
     211    static JSValueRef sendIPCStreamTesterSyncCrashOnZero(JSContextRef, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
    210212
    211213    WeakPtr<JSIPC> m_jsIPC;
    … …  
    855857    static const JSStaticFunction functions[] = {
    856858        { "streamBuffer", streamBuffer, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
    857         { "setWakeUpSemaphore", setWakeUpSemaphore, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
     859        { "setSemaphores", setSemaphores, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
    858860        { "sendMessage", sendMessage, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
    859861        { "sendSyncMessage", sendSyncMessage, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
     862        { "sendIPCStreamTesterSyncCrashOnZero", sendIPCStreamTesterSyncCrashOnZero, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
    860863        { 0, 0, 0 }
    861864    };
    … …  
    876879}
    877880
    878 JSValueRef JSIPCStreamClientConnection::setWakeUpSemaphore(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     881JSValueRef JSIPCStreamClientConnection::setSemaphores(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
    879882{
    880883    auto* globalObject = toJS(context);
    … …  
    886889    }
    887890
    888     if (argumentCount < 1) {
    889         *exception = createTypeError(context, "Must specify an IPC semaphore as the first argument"_s);
    890         return JSValueMakeUndefined(context);
    891     }
    892 
    893     RefPtr jsSemaphore = JSIPCSemaphore::toWrapped(context, arguments[0]);
    894     if (!jsSemaphore) {
     891    if (argumentCount < 2) {
     892        *exception = createTypeError(context, "Must specify an IPC semaphore as the first and second argument"_s);
     893        return JSValueMakeUndefined(context);
     894    }
     895
     896    RefPtr jsWakeUpSemaphore = JSIPCSemaphore::toWrapped(context, arguments[0]);
     897    if (!jsWakeUpSemaphore) {
    895898        *exception = createTypeError(context, "Wrong type (expected Semaphore)"_s);
    896899        return JSValueMakeUndefined(context);
    897900    }
    898901
    899     jsStreamConnection->setWakeUpSemaphore(*jsSemaphore);
     902    RefPtr jsClientWaitSemaphore = JSIPCSemaphore::toWrapped(context, arguments[1]);
     903    if (!jsClientWaitSemaphore) {
     904        *exception = createTypeError(context, "Wrong type (expected Semaphore)"_s);
     905        return JSValueMakeUndefined(context);
     906    }
     907
     908    jsStreamConnection->setSemaphores(*jsWakeUpSemaphore, *jsClientWaitSemaphore);
    900909    return JSValueMakeUndefined(context);
    901910}
    … …  
    10181027
    10191028    return JSValueMakeUndefined(context);
     1029}
     1030
     1031// FIXME(http://webkit.org/b/237197): Cannot send arbitrary messages, so we hard-code this one to be able to send it.
     1032JSValueRef JSIPCStreamClientConnection::sendIPCStreamTesterSyncCrashOnZero(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     1033{
     1034    auto* globalObject = toJS(context);
     1035    JSC::JSLockHolder lock(globalObject->vm());
     1036
     1037    RefPtr jsStreamConnection = toWrapped(context, thisObject);
     1038    if (!jsStreamConnection) {
     1039        *exception = createTypeError(context, "Wrong type"_s);
     1040        return JSValueMakeUndefined(context);
     1041    }
     1042
     1043    if (argumentCount < 3) {
     1044        *exception = createTypeError(context, "Must specify destination ID, value, and timeout as the first three arguments"_s);
     1045        return JSValueMakeUndefined(context);
     1046    }
     1047
     1048    auto destinationID = destinationIDFromArgument(globalObject, arguments[0], exception);
     1049    if (!destinationID)
     1050        return JSValueMakeUndefined(context);
     1051
     1052    int32_t value;
     1053    {
     1054        auto jsValue = toJS(globalObject, arguments[1]);
     1055        if (!jsValue.isNumber()) {
     1056            *exception = createTypeError(context, "value must be a number"_s);
     1057            return JSValueMakeUndefined(context);
     1058        }
     1059        value = static_cast<int32_t>(jsValue.asNumber());
     1060    }
     1061
     1062    Seconds timeoutDuration;
     1063    {
     1064        auto jsValue = toJS(globalObject, arguments[2]);
     1065        if (!jsValue.isNumber()) {
     1066            *exception = createTypeError(context, "timeout must be a number"_s);
     1067            return JSValueMakeUndefined(context);
     1068        }
     1069        timeoutDuration = Seconds { jsValue.asNumber() };
     1070    }
     1071
     1072    auto& streamConnection = jsStreamConnection->connection();
     1073    int32_t resultValue = 0;
     1074    enum JSIPCStreamTesterIdentifierType { };
     1075    auto destination = makeObjectIdentifier<JSIPCStreamTesterIdentifierType>(*destinationID);
     1076
     1077    auto result = streamConnection.sendSync(Messages::IPCStreamTester::SyncCrashOnZero(value), Messages::IPCStreamTester::SyncCrashOnZero::Reply(resultValue), destination, timeoutDuration);
     1078    if (!result) {
     1079        *exception = createTypeError(context, "sync send failed"_s);
     1080        return JSValueMakeUndefined(context);
     1081    }
     1082
     1083    return JSValueMakeNumber(context, resultValue);
    10201084}
    10211085
Note: See TracChangeset for help on using the changeset viewer.