mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-05 01:42:54 +00:00
ImageDecoder: Pass decoded images as Gfx::Bitmap over IPC
Before this change, we were passing them as Gfx::ShareableBitmap. The problem is that shareable bitmaps keep their underlying file descriptor open, so that they can be shared again with someone else. When a Gfx::Bitmap is decoded from an IPC message, the file descriptor is closed and recovered immediately. This fixes an issue where we'd accumulate one file descriptor for every image decoded. This eventually led to descriptor starvation after enough images were loaded and still referenced at the same time.
This commit is contained in:
parent
9f1a853cc8
commit
166e603c5e
Notes:
sideshowbarker
2024-07-18 23:47:04 +09:00
Author: https://github.com/awesomekling
Commit: 166e603c5e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/688
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/tcl3
5 changed files with 9 additions and 9 deletions
|
@ -75,16 +75,16 @@ Messages::ImageDecoderServer::ConnectNewClientsResponse ConnectionFromClient::co
|
|||
return files;
|
||||
}
|
||||
|
||||
static void decode_image_to_bitmaps_and_durations_with_decoder(Gfx::ImageDecoder const& decoder, Optional<Gfx::IntSize> ideal_size, Vector<Gfx::ShareableBitmap>& bitmaps, Vector<u32>& durations)
|
||||
static void decode_image_to_bitmaps_and_durations_with_decoder(Gfx::ImageDecoder const& decoder, Optional<Gfx::IntSize> ideal_size, Vector<Optional<NonnullRefPtr<Gfx::Bitmap>>>& bitmaps, Vector<u32>& durations)
|
||||
{
|
||||
for (size_t i = 0; i < decoder.frame_count(); ++i) {
|
||||
auto frame_or_error = decoder.frame(i, ideal_size);
|
||||
if (frame_or_error.is_error()) {
|
||||
bitmaps.append(Gfx::ShareableBitmap {});
|
||||
bitmaps.append({});
|
||||
durations.append(0);
|
||||
} else {
|
||||
auto frame = frame_or_error.release_value();
|
||||
bitmaps.append(frame.image->to_shareable_bitmap());
|
||||
bitmaps.append(frame.image.release_nonnull());
|
||||
durations.append(frame.duration);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue