mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
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:
committed by
Alexander Kalenik
parent
a7b70b0042
commit
b49c243abd
Notes:
github-actions[bot]
2026-03-03 13:13:51 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/b49c243abd8 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8237 Reviewed-by: https://github.com/gmta
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
// Test that changing img.src to a valid image while a previous invalid src is still
|
||||
// being decoded works correctly. The stale failure callback from the first (invalid)
|
||||
// src must not corrupt the state of the second (valid) image request.
|
||||
asyncTest((done) => {
|
||||
let img = document.createElement("img");
|
||||
document.body.appendChild(img);
|
||||
|
||||
// Set src to data that will fail to decode (not valid image data).
|
||||
img.src = "data:image/png;base64,dGhpcyBpcyBub3QgYW4gaW1hZ2U=";
|
||||
|
||||
// After a task boundary, the microtask for the first src will have run and
|
||||
// started the decode via ImageDecoder. Change src to a valid 1x1 red PNG.
|
||||
setTimeout(() => {
|
||||
img.onload = () => {
|
||||
println(`naturalWidth: ${img.naturalWidth}`);
|
||||
println(`naturalHeight: ${img.naturalHeight}`);
|
||||
done();
|
||||
};
|
||||
img.onerror = () => {
|
||||
println("FAIL: error event fired for valid image");
|
||||
done();
|
||||
};
|
||||
img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwADhQGAWjR9awAAAABJRU5ErkJggg==";
|
||||
}, 0);
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user