Skip to content

Commit

Permalink
Don't call deferNonVisibleProcessEarlyMemoryCleanupTimer from worker …
Browse files Browse the repository at this point in the history
…threads

https://bugs.webkit.org/show_bug.cgi?id=259170
rdar://110910174

Reviewed by Simon Fraser.

We call deferNonVisibleProcessEarlyMemoryCleanupTimer in
RemoteResourceCacheProxy::recordNativeImageUse. The idea there is to
avoid discarding decoded image data in background tabs if the background
tab is drawing images, which might be some canvas work, or it could be
other things like Safari taking a tab snapshot. If we didn't avoid this,
we could thrash between discarding decoded data and redecoding.

OffscreenCanvas can also draw images on worker threads, but
deferNonVisibleProcessEarlyMemoryCleanupTimer is not safe to call from
non-main threads. We can safely skip this call if we're not on the main
thread: workers do not have access to images which are stored in the
MemoryCache, so we are not at risk of discarding decoded image data that
the worker will want to re-decode to draw.

* Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp:
(WebKit::RemoteResourceCacheProxy::recordNativeImageUse):

Canonical link: https://commits.webkit.org/266024@main
  • Loading branch information
heycam committed Jul 13, 2023
1 parent da4d5fa commit 1ace3d3
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ void RemoteResourceCacheProxy::recordFilterUse(Filter& filter)

void RemoteResourceCacheProxy::recordNativeImageUse(NativeImage& image)
{
WebProcess::singleton().deferNonVisibleProcessEarlyMemoryCleanupTimer();
if (isMainRunLoop())
WebProcess::singleton().deferNonVisibleProcessEarlyMemoryCleanupTimer();

if (cachedNativeImage(image.renderingResourceIdentifier()))
return;
Expand Down

0 comments on commit 1ace3d3

Please sign in to comment.