mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +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:
committed by
Andreas Kling
parent
9f1a853cc8
commit
166e603c5e
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user