Bug 275331
Summary: | [CG] An Image with video source may allocate too much memory for caching all the video frames | ||
---|---|---|---|
Product: | WebKit | Reporter: | Said Abou-Hallawa <sabouhallawa> |
Component: | Images | Assignee: | Said Abou-Hallawa <sabouhallawa> |
Status: | REOPENED | ||
Severity: | Normal | CC: | commit-queue, sabouhallawa, webkit-bug-importer |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Bug Depends on: | 276319 | ||
Bug Blocks: |
Said Abou-Hallawa
If a video has at least hundreds of frames and the size of each frame is large, one image like this <img src="video.mp4"> may allocate multiple of gigabytes.
ImageDecoderAVFObjC::createFrameImageAtIndex() decodes a frame of the video and returns a CGImage for this frame. But it caches the returned CGImage also to avoid decoding it multiple times. Unfortunately this is not how decoding the animated image works.
BitmapImageSource manages the cache of the decoded frames and under memory pressure BitmapImageSource::destroyDecodedData() releases all frames which it does not need to render the current frame.
BitmapImageSource::destroyDecodedData() calls also ImageDecoderAVFObjC::clearFrameBufferCache() to let it release any cached data. But the caches in BitmapImageSource and ImageDecoderAVFObjC can get of sync because BitmapImageSource does not communicate what frames it actually released. So ImageDecoderAVFObjC may end up holding many CGImages BitmapImageSource does not know anything about.
ImageDecoderAVFObjC should not cache any decoded frame. ImageDecoderAVFObjC::clearFrameBufferCache() should be just an empty function.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Said Abou-Hallawa
rdar://126993116
Said Abou-Hallawa
Pull request: https://github.com/WebKit/WebKit/pull/29688
EWS
Committed 279926@main (22ed0bf86c1f): <https://commits.webkit.org/279926@main>
Reviewed commits have been landed. Closing PR #29688 and removing active labels.
WebKit Commit Bot
Re-opened since this is blocked by bug 276319