| Summary: | Img rendering skips multiple frames resulting white flash | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Roland Soos <roland> |
| Component: | Layout and Rendering | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW --- | ||
| Severity: | Normal | CC: | bfulgham, sabouhallawa, simon.fraser, webkit-bug-importer, zalan |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari 14 | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
|
Description
Roland Soos
2021-05-25 06:06:50 PDT
I tried to use image.decode() API, event with
image.decode().then(function(){
requestAnimationFrame(function(){
hideLastImage();
showNextImage();
});
});
But it produced the same behavior as the original code.
(In reply to Roland Soos from comment #1) > I tried to use image.decode() API, event with > image.decode().then(function(){ > requestAnimationFrame(function(){ > hideLastImage(); > showNextImage(); > }); > }); > > But it produced the same behavior as the original code. Why do you need to call hideLastImage() before calling showNextImage()? Hiding the image might be the cause of this flickering. I think something like this should work: var image = new Image; image.src = "images/imageslider-background.jpg"; image.decode().then(() => { document.querySelector("imageslider").src = image.src; }); Also your test case has the following markup for the <img> elements: <img src="images/imageslider-background2.jpg" alt="" title="" loading="lazy" class="skip-lazy" data-skip-lazy="1"> Is there a reason for adding the loading="lazy"? Said Abou-Hallawa: That example was only just a theory. Yes, I can do the following:
image.decode().then(function(){
requestAnimationFrame(function(){
showNextImage();
setTimeout(hideLastImage, 500);
});
});
Poetical question: What is the right timeout to hide the last image to avoid white area? -> The image.decode() promise should indicate when an image can be rendered and when fulfilled we want that image to show in the next frame, right? Or else I can accept if that promise get fulfilled later when the image ready to render. It is not acceptable to get an empty area for a few frame when the promise fulfilled. This is how the specs describe it: https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element:dom-animationframeprovider-requestanimationframe
That loading="lazy" attribute gets changed by JavaScript to "eager". Also I can see on my testcase in the network tab that the next image loaded, also the image.decode() promise is fulfilled and still there is a white flash which shouldn't.
|