Closed Bug 1747494 Opened 2 years ago Closed 2 years ago

Multiple image requests aren't coalesced for image cache case

Categories

(DevTools :: Netmonitor, defect, P3)

Firefox 95
defect

Tracking

(firefox-esr91 unaffected, firefox95 wontfix, firefox96 wontfix, firefox97 fixed)

RESOLVED FIXED
97 Branch
Tracking Status
firefox-esr91 --- unaffected
firefox95 --- wontfix
firefox96 --- wontfix
firefox97 --- fixed

People

(Reporter: undeaD_D, Assigned: bomsy)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: regression)

Attachments

(3 files)

Steps to reproduce:

Step 1: Open Link
https://undeadd.github.io/JavaCtf/test.html
(Sry for the weird url -> its a quick poc)

Step 2: Open Developer Network Tool
(Look out for Image loads)

Step 3: Click Link: "Test"
(Image gets loaded once)

Step 4: Click same Link again
(suddenly all the images get loaded seperately even if they are all the same src)

Step 5: Compare Network loads from Step 3 & 4

Actual results:

Firefox v95 and higher suddenly loads all the images seperately (in Step 4).
Larger quantities of images would lead to huge lagspikes and delay.

Expected results:

Firefox v94 and lower dont have this problem.
Step 4 should only trigger one image load operation similar to Step 3.

The Bugbug bot thinks this bug should belong to the 'Core::JavaScript Engine' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → JavaScript Engine
Product: Firefox → Core
Summary: image load js → Firefox should not load all JS images seperately

bug 1722759 changed the Netmonitor behavior to log image requests loaded from image cache.

So, items logged at step 4 are image requests loaded from cache (see "Aus Cache" in "Übertragen" column), and no network requests happens at step 4.
But this behavior is inconsistent with the step 3 where image cache is not used and only one item is logged for multiple <img>s.

Status: UNCONFIRMED → NEW
Component: JavaScript Engine → Netmonitor
Ever confirmed: true
Product: Core → DevTools
Regressed by: 1722759
Summary: Firefox should not load all JS images seperately → Multiple image requests aren't coalesced for image cache case
Has Regression Range: --- → yes

Set release status flags based on info from the regressing bug 1722759

Thank you for the report.

I can reproduce the issue using STRs in comment #0

@Bomsy: could we show just one "cached" request? (just like e.g. Chrome Net panel does)

Severity: -- → S3
Flags: needinfo?(hmanilla)
Priority: -- → P3

Hi Honza,

@Bomsy: could we show just one "cached" request? (just like e.g. Chrome Net panel does)

Yes we can just load one cache request. Should be straightforward to fix. I'll take a look.

Flags: needinfo?(hmanilla)

Depends on D134617

Assignee: nobody → hmanilla
Status: NEW → ASSIGNED

(In reply to Jan Honza Odvarko [:Honza] (always need-info? me) from comment #4)

@Bomsy: could we show just one "cached" request? (just like e.g. Chrome Net panel does)

Note that chrome isn't as good as Firefox to displayed cached image request.
It does show a cached image request if you click on Test the first time, after having loaded the image in a previous page load.
Otherwise if you click Test again, Chrome won't show any request.

As Arai said in comment 2, Firefox doesn't fetch the images over the network except for the very first image loaded.
All subsequent requests displayed in the network monitor are fetched from the memory cache and not from the network. May be we should make that even clearer in the UI?
Now we have some discrepancy between the very first click on Test and all the subsequent ones.
We do not show all the images fetched from the cache on the very first click.
May be we should? Any idea why we aren't getting http-on-image-cache-response notifications?

Showing only the first one may be misleading?
Why would fetch("https://avatars.githubusercontent.com/u/8116188https://avatars.githubusercontent.com/u/8116188") display a request each time we call it?
Whereas var img = new Image(); img.src = "https://avatars.githubusercontent.com/u/8116188"; would only display a request once?

Sean, any opinion about this?
Do you have any idea why http-on-image-cache-response isn't always fired? (Step 3 of comment 0's STR)

Flags: needinfo?(sefeng)

I was able to reproduce it locally.

We didn't fire it for the rest of the images because the cache entry exited but the request wasn't completed yet, so we exited early at https://searchfox.org/mozilla-central/rev/253ae246f642fe9619597f44de3b087f94e45a2d/image/imgLoader.cpp#2061-2063

I agree the behaviour should be consistent. I think if we only always want to get 1 image request in the devtool, then bomsy's fix is correct. However, if we want to always get multiple requests in the devtool, then we probably need to fix how we fire http-on-image-cache-response, perhaps it should be moved to imgRequestProxy::OnLoadComplete.

Flags: needinfo?(sefeng)

Why "Disable Cache" (a checkbox within the Network panel) doesn't have an impact and the second click is showing cached images?

Because that's for HTTP cache? Images are loaded from the in-memory image cache for the second click.

(In reply to Sean Feng [:sefeng] from comment #12)

Because that's for HTTP cache? Images are loaded from the in-memory image cache for the second click.

I see, that make sense, thank you.
Are there any APIs that would allow DevTools to disable also the in-memory image cache?

I don't know anything about that.

(In reply to Sean Feng [:sefeng] from comment #10)

I was able to reproduce it locally.

We didn't fire it for the rest of the images because the cache entry exited but the request wasn't completed yet, so we exited early at https://searchfox.org/mozilla-central/rev/253ae246f642fe9619597f44de3b087f94e45a2d/image/imgLoader.cpp#2061-2063

Ah ok, that's good to know!

I agree the behaviour should be consistent. I think if we only always want to get 1 image request in the devtool, then bomsy's fix is correct. However, if we want to always get multiple requests in the devtool, then we probably need to fix how we fire http-on-image-cache-response, perhaps it should be moved to imgRequestProxy::OnLoadComplete.

It sounds like you don't have a strong opinion here? I imagine that platform developers may have different point of view than web developers.
Showing absolutely all image loads may be useful to debug platform issues, while it might be confusing for web developers who have more interest about actual network requests.
Given that, the current fix is probably our best option, which we can easily revisit later if we want to display all image usages.

I agree the behaviour should be consistent. I think if we only always want to get 1 image request in the devtool, then bomsy's fix is correct. However, if we want to always get multiple requests in the devtool, then we probably need to fix how we fire http-on-image-cache-response, perhaps it should be moved to imgRequestProxy::OnLoadComplete.

It sounds like you don't have a strong opinion here? I imagine that platform developers may have different point of view than web developers.
Showing absolutely all image loads may be useful to debug platform issues, while it might be confusing for web developers who have more interest about actual network requests.
Given that, the current fix is probably our best option, which we can easily revisit later if we want to display all image usages.

Maybe a good tradeoff might be showing some information indicating that this request is one of a number of requests (maybe some information in the tooltip). This might help platform developers.

Pushed by hmanilla@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/061ada982fc2
[devtools] Small  cleanups r=ochameau
https://hg.mozilla.org/integration/autoland/rev/bde2d5a50f7d
[devtools] Should display only one request per URL for images from the cache r=ochameau
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 97 Branch
See Also: → 1753471
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: