Closed Bug 1589955 Opened 6 years ago Closed 6 years ago

Javascript image change cause stretching glitch before CSS is honored

Categories

(Core :: Layout: Images, Video, and HTML Frames, defect, P2)

69 Branch
Desktop
All
defect

Tracking

()

VERIFIED FIXED
mozilla72
Tracking Status
firefox-esr60 --- unaffected
firefox-esr68 --- wontfix
firefox67 --- unaffected
firefox68 --- wontfix
firefox69 --- wontfix
firefox70 --- wontfix
firefox71 --- wontfix
firefox72 --- verified
firefox73 --- verified

People

(Reporter: vdeconinck, Assigned: emilio)

References

(Regressed 1 open bug, Regression)

Details

(Keywords: regression)

Attachments

(2 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0

Steps to reproduce:

Open sample page at http://vdeconinck.synology.me/ffx_bug/ and wait for the slideshow to switch images.

Actual results:

There is a visible glitch when an image is first shown : it is resized to fit the frame of the previous image (even if it has a different aspect ratio) before CSS is honored and image is shown with its original image aspect ratio.

Expected results:

New image should immediately be displayed with the CSS applied.
NB: Chrome behaviour is ok.

Note : the symptoms are similar to bug 953364 but this one is obviously not fixed. Feel free to mark this as a dupe and reopen the original one if the root cause is identical...

Component: Untriaged → Layout
Product: Firefox → Core

Thanks for filing!

I wonder if it's a regression...

Status: UNCONFIRMED → NEW
Component: Layout → Layout: Images, Video, and HTML Frames
Ever confirmed: true

Bugbug thinks this bug is a regression, but please revert this change in case of error.

Keywords: regression

Sorry bugbug, we don't know yet.

Keywords: regression
Attached file Testcase #1

Here's a somewhat reduced testcase based on the Reporter's testcase.

Fwiw, the flicker also occurs with display: flex instead of display: grid.

I see it also with display: block, I'm moderately sure this shouldn't be grid/flex-related.

So I think I know what happens, and I'm ~sure this was regressed by bug 1395964 (though it'd be good to confirm).

What is going on is, I think:

  • src changes.
  • We get enough metadata about the new image to figure out the right aspect-ratio / size of the image, but haven't decoded it yet.
  • We do layout with the new image's dimensions.
  • We go to paint, try to decode the image, but it's not fully ready yet, so in order to prevent flashing, we paint the previous image.
  • Normally this is fine since the images have similar aspect ratios, but in this case it's bad.

As far as I understand, other browsers sync-decode by default.

So, options in this case, I think, could be something like, if we have both mImage and mPrevImage, and their ratios are quite different (how much, though?), and the image is sized intrinsically (the frame size is dependent on the image intrinsic size / ratio), either:

  • Sync-decode, to prevent flashing, or...
  • Don't paint mPrevImage (we'd flash white).

Tim, thougts / better ideas? Maybe I'm completely off? :)

Flags: needinfo?(tnikkel)
See Also: → 1395964
Regressed by: 1395964

Thanks so much Alice :)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #7)

So, options in this case, I think, could be something like, if we have both mImage and mPrevImage, and their ratios are quite different (how much, though?), and the image is sized intrinsically (the frame size is dependent on the image intrinsic size / ratio), either:

  • Sync-decode, to prevent flashing, or...
  • Don't paint mPrevImage (we'd flash white).

Tim, thougts / better ideas? Maybe I'm completely off? :)

Thanks for this explanation.

I would be fine with sync-decoding if the image size or ratio changed at all (even by a small amount) and the frame size was dependent on that.

Flags: needinfo?(tnikkel)

I confirm the regression range found in comment 8. Also, I've set the flags and platform.

OS: Unspecified → All
Hardware: Unspecified → Desktop

Alright, will give that a shot, when I get to it.

Flags: needinfo?(emilio)
Priority: -- → P2

This seems to fix it for me, and it's pretty straight-forward, but I think
we'd still paint the old image if the image is huge and it's loading, which
may be counter-productive. Maybe we should guard the whole "paint mOldImage"
with and if (!oldImageIsDifferent), wdyt?

Assignee: nobody → emilio
Flags: needinfo?(emilio)

Change the status for beta to have the same as nightly and release.
For more information, please visit auto_nag documentation.

Attachment #9103253 - Attachment description: Bug 1589955 - Sync-decode images when intrinsic ratio between the old and new source changes. r=tnikkel → Bug 1589955 - Sync-decode images when intrinsic ratio between the old and new source changes.
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/37538ab48bab Sync-decode images when intrinsic ratio between the old and new source changes. r=tnikkel
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla72

Regression in Firefox 54 and not a P1, this can ride the 72 train, wontfix 71.

Flags: qe-verify+

I have verified this fix on Nightly v73.0a1 and Beta v72.0b67 on Windows 10 and Mac OS 10.13.6 after reproducing it in Firefox v71.0.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
Regressions: 1680196
Has Regression Range: --- → yes
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: