test: wait for lazy loaded images before taking visual test screenshots - #6656
Merged
Conversation
The mediapool thumbnail uses `loading="lazy"`, and lazy images do not delay the load event the recorder navigates with. The media manager has to generate the image on the first request, so it was a race whether it made it into the screenshot — which kept flip-flopping the golden sample.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The mediapool thumbnail in
mediapool/pages/media.list.phpis rendered withloading="lazy"— and lazy images do not delay the load event, which is what the recorder navigates with (waitUntil: 'load'). The image itself comes from the media manager and has to be generated on the first request, so whether it made it into the screenshot was a race.That is what keeps rewriting
mediapool_media.png, e.g. in #6655: one commit sets light + dark to "no thumbnail", the next one puts dark back, the one after that light. Light and dark are taken from a single page load one after the other, so the image simply arrived in between. SinceMIN_DIFF_PIXELS = 1commits any pixel difference as the new golden sample, the auto-commit then retriggers the workflow and it keeps swinging.Reproduced in isolation with a deliberately slow image response:
The fix
Before each screenshot, all images are switched to eager and awaited:
loading = 'eager'is what gets a lazy image to load at all — afullPagescreenshot doesn't scroll it into view either, so images below the fold would never have loaded.waitForFunctionwaits with a real timeout, so a permanently stuck image fails the action instead of hanging it for 30 minutes.decode()closes the remaining gap between "loaded" and "decoded for the next paint".loading="lazy"appears in exactly those two thumbnail lines in the whole backend, so nothing else is affected.The first run with this may still commit a golden sample once — namely if the current one happens to be stuck in a "no thumbnail" state. That's the last correction, not the next swing.
Noticed on
6.x, where the media manager rebuild (#6566) makes generating the image slow enough for the race to tip the wrong way more often. The cause is the same here, so this is meant to be merged up.