[webkit-changes] [WebKit/WebKit] ecb76a: ThreadSafeObjectHeap lacks add and remove operations

Kimmo Kinnunen noreply at github.com
Mon Jun 12 04:44:37 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ecb76a449ffa26cb4da089afe4ee8d7ba90f13a9
      https://github.com/WebKit/WebKit/commit/ecb76a449ffa26cb4da089afe4ee8d7ba90f13a9
  Author: Kimmo Kinnunen <kkinnunen at apple.com>
  Date:   2023-06-12 (Mon, 12 Jun 2023)

  Changed paths:
    M Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp
    M Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp
    M Source/WebKit/GPUProcess/media/RemoteVideoFrameObjectHeap.cpp
    M Source/WebKit/GPUProcess/media/RemoteVideoFrameObjectHeap.mm
    M Source/WebKit/Platform/IPC/ObjectIdentifierReferenceTracker.h
    M Source/WebKit/Platform/IPC/ThreadSafeObjectHeap.h
    M Source/WebKit/WebProcess/GPU/media/RemoteVideoFrameProxy.cpp
    M Source/WebKit/WebProcess/GPU/media/RemoteVideoFrameProxy.h
    M Tools/TestWebKitAPI/Tests/IPC/ThreadSafeObjectHeapTests.cpp

  Log Message:
  -----------
  ThreadSafeObjectHeap lacks add and remove operations
https://bugs.webkit.org/show_bug.cgi?id=257647
rdar://110169358

Reviewed by Youenn Fablet.

Before, writing to ThreadSafeObjectHeap was intended to use the
retire(WriteReference, optional<T>, optional<Timeout>). The heap also
was intended to support copy-on-write or overwriting non-depending
update scenarios where an overwriting write could skip ahead the
earlier, non-processed reads and writes.

For example, receiving following sequence with reads omitted:
 write version=0, "1"    (sequence x)
 write version=1, "abc"  (sequence y)
 write version=2, "abcd" (sequence y)

In case of overwriting, non-depending writes, sequence y could proceed
first and insert version 1 and then subsequently version 2. Inserting
version 1 would insert a final read marker for version 0, which would be
noticed by eventual sequence x inserting first version 0. Upon
inserting version 0, the insert would be skipped as that version was
already overwritten.

However, since there was no distinction between "write" and "initial
write", the final read marker would be needed for inserting any object,
including the initial insert. This in turn would mean that the heap
would be leaking the final read marker for the initial insertion.

Instead, change the API to "add", "get", "read", "take", "remove". These
are more intuitive with the use-cases. Each write must naturally remove
the instance from the heap for the duration of the update, as would
de-facto happen in non-overwriting write also previously. Non-blocking
remove and add can be used for overwriting write until more performance
is needed.

* Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp:
(WebKit::GPUConnectionToWebProcess::releaseSerializedImageBuffer):
* Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::moveToSerializedBuffer):
(WebKit::RemoteRenderingBackend::moveToImageBuffer):
* Source/WebKit/GPUProcess/media/RemoteVideoFrameObjectHeap.cpp:
(WebKit::RemoteVideoFrameObjectHeap::add):
(WebKit::RemoteVideoFrameObjectHeap::releaseVideoFrame):
* Source/WebKit/GPUProcess/media/RemoteVideoFrameObjectHeap.mm:
(WebKit::RemoteVideoFrameObjectHeap::get):
* Source/WebKit/Platform/IPC/ObjectIdentifierReferenceTracker.h:
(IPC::ObjectIdentifierReference::generateForAdd):
(IPC::ObjectIdentifierReferenceTracker::add const):
(IPC::ObjectIdentifierWriteReference::generateForAdd): Deleted.
* Source/WebKit/Platform/IPC/ThreadSafeObjectHeap.h:
(IPC::ThreadSafeObjectHeap::ReferenceState::ReferenceState):
(IPC::HeldType>::add):
(IPC::HeldType>::get):
(IPC::HeldType>::read):
(IPC::HeldType>::remove):
(IPC::HeldType>::sizeForTesting const):
(IPC::HeldType>::retire): Deleted.
(IPC::HeldType>::retireRemove): Deleted.
* Source/WebKit/WebProcess/GPU/media/RemoteVideoFrameProxy.cpp:
(WebKit::RemoteVideoFrameProxy::properties):
* Source/WebKit/WebProcess/GPU/media/RemoteVideoFrameProxy.h:
* Tools/TestWebKitAPI/Tests/IPC/ThreadSafeObjectHeapTests.cpp:
(TestWebKitAPI::TEST_F):

Canonical link: https://commits.webkit.org/265063@main




More information about the webkit-changes mailing list