Repository navigation
Conversation
https://bugs.webkit.org/show_bug.cgi?id=308730 Reviewed by NOBODY (OOPS!). Each BitmapImageSource that decoded asynchronously created its own WorkQueue. That queue ran one work item that looped on a blocking SynchronizedFixedQueue::dequeue() until stop(). The queue is stopped only when it is idle and the image is static or its animation has stopped. So every animating image, and every removed image with a pending frame request, held a thread that waited for future frames. With many animated images, these waiting workers accumulate until later images can no longer be decoded and the page stops rendering new frames. AVIF decoding also uses GCD internally. Allowing an unbounded number of image decodes can exhaust the available GCD worker threads when the platform decoder dispatches its own work, preventing decoding from making progress. Bound concurrent image decoding as well as eliminating workers that wait for future frame requests. Replace the long-running loop with one finite work item per decode request: - Requests for a single image still run serially, including across stop() and restart. - A shared scheduler runs ready images on at most 8 reusable WorkQueue workers, giving other ready images a turn between frames. An empty image queue never keeps a worker waiting, and queue pressure never turns into unbounded concurrent decodes. - stop() increments a generation counter. Stale requests skip decoding, and their completions are ignored. A completion is still posted to the creation thread, so the source and the work queue are released there. - ImageFrameWorkQueue keeps the decoder between requests until stop(), as the old loop did. - The minimum decoding duration for testing is captured at dispatch time instead of being read on the decoding thread. Also, when pruning decoded data, keep an already decoded next frame while the animation timer is pending. Otherwise the frame would be decoded synchronously when the timer fires. Keep the decoder while decoded frames are still in use. Tests: fast/images/async-image-decoding-concurrent-images.html fast/images/async-image-decoding-removed-images.html * LayoutTests/TestExpectations: * LayoutTests/fast/images/async-image-decoding-concurrent-images-expected.txt: Added. * LayoutTests/fast/images/async-image-decoding-concurrent-images.html: Added. * LayoutTests/fast/images/async-image-decoding-removed-images-expected.txt: Added. * LayoutTests/fast/images/async-image-decoding-removed-images.html: Added. * Source/WebCore/platform/graphics/BitmapImageSource.cpp: (WebCore::BitmapImageSource::destroyDecodedFrames): (WebCore::BitmapImageSource::destroyDecodedData): * Source/WebCore/platform/graphics/ImageFrameAnimator.h: (WebCore::ImageFrameAnimator::nextFrameIndex const): * Source/WebCore/platform/graphics/ImageFrameWorkQueue.cpp: (WebCore::ImageDecodingQueue::create): (WebCore::ImageDecodingQueue::WTF_GUARDED_BY_LOCK): (WebCore::ImageDecodingScheduler::singleton): (WebCore::ImageDecodingScheduler::dispatch): (WebCore::ImageDecodingScheduler::WTF_GUARDED_BY_LOCK): (WebCore::ImageDecodingQueue::dispatch): (WebCore::ImageDecodingQueue::runOneRequest): (WebCore::ImageFrameWorkQueue::ImageFrameWorkQueue): (WebCore::ImageFrameWorkQueue::dispatch): (WebCore::ImageFrameWorkQueue::stop): (WebCore::ImageFrameWorkQueue::requestQueue): Deleted. (WebCore::ImageFrameWorkQueue::start): Deleted. * Source/WebCore/platform/graphics/ImageFrameWorkQueue.h: (WebCore::ImageFrameWorkQueue::minimumDecodingDurationForTesting const): Deleted.
Collaborator
|
EWS run on current version of this PR (hash 489ea5e) Details |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🧪 win-tests
489ea5e
489ea5e
🛠 playstation