[webkit-changes] [WebKit/WebKit] 22ed0b: [CG] An Image with video source may allocate too m...

Said Abou-Hallawa noreply at github.com
Tue Jun 11 15:14:57 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 22ed0bf86c1fb602cdc5de10b52eeb377fde7329
      https://github.com/WebKit/WebKit/commit/22ed0bf86c1fb602cdc5de10b52eeb377fde7329
  Author: Said Abou-Hallawa <said at apple.com>
  Date:   2024-06-11 (Tue, 11 Jun 2024)

  Changed paths:
    M Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h
    M Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm

  Log Message:
  -----------
  [CG] An Image with video source may allocate too much memory for caching all the video frames
https://bugs.webkit.org/show_bug.cgi?id=275331
rdar://126993116

Reviewed by Jer Noble.

Both BitmapImageSource and ImageDecoderAVFObjC cache the decoded frames. When
deleting the decoded frames, BitmapImageSource::destroyDecodedData() calls
ImageDecoderAVFObjC::clearFrameBufferCache() to let it release any unnecessary
cached data. But BitmapImageSource does not communicate what frames it actually
released. So the caches in BitmapImageSource and ImageDecoderAVFObjC can get of
sync. And ImageDecoderAVFObjC may end up holding many decoded frames which
BitmapImageSource does not need.

BitmapImageSource will ask ImageDecoderAVFObjC to re-decode any frame when it is
needed. BitmapImageSource should not use too much memory for caching the decoded
frames. ImageDecoderAVFObjC should cache only what is needed to decode the next
frame. BitmapImageSource will always ask ImageDecoderAVFObjC to decode frames
in order.

The fix is to make ImageDecoderAVFObjC not cache any decoded frame and let
BitmapImageSource be responsible for this.

* Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h:
* Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm:
(WebCore::ImageDecoderAVFObjCSample::setAlpha):
(WebCore::ImageDecoderAVFObjC::createFrameImageFromSampleBuffer):
(WebCore::ImageDecoderAVFObjC::createFrameImageAtIndex):
(WebCore::ImageDecoderAVFObjCSample::image const): Deleted.
(WebCore::ImageDecoderAVFObjCSample::setImage): Deleted.
(WebCore::ImageDecoderAVFObjC::storeSampleBuffer): Deleted.
(WebCore::ImageDecoderAVFObjC::clearFrameBufferCache): Deleted.

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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list