Closed Bug 1580820 Opened 5 years ago Closed 5 years ago

CSS variable in background-image produces a new server request every time background-position changes

Categories

(Core :: Graphics: ImageLib, defect, P2)

68 Branch
Unspecified
All
defect

Tracking

()

VERIFIED FIXED
mozilla71
Tracking Status
firefox-esr60 --- unaffected
firefox-esr68 --- verified
firefox69 --- wontfix
firefox70 --- verified
firefox71 --- verified

People

(Reporter: stephen.cantini, Assigned: tnikkel)

References

(Regression)

Details

(Keywords: regression)

Attachments

(3 files)

Attached file bug.zip

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0

Steps to reproduce:

  1. Upload the attached files to a webserver (localhost or somewhere else). I've put them online temporarily here: http://tranquilainquietud.com/stephen/bug.html
  2. Open the "bug.html" page (not with file:// protocol), open the dev console. Move the pointer over the two images to see the hover effect.
  3. Reload the page with F5 or by clicking on the reload icon, one or more times. Move the pointer again over the two images.
  4. Shift-Reload the page and check again.

Actual results:

The upper image flickers, because it is downloaded from the server again and again, every time its background-position is changed by moving the pointer over it (see the network tab). The lower image (which has it's background-image forced directly bypassing CSS variables) works fine.

Expected results:

The upper image should behave like the lower one: it should not generate new server requests, independently of the first request cache headers (it works ok in Chrome). It looks like a background-image specified with CSS variables disables caching and forces a resource reload, even if the variable value is constant.

NOTE: The unwanted behavior happens after reloading the page one or more times with F5 or by clicking on the reload icon. Sometimes one reload is not sufficient.

I was able to reproduce this issue for latest Nightly version 71.0a1 Build ID 20190916093313 using Ubuntu 18.04, Windows 10 as well as mac os 10.14.

Affected platforms:
Ubuntu 18.04
Windows 10
Mac OS 10.14

The upper image flickers after update the page. Browser console shows this message:

[Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIContentSniffer.getMIMETypeFromContent]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: resource:///modules/FaviconLoader.jsm :: onStopRequest :: line 277" data: no] FaviconLoader.jsm:277:24
onStopRequest resource:///modules/FaviconLoader.jsm:277
AsyncFunctionNext self-hosted:839

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

It is really weird that this happens only after a reload, but I can repro. Also shouldn't really happen in the first place... Maybe a regression?

Component: Layout: Images, Video, and HTML Frames → CSS Parsing and Computation
Flags: needinfo?(emilio)
Priority: -- → P3

Regression window:
https://hg.mozilla.org/integration/mozilla-inbound/pushloghtml?fromchange=39c8abcf9cb2f40b78289a5535fe550368302423&tochange=fdbb1ad695392bc5e5e00200013dee7c98a54967

Regressed by: 135eaacf1dfc66c289367a665473e67a650407b9 Andrea Marchesini — Bug 1495738 - Image cache entry should compare the window ID together with the loadID because the loadID can be a reused pointer, r=aosmond

Has Regression Range: --- → yes
Has STR: --- → yes
Component: CSS Parsing and Computation → ImageLib
OS: Unspecified → All
Regressed by: 1495738

The component has been changed since the backlog priority was decided, so we're resetting it.
For more information, please visit auto_nag documentation.

Priority: P3 → --

Thanks for the testcase, I believe I have found the problem. I'll verify and hopefully post a patch later today.

Ah, cool, thanks Tim.

Flags: needinfo?(emilio)

If we just update the document pointer and not the inner window id then the request is unusable by any document since both the inner window id and the document pointer must match for it to be re-usable.

Assignee: nobody → tnikkel
Priority: -- → P2

I'll try to come up with a test for this.

Pushed by tnikkel@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a3224ec885eb Update the inner window id as well as the context (document) pointer on an imgRequest if we validate it for that document/inner window id. r=aosmond
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla71

Comment on attachment 9093217 [details]
Bug 1580820. Update the inner window id as well as the context (document) pointer on an imgRequest if we validate it for that document/inner window id. r?aosmond

ESR Uplift Approval Request

  • If this is not a sec:{high,crit} bug, please state case for ESR consideration: basic cached image functionality was regressed
  • User impact if declined: images not using cached version causing flickers
  • Fix Landed on Version: 71
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): just applies the same logic to the innerwindowid as we have been doing for ages to the document pointer
  • String or UUID changes made by this patch:

Beta/Release Uplift Approval Request

  • User impact if declined: images not using cached version causing flickers
  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): just applies the same logic to the innerwindowid as we have been doing for ages to the document pointer
  • String changes made/needed:
Attachment #9093217 - Flags: approval-mozilla-esr68?
Attachment #9093217 - Flags: approval-mozilla-beta?

Comment on attachment 9093217 [details]
Bug 1580820. Update the inner window id as well as the context (document) pointer on an imgRequest if we validate it for that document/inner window id. r?aosmond

Fixes a caching bug causing image flicker. Approved for 70.0b8 and 68.2esr.

Attachment #9093217 - Flags: approval-mozilla-esr68?
Attachment #9093217 - Flags: approval-mozilla-esr68+
Attachment #9093217 - Flags: approval-mozilla-beta?
Attachment #9093217 - Flags: approval-mozilla-beta+
QA Whiteboard: [qa-triaged]

I have managed to reproduce this issue using Firefox 71.0a1 (BuildId:20190912215412) on Windows 10 64bit.

This issue is verified fixed using Firefox 71.0a1 (BuildId:20190918215055) and Firefox 70.0b8 (provided in comment 16) on Windows 10 64bit, macOS 10.13.6 and Ubuntu 18.04 64bit.

Status: RESOLVED → VERIFIED
Flags: qe-verify+

Leaving a ni? on myself to verify this on esr as well (once it lands).

Flags: needinfo?(emil.ghitta)

This needs a rebased patch for ESR68.

Flags: needinfo?(tnikkel)
Attached patch patch for esrSplinter Review
Flags: needinfo?(tnikkel) → needinfo?(ryanvm)
Flags: needinfo?(ryanvm)

This issue is verified fixed using Firefox 68.2.0esr (provided in comment 21) on Windows 10 64bit, macOS 10.13.6 and Ubuntu 18.04 64bit.

Flags: needinfo?(emil.ghitta)
Regressions: 1755032
Regressions: 1756551
No longer duplicate of this bug: 1581268
Duplicate of this bug: 1581268
See Also: → 1832528
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: