LibWeb: Fix stale image request callbacks corrupting newer requests

When img.src is changed rapidly (e.g., YouTube Music sets a GIF
placeholder then swaps to a real URL via IntersectionObserver), the
failure callback from the stale first request could corrupt the newer
request by calling abort_the_image_request on the now-reassigned
m_current_request.

Fix this by using the existing m_update_the_image_data_count generation
counter to detect stale fetch callbacks.

This fixes thumbnail loading on YouTube Music.
This commit is contained in:
Aliaksandr Kalenik
2026-03-01 10:25:37 +01:00
committed by Alexander Kalenik
parent a7b70b0042
commit b49c243abd
Notes: github-actions[bot] 2026-03-03 13:13:51 +00:00
4 changed files with 51 additions and 6 deletions

View File

@@ -144,7 +144,7 @@ private:
void handle_successful_fetch(URL::URL const&, StringView mime_type, ImageRequest&, ByteBuffer, bool maybe_omit_events, URL::URL const& previous_url);
void handle_failed_fetch();
void add_callbacks_to_image_request(GC::Ref<ImageRequest>, bool maybe_omit_events, String const& url_string, String const& previous_url);
void add_callbacks_to_image_request(GC::Ref<ImageRequest>, bool maybe_omit_events, String const& url_string, String const& previous_url, u64 update_the_image_data_count);
void animate();