Closed Bug 1740211 Opened 3 years ago Closed 2 years ago

Firefox preloads resources that don't match the media attribute

Categories

(Core :: DOM: Core & HTML, defect)

Firefox 96
x86_64
Linux
defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: seth, Unassigned)

References

(Blocks 1 open bug)

Details

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

Steps to reproduce:

Run the following repo:
https://github.com/SethFalco/firefox-bug-question-mark

I'm also an adapted version for GitHub Pages here:
https://sethfalco.github.io/Firefox/

  • Contains 3 link elements that preload in the head at various media queries.
  • Contains a picture with 3 source elements that match the link elements in the head and 1 img element.

To reproduce:

  1. Open a new private browser.
  2. Open inspect element and responsive design mode before visiting the website.
  3. Set the size to iPad Mini or 768x1024
  4. Access the website for the first time
  5. Observe that it preloads more than it should
  6. Refresh
  7. Observe that it behaves as expected

Actual results:

The first time the site is visited, it preloads images that aren't matched by the media attribute.

After refreshing the page, or visiting later, even if cookies/cache is cleared, it will behave as expected and not preload additional resources.

Expected results:

It should only preload resources where the media attribute matches. In the case of the minimal example above, when following those steps the 1080p/4k image should not be preloaded.

The issue can be reproduced by closing the private-browser session and starting a new one.*

Blocks: rel=preload
Component: Networking → DOM: Core & HTML

I am not sure how this should behave on a private browser window. Does our code differentiate a private browser in preload cases?
FWIW I wasn't seeing the issue when trying to reproduce it.

Flags: needinfo?(emilio)

I couldn't reproduce this either on the current Nightly build. Following comment 0 I get the following PreloadImage calls (0 or 1 is for "did the media match", and thus "do we preload the image"):

PreloadImage(https://sethfalco.github.io/Firefox/2160.webp, 0)
PreloadImage(https://sethfalco.github.io/Firefox/706.webp, 1)
PreloadImage(https://sethfalco.github.io/Firefox/362.webp, 0)
PreloadImage(https://sethfalco.github.io/Firefox/706.webp, 1)

So we only preload 706.webp which is the expected thing to do for that viewport size afaict. Seth, does this repro on Nightly for you?

Re. comment 2, there should be no behavior difference for private windows vs. non private. However when the last private window is exited we clean up the private-mode image cache iirc, so it makes it easier to reproduce by not requiring a full restart.

Flags: needinfo?(emilio)
Flags: needinfo?(seth)

Close per comment 2 and comment 3.
Dear reporter, please feel free to reopen it if you still see this issue and got a chance to get back here. Thanks!

Status: UNCONFIRMED → RESOLVED
Closed: 2 years ago
Resolution: --- → WORKSFORME

Sorry for coming back to this so late. I did just try to reproduce the issue again, but I'm unable to.
I'm not sure what was wrong before, but in any case, it's fine to keep this closed.

Just updating the ticket to clear the needinfo status.

Flags: needinfo?(seth)
OS: Unspecified → Linux
Hardware: Unspecified → x86_64
You need to log in before you can comment on or make changes to this bug.