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

Changeset 270591 in webkit


Ignore:
Timestamp:
Dec 9, 2020, 11:50:11 AM (6 years ago)
Author:
Wenson Hsieh
Message:

[Concurrent display lists] Support playback of display list items with cached resources
https://bugs.webkit.org/show_bug.cgi?id=218614
<rdar://problem/71326662>

Reviewed by Tim Horton.

Teaches the GPU process to resume playback of display list items that were previously unable to be played back
due to missing cached resources. See below for more details.

  • GPUProcess/graphics/RemoteRenderingBackend.cpp:

(WebKit::RemoteRenderingBackend::createImageBuffer):

See if the newly created image buffer's ID matches that of the pending wakeup message; if so, immediately kick
off the wakeup loop.

(WebKit::RemoteRenderingBackend::nextDestinationImageBufferAfterApplyingDisplayLists):
(WebKit::RemoteRenderingBackend::wakeUpAndApplyDisplayList):

In the case where the next destination image buffer is unknown, bail early and resume when we eventually learn
about the image buffer in the GPU process. This can happen if a MetaCommandChangeDestinationImageBuffer item is
added that references a newly created image buffer.

(WebKit::RemoteRenderingBackend::setNextItemBufferToRead):
(WebKit::RemoteRenderingBackend::cacheNativeImage):

See if the newly cached image's ID matches that of the pending wakeup message; if so, immediately kick off the
wakeup loop.

(WebKit::RemoteRenderingBackend::didCreateSharedDisplayListHandle):

  • GPUProcess/graphics/RemoteRenderingBackend.h:

Add a private PendingWakeupInformation struct that encapsulates all the information needed to remember that
we stopped display list processing, and resume processing in the future. Currently, this contains a set of
wakeup message arguments, and (optionally) the identifier of the missing resource that we need to receive in
order to continue.

We also use this in place of storing GPUProcessWakeupMessageArguments on RemoteRenderingBackend.

(WebKit::RemoteRenderingBackend::PendingWakeupInformation::shouldPerformWakeup const):

Location:
trunk/Source/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r270587 r270591  
     12020-12-09  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [Concurrent display lists] Support playback of display list items with cached resources
     4        https://bugs.webkit.org/show_bug.cgi?id=218614
     5        <rdar://problem/71326662>
     6
     7        Reviewed by Tim Horton.
     8
     9        Teaches the GPU process to resume playback of display list items that were previously unable to be played back
     10        due to missing cached resources. See below for more details.
     11
     12        * GPUProcess/graphics/RemoteRenderingBackend.cpp:
     13        (WebKit::RemoteRenderingBackend::createImageBuffer):
     14
     15        See if the newly created image buffer's ID matches that of the pending wakeup message; if so, immediately kick
     16        off the wakeup loop.
     17
     18        (WebKit::RemoteRenderingBackend::nextDestinationImageBufferAfterApplyingDisplayLists):
     19        (WebKit::RemoteRenderingBackend::wakeUpAndApplyDisplayList):
     20
     21        In the case where the next destination image buffer is unknown, bail early and resume when we eventually learn
     22        about the image buffer in the GPU process. This can happen if a MetaCommandChangeDestinationImageBuffer item is
     23        added that references a newly created image buffer.
     24
     25        (WebKit::RemoteRenderingBackend::setNextItemBufferToRead):
     26        (WebKit::RemoteRenderingBackend::cacheNativeImage):
     27
     28        See if the newly cached image's ID matches that of the pending wakeup message; if so, immediately kick off the
     29        wakeup loop.
     30
     31        (WebKit::RemoteRenderingBackend::didCreateSharedDisplayListHandle):
     32        * GPUProcess/graphics/RemoteRenderingBackend.h:
     33
     34        Add a private `PendingWakeupInformation` struct that encapsulates all the information needed to remember that
     35        we stopped display list processing, and resume processing in the future. Currently, this contains a set of
     36        wakeup message arguments, and (optionally) the identifier of the missing resource that we need to receive in
     37        order to continue.
     38
     39        We also use this in place of storing GPUProcessWakeupMessageArguments on RemoteRenderingBackend.
     40
     41        (WebKit::RemoteRenderingBackend::PendingWakeupInformation::shouldPerformWakeup const):
     42
    1432020-12-09  Kimmo Kinnunen  <kkinnunen@apple.com>
    244
  • trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp

    r270564 r270591  
    128128
    129129    m_remoteResourceCache.cacheImageBuffer(makeRef(*imageBuffer));
     130
     131    if (m_pendingWakeupInfo && m_pendingWakeupInfo->shouldPerformWakeup(renderingResourceIdentifier))
     132        wakeUpAndApplyDisplayList(std::exchange(m_pendingWakeupInfo, WTF::nullopt)->arguments);
    130133}
    131134
     
    191194            destination = makeRefPtr(m_remoteResourceCache.cachedImageBuffer(*result.nextDestinationImageBuffer));
    192195            if (!destination) {
    193                 ASSERT(!m_pendingWakeupArguments);
    194                 m_pendingWakeupArguments = {{ handle.identifier(), offset, *result.nextDestinationImageBuffer }};
     196                ASSERT(!m_pendingWakeupInfo);
     197                m_pendingWakeupInfo = {{{ handle.identifier(), offset, *result.nextDestinationImageBuffer }, WTF::nullopt }};
    195198            }
    196199        }
    197200
    198         if (m_pendingWakeupArguments)
     201        if (result.reasonForStopping == DisplayList::StopReplayReason::MissingCachedResource) {
     202            m_pendingWakeupInfo = {{
     203                { handle.identifier(), offset, destination->renderingResourceIdentifier() },
     204                result.missingCachedResourceIdentifier
     205            }};
     206        }
     207
     208        if (m_pendingWakeupInfo)
    199209            break;
    200210
     
    225235    destinationImageBuffer = nextDestinationImageBufferAfterApplyingDisplayLists(*destinationImageBuffer, arguments.offset, *initialHandle);
    226236    if (!destinationImageBuffer) {
    227         ASSERT_NOT_REACHED();
    228         return;
    229     }
    230 
    231     while (m_pendingWakeupArguments) {
    232         auto nextHandle = m_sharedDisplayListHandles.get(m_pendingWakeupArguments->itemBufferIdentifier);
     237        RELEASE_ASSERT(m_pendingWakeupInfo);
     238        return;
     239    }
     240
     241    while (m_pendingWakeupInfo) {
     242        if (m_pendingWakeupInfo->missingCachedResourceIdentifier)
     243            break;
     244
     245        auto nextHandle = m_sharedDisplayListHandles.get(m_pendingWakeupInfo->arguments.itemBufferIdentifier);
    233246        if (!nextHandle) {
    234247            // If the handle identifier is currently unknown, wait until the GPU process receives an
     
    238251
    239252        // Otherwise, continue reading the next display list item buffer from the start.
    240         auto arguments = *std::exchange(m_pendingWakeupArguments, WTF::nullopt);
     253        auto arguments = std::exchange(m_pendingWakeupInfo, WTF::nullopt)->arguments;
    241254        destinationImageBuffer = nextDestinationImageBufferAfterApplyingDisplayLists(*destinationImageBuffer, arguments.offset, *nextHandle);
    242255        if (!destinationImageBuffer) {
    243             ASSERT_NOT_REACHED();
    244             return;
     256            RELEASE_ASSERT(m_pendingWakeupInfo);
     257            break;
    245258        }
    246259    }
     
    249262void RemoteRenderingBackend::setNextItemBufferToRead(DisplayList::ItemBufferIdentifier identifier, WebCore::RenderingResourceIdentifier destinationIdentifier)
    250263{
    251     if (UNLIKELY(m_pendingWakeupArguments)) {
     264    if (UNLIKELY(m_pendingWakeupInfo)) {
    252265        // FIXME: Add a message check to terminate the web process.
    253266        ASSERT_NOT_REACHED();
    254267        return;
    255268    }
    256     m_pendingWakeupArguments = {{ identifier, SharedDisplayListHandle::headerSize(), destinationIdentifier }};
     269    m_pendingWakeupInfo = {{{ identifier, SharedDisplayListHandle::headerSize(), destinationIdentifier }, WTF::nullopt }};
    257270}
    258271
     
    267280void RemoteRenderingBackend::cacheNativeImage(const ShareableBitmap::Handle& handle, RenderingResourceIdentifier renderingResourceIdentifier)
    268281{
    269     if (auto bitmap = ShareableBitmap::create(handle)) {
    270         if (auto image = NativeImage::create(bitmap->createPlatformImage(), renderingResourceIdentifier))
    271             m_remoteResourceCache.cacheNativeImage(makeRef(*image));
    272     }
     282    auto bitmap = ShareableBitmap::create(handle);
     283    if (!bitmap)
     284        return;
     285
     286    auto image = NativeImage::create(bitmap->createPlatformImage(), renderingResourceIdentifier);
     287    if (!image)
     288        return;
     289
     290    m_remoteResourceCache.cacheNativeImage(makeRef(*image));
     291
     292    if (m_pendingWakeupInfo && m_pendingWakeupInfo->shouldPerformWakeup(renderingResourceIdentifier))
     293        wakeUpAndApplyDisplayList(std::exchange(m_pendingWakeupInfo, WTF::nullopt)->arguments);
    273294}
    274295
     
    289310        m_sharedDisplayListHandles.set(identifier, DisplayListReaderHandle::create(identifier, sharedMemory.releaseNonNull()));
    290311
    291     if (m_pendingWakeupArguments && m_pendingWakeupArguments->itemBufferIdentifier == identifier)
    292         wakeUpAndApplyDisplayList(*std::exchange(m_pendingWakeupArguments, WTF::nullopt));
     312    if (m_pendingWakeupInfo && m_pendingWakeupInfo->shouldPerformWakeup(identifier))
     313        wakeUpAndApplyDisplayList(std::exchange(m_pendingWakeupInfo, WTF::nullopt)->arguments);
    293314}
    294315
  • trunk/Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h

    r270564 r270591  
    114114    void didCreateSharedDisplayListHandle(WebCore::DisplayList::ItemBufferIdentifier, const SharedMemory::IPCHandle&, WebCore::RenderingResourceIdentifier destinationBufferIdentifier);
    115115
     116    struct PendingWakeupInformation {
     117        GPUProcessWakeupMessageArguments arguments;
     118        Optional<WebCore::RenderingResourceIdentifier> missingCachedResourceIdentifier;
     119
     120        bool shouldPerformWakeup(WebCore::RenderingResourceIdentifier identifier) const
     121        {
     122            return arguments.destinationImageBufferIdentifier == identifier
     123                || missingCachedResourceIdentifier == identifier;
     124        }
     125
     126        bool shouldPerformWakeup(WebCore::DisplayList::ItemBufferIdentifier identifier) const
     127        {
     128            return arguments.itemBufferIdentifier == identifier;
     129        }
     130    };
     131
    116132    RemoteResourceCache m_remoteResourceCache;
    117133    WeakPtr<GPUConnectionToWebProcess> m_gpuConnectionToWebProcess;
    118134    RenderingBackendIdentifier m_renderingBackendIdentifier;
    119135    HashMap<WebCore::DisplayList::ItemBufferIdentifier, RefPtr<DisplayListReaderHandle>> m_sharedDisplayListHandles;
    120     Optional<GPUProcessWakeupMessageArguments> m_pendingWakeupArguments;
     136    Optional<PendingWakeupInformation> m_pendingWakeupInfo;
    121137};
    122138
Note: See TracChangeset for help on using the changeset viewer.