Truly independent web browser
LibWeb: Stop animations of which only the first frame is used
Andreas Klinga5b84905514a
diff --git a/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Libraries/LibWeb/HTML/HTMLLinkElement.cppindex 98f49854daf..bc73b665017 100644--- a/Libraries/LibWeb/HTML/HTMLLinkElement.cpp+++ b/Libraries/LibWeb/HTML/HTMLLinkElement.cpp@@ -1419,6 +1419,9 @@ static NonnullRefPtr<Core::Promise<NonnullRefPtr<Gfx::Bitmap const>>> decode_fav};auto on_successful_decode = [document = GC::Root(document), promise](Web::Platform::DecodedImage& decoded_image) -> ErrorOr<void> {+ // NB: Only the first frame is used, so an animation the decoder opened is stopped right away.+ if (decoded_image.session_id != 0)+ Platform::ImageCodecPlugin::the().stop_animation_decode(decoded_image.session_id);auto favicon_bitmap = decoded_image.frames[0].bitmap;dbgln_if(IMAGE_DECODER_DEBUG, "Decoded favicon, {}", favicon_bitmap->size());diff --git a/Libraries/LibWeb/HTML/HTMLVideoElement.cpp b/Libraries/LibWeb/HTML/HTMLVideoElement.cppindex 1cc7153f562..a55ae405009 100644--- a/Libraries/LibWeb/HTML/HTMLVideoElement.cpp+++ b/Libraries/LibWeb/HTML/HTMLVideoElement.cpp@@ -338,6 +338,9 @@ WebIDL::ExceptionOr<void> HTMLVideoElement::determine_element_poster_frame(Optio(void)Platform::ImageCodecPlugin::the().decode_image(image_data,[weak_self, poster_url](Web::Platform::DecodedImage& image) -> ErrorOr<void> {+ // NB: Only the first frame is used, so an animation the decoder opened is stopped right away.+ if (image.session_id != 0)+ Platform::ImageCodecPlugin::the().stop_animation_decode(image.session_id);if (!weak_self)return {};RefPtr<Gfx::Bitmap> poster_frame;diff --git a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cppindex 385e3f84f84..c8d838b1f35 100644--- a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp+++ b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp@@ -611,6 +611,9 @@ void WindowOrWorkerGlobalScopeMixin::create_image_bitmap_impl(JS::Realm& realm,};auto on_successful_decode = [p = GC::Root(*p), sx, sy, sw, sh, options](Web::Platform::DecodedImage& result) -> ErrorOr<void> {+ // NB: Only the first frame is used, so an animation the decoder opened is stopped right away.+ if (result.session_id != 0)+ Web::Platform::ImageCodecPlugin::the().stop_animation_decode(result.session_id);if (Core::StatsLog::the())end_rendering_pending_operation(GC::as_cell(p.ptr()));// 4. Set imageBitmap's bitmap data to imageData, cropped to the source rectangle with formatting.diff --git a/Libraries/LibWeb/NotificationsAPI/Notification.cpp b/Libraries/LibWeb/NotificationsAPI/Notification.cppindex 662adecdba4..8a529a8fa90 100644--- a/Libraries/LibWeb/NotificationsAPI/Notification.cpp+++ b/Libraries/LibWeb/NotificationsAPI/Notification.cpp@@ -420,6 +420,9 @@ void Notification::fetch_a_notification_resource(URL::URL const& url, GC::Ref<GC// resource to are rooted for the wait: Nothing else holds the step once the fetch is over. An answer for a// notification that's gone in the meantime is dropped.auto on_decoded = [self = GC::Root(*this), process_resource = GC::Root(*process_resource)](Platform::DecodedImage& decoded_image) -> ErrorOr<void> {+ // NB: Only the first frame is used, so an animation the decoder opened is stopped right away.+ if (decoded_image.session_id != 0)+ Platform::ImageCodecPlugin::the().stop_animation_decode(decoded_image.session_id);if (self->m_state != State::Pending)return {};auto* this_notification = self.ptr();