Open Bug 1532274 Opened 6 years ago Updated 1 year ago

Page Info Window shows size unknown for images that are not cached

Categories

(Firefox :: Page Info Window, defect, P3)

65 Branch
defect

Tracking

()

People

(Reporter: martijn, Unassigned)

References

Details

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

Steps to reproduce:

Go to Page Info, to the Media tab. Then select an image that happens not to be cached.

Actual results:

Next to "Size" it will say "unknown (not cached)".

Expected results:

It should display the size for that image. The size of an image is absolutely known. Even the network tab in the devtools properly shows sizes.

Better yet: for any resource currently being displayed, how could its size NOT be known? I mean it has just been downloaded moments ago.

Component: Untriaged → Page Info Window
Summary: Image info size unknown → Page Info Window shows size unknown for images that are not cached

I was sure this was a duplicate, but I can't find any existing bug. This was a much bigger problem when https resources were not cached.

(In reply to Martijn from comment #0)

Even the network tab in the devtools properly shows sizes.

Better yet: for any resource currently being displayed, how could its size NOT be known? I mean it has just been downloaded moments ago.

The network tab monitors all network traffic (and you've got to reload the page to see things) so it knows the size of everything. Page Info collects information after the fact. The size of image files may not be available anymore as the original file might have been discarded after decoding/decompressing the image.

Priority: -- → P3
Status: UNCONFIRMED → NEW
Ever confirmed: true

(In reply to Florian Quèze [:florian] from comment #1)

I was sure this was a duplicate, but I can't find any existing bug.

Bug 1525139?

(In reply to Itiel from comment #2)

(In reply to Florian Quèze [:florian] from comment #1)

I was sure this was a duplicate, but I can't find any existing bug.

Bug 1525139?

This is slightly different, but also a consequence of Page Info relying on the network cache. I was looking for something really old, as I'm sure this bug pre-existed the rewrite I did in 2006.

See Also: → 1734458

I am a bit astonished about what the behavior of Firefox in "Page Info: Media" TAB looks like to be when Page Info Window is opened and when an item list is selected; here I try only to summarize what I noticed.

  1. Firefox starts to get the list of items for "Page Info: Media" asynchronously form loaded page just after opening (i.e. by pressing CTRL-I) "Page Info Window", so if the page has lots of images it may require several seconds before the icon "Media" appears after the "General" icon in window.

    This behavior may be right because there are lots of dynamic pages out there and it makes sense to get that list on the fly (you can open Page Info a first time, then close it, then go down the dynamic page (i.e. see youtube video pages with comments that are dynamically added to the page, etc.).

    Anyway, while the list is being loaded there is no "Media" icon and there is NO user message or an icon indicator to inform the user that there is an ongoing operation that may last for a long time.

    I once opened a page with thousands of small icons and no tab "Media" appeared for tens of seconds, so I thought that there was a bug when there were too many images.

    I'll open a new bug for the missing user information while loading "Media" list.

  2. When "Media" tab is selected then item list is shown and the first item is automatically selected.

    This is useful because its image is displayed below the list but in "Size:" field the real size is not updated!

  3. Everytime an image is shown for the first time, it looks like that it is gotten from HTTP server and not from some cache
    where it should be already present (because it has just been stored when web page was displayed).

    Anyway, if an image is shown (asynchronously) for the first time, also its size should be updated without having to reselect the item (maybe a notification about having shown an image should be sent to the window in order to refresh the real size of the item).

    I have discovered that every time an item is selected for the first time, if it is not present in (network) cache:

    • a new HTTP request is made to server (if you disconnect network cable from your PC before selecting a new item, no image is ever shown);
    • if the HTTP request was successful then the replied image is shown below the list;
    • the image size is not updated when the image is shown; only the second time that the image is shown, its size is updated properly (missing notification about displayed image that should force a refresh in "Size:" value field).

    Observations.

    Why is that image not found in some cache as it has already been shown in web page (maybe just a few seconds before opening page info) ?

    Getting a big image from HTTP server after having selected it, may require some time and so in that case everything becomes painfully slow for the user; anyway, because of this behavior, also small images slow down a bit the browsing of the list (it is really easy to break down the golden rule to respond to user input within 0.1 seconds) and besides this no user message or indicator is shown to notify user that a potentially lengthy operation is being performed.

    If you open Page Info window after a lot of time you have accessed its web page, you may show a new image (with the same name) that is not the same as that shown in web page or it may not exist anymore, etc.; I think that page info window should show information that is the same as that used to display web page.

    Page info media list should show the same objects that were just shown in web page, not those gotten at the time you select items for the first time and yes, Firefox should be smart enough to find out when an object in cache was or was not successfully stored (Firefox should try to get it again from network only in the second case).

I noticed above behavior in Firefox 93, Windows 10 (x86_64) so it looks like nothing has been improved in the last 3 years.

Another defect of Page Info: Media window is:

  • if there is only one image in web page (one row in media item list), that item (image) size is never updated (because you cannot deselect and reselect that one row) and so Firefox will always display this string: "Unknown (not cached)" even if this is not true because image has just been stored in network cache when that row was automatically selected at window open.

All above cases should be tested both with web pages coming from an HTTP server (https://) or from file system (i.e. file:///).

A secondary cause of this problem appears to be if the page uses Basic Auth. The media window doesn't share your session and can't load the image.

Just noticed this on a staging site.

I partially figured this out.

To reproduce open any image in a new tab. Let's take https://upload.wikimedia.org/wikipedia/commons/f/f1/Bal26151-Jan-Both.jpg for an example

Observe that it gets cached immediately. In the cache on disk appears file ./cache2/entries/F020619CFDA44D18A873FBE1904E8A8EE2633011
You can check that it is an actual image by opening it in any image viewer.

Now let's check file size. Press Ctrl-I, go to "Media" tab. In the "Size:" field you'll see "Unknown (not cached)". This is weird, as it actually cached as we checked. But! Close Page Info and reopen it again, once again navigate to Media tab. Now it shows correct size for the image!

Turns out that viewing image info via "Media" tab causes it to be download again and stored as another one record in cache. And now you have the same image cached twice:

$ ls -o ./F020619CFDA44D18A873FBE1904E8A8EE2633011  ./F485003BEBEBC9A995C954E1EB4CF459BC2F4089
-rw------- 1 self 187355 2022-09-23 13:12 ./F020619CFDA44D18A873FBE1904E8A8EE2633011
-rw------- 1 self 187256 2022-09-23 13:14 ./F485003BEBEBC9A995C954E1EB4CF459BC2F4089

Huh. This is strange. These are both the same image but files are obviously differs at least by size.

Turns out firefox appends some kind of metadata to cached images. And among other things it looks like it stores the URL of the image. Here is for the cache entry that appears after loading image in browser tab:

$ strings ./F020619CFDA44D18A873FBE1904E8A8EE2633011  | grep Bal26151
O^partitionKey=%28https%2Cwikimedia.org%29,:https://upload.wikimedia.org/wikipedia/commons/f/f1/Bal26151-Jan-Both.jpg

And here is URL for cache entry that gets cached when checking image via Page Info / Media:

$ strings ./F485003BEBEBC9A995C954E1EB4CF459BC2F4089 | grep Bal26151
:https://upload.wikimedia.org/wikipedia/commons/f/f1/Bal26151-Jan-Both.jpg

Thus the problem is that Page Info / Media checks another URL, not the same that was loaded in the page itself.

And the solution should be in synchronizing these URLs.

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.