Fixes #4628 Remove decoding attribute and triggering a layout reflow to fix rendering issues on WebKit #8073
Open
Jeroen-1978 wants to merge 5 commits intowp-media:developfrom
Open
Conversation
Remove 'decoding' attribute to prevent render stalls and force browser repaint for images.
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request addresses Safari iOS rendering issues where lazy-loaded images below the fold fail to display, even though the DOM shows the image replacement is functioning correctly. The fix implements two changes to the lazyload library (version 17.8.3): removing the decoding="async" attribute before setting image sources, and forcing a browser repaint after programmatic source changes.
Changes:
- Removes
decodingattribute insetSourcesImg()before setting image attributes to prevent render stalls - Adds repaint logic in
loadHandler()that removesdecoding, toggles display style, and triggers reflow for IMG elements
Replace image display manipulation with opacity transition to avoid forced synchronous layout (layout thrashing).
The detection is now as follows: |Browser|isWebKit|Reason| |-----|------|-------| |Safari macOS|true|Contains AppleWebKit, no Chrome| |Safari iOS|true|Contains AppleWebKit, no Chrome| |Chrome iOS|true|Contains AppleWebKit + CriOS (not Chrome) — actually uses WebKit| |Firefox iOS|true|Contains AppleWebKit + FxiOS — actually uses WebKit| |Edge iOS|true|Contains AppleWebKit + EdgiOS — actually uses WebKit| |Chrome desktop|false|Contains Chrome in UA (Blink engine)| |Edge|desktop|false|Contains Chrome in UA (Blink engine)| |Firefox desktop|false|Does not contain AppleWebKit (Gecko engine)|
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.
Description
Fixes #4628
This pull request introduces targeted fixes to the lazy loading behavior for images, addressing rendering stalls and repaint issues. The main changes focus on improving image loading reliability and ensuring images are properly displayed after their sources are set.
This is a known WebKit compositing/rendering behavior where programmatic attribute changes on elements that were initially decoded asynchronously do not always trigger a paint update.
Type of change
Detailed scenario
What was tested
As described in Issue.
To make sure this is realy a WebKit problem I tested several Browsers on several platforms. All using the most recent version available.
Browsers & platforms tested
Note: On iOS, all browsers are required by Apple to use WebKit as their underlying engine (WKWebView). This means Chrome, Firefox, and Edge on iOS are all affected, confirming that the root cause is WebKit itself, not a browser-specific issue.
How to test
As described in Issue.
Technical description
Documentation
Rendering and repaint improvements:
decoding="async"attribute from images before setting their sources to prevent rendering stalls during lazy loading.New dependencies
None.
Risks
None.
Mandatory Checklist
Code validation
Code style
Unticked items justification
None
Additional Checks