Closed Bug 1621919 Opened 5 years ago Closed 2 years ago

Fix data size calculation in the Network panel

Categories

(DevTools :: Netmonitor, defect, P2)

defect

Tracking

(firefox106 fixed)

RESOLVED FIXED
106 Branch
Tracking Status
firefox106 --- fixed

People

(Reporter: Honza, Assigned: bomsy)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

The Network panel is using kB/MB labels for (request/response/headers/etc.) sizes, which corresponds to the following definition:

1 kB = 1 kilobyte = 1000 bytes = 10^3 bytes
1 MB = 1 megabyte = 1000^2 bytes = 10^6 bytes

But, the code performs 1024-based calculations.

See this line:
https://searchfox.org/mozilla-central/rev/2fd8ffcf087bc59a8e5c962965bbb7bf230bcd28/devtools/client/netmonitor/src/utils/format-utils.js#10

It's using 1024 based calculation
Should be fixed to 1000

Honza

Hey Honza, I'd like to fix this one;

The only thing to do is just update the constant?

Correct. And also, please test carefuly with various responses, compare with chrome devtools of file explorer, etc.

Honza

Assignee: nobody → marianapicolo
Mentor: odvarko
Status: NEW → ASSIGNED

@Honza, did you check my last comment on Phabricator?

Flags: needinfo?(odvarko)

Sorry for the delay, commented on Phab now.

Honza

Flags: needinfo?(odvarko)

@ MarianaPicolo: just posted a comment to Phab, some tests need to be updated too (just adjust the expected size)

Honza

Flags: needinfo?(marianapicolo)

Because this bug's Severity has not been changed from the default since it was filed, and it's Priority is P3 (Backlog,) indicating it has been triaged, the bug's Severity is being updated to S3 (normal.)

Severity: normal → S3

We need to be careful with this to consider our options further. 1024 is deeply embedded in developer's brains, while the subtle difference in naming conventions are not. Maybe fixing the labels/tooltips for clarity could also help with this.

Related: https://twitter.com/digitarald/status/1263151454480510976 .

So, looks like 1024 is the way to go (81%)

@MarianaPicolo: are you still working on this?

Honza

The poll results might just indicate the current state of things, which is confusing since various apps use the same "kB" label to mean different things (despite there being a clear definition for what it means). There's an opportunity to reduce overall confusion and educate developers at the same time, regardless of how we end up solving this (either by clarifying the labels by using "KiB" for 1024-based units, or by continuing to use "kB" labels but ensuring 1000-based calculations).

E.g. Apple's HIG specifies that all data units should be 1000-based in macOS itself and in all macOS apps. (Ironically, the Safari DevTools use 1024-based numbers, but since that's a HIG violation that's a bug.) Inspecting a 1000-byte file in the macOS finder shows 1 kB, whereas inspecting a network request for the same file in Firefox DevTools currently says something else, which is confusing in and of itself. (Chrome has the same problem currently.)

Test resources:

https://mathiasbynens.github.io/css-dbg-stories/1000.txt
https://mathiasbynens.github.io/css-dbg-stories/1024.txt

Per the earlier consensus (before comment #8), Chrome DevTools now consistently uses 1000-based units with the proper SI labels: https://bugs.chromium.org/p/chromium/issues/detail?id=1035309 It would be great if Firefox DevTools would do the same. :Honza, WDYT?

This good-first-bug hasn't had any activity for 2 months, it is automatically unassigned.
For more information, please visit auto_nag documentation.

Assignee: marianapicolo → nobody
Status: ASSIGNED → NEW

Hello Everyone,
What is the status of this bug, can I work on this?

Ankit.

Hi Ankit,
thank your for your interest in helping DevTools!

We had a meeting about this couple months ago and decided to keep the logic as is, i.e keeping 1024 calculation as well as the labels.

(In reply to Mathias Bynens from comment #11)

Per the earlier consensus (before comment #8), Chrome DevTools now consistently uses 1000-based units with the proper SI labels: https://bugs.chromium.org/p/chromium/issues/detail?id=1035309 It would be great if Firefox DevTools would do the same. :Honza, WDYT?

Thank you Mathias for the links!

For now, it isn't easy to find consensus even if I'd be happy if DevTools (cross-browser) had the same view on this.

Honza

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WONTFIX

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

We had a meeting about this couple months ago and decided to keep the logic as is, i.e keeping 1024 calculation as well as the labels.

May I ask for the reasons you decided to keep the current logic? I have to admit that I never really thought much about it earlier, though the calculations and labels are clearly wrong regarding their definition.

I think the most logical would be to switch to 1000-based calculation as I assume only a small percentage of developers know about the 1024-based units. And to be precise, "KB" then should be renamed to "kB".

Sebastian

Flags: needinfo?(odvarko)

Harald's twitter poll showed that people expect 1024 and in such case we would have to use "KiB/MiB" and those labels could be confusing to users. Personally, it would be ok for me to use 1000 based calculation.

Honza

Flags: needinfo?(odvarko)

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

Harald's twitter poll showed that people expect 1024 and in such case we would have to use "KiB/MiB" and those labels could be confusing to users.

I'd argue the current "KB" labeling is way more confusing, because it's ambiguous. Upon seeing KB as a user, I always have to guess: did you mean "kB" (1000 bytes) or KiB (1024 bytes)? Turns out that in this case you meant KiB (but e.g. the macOS Finder uses the same "KB" label to mean "kB").

As a user, I don't have a strong preference w.r.t. using 1000- or 1024-based units (although I would love alignment between all browser DevTools!). Using precise labels seems uncontroversial though.

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

We had a meeting about this couple months ago and decided to keep the logic as is, i.e keeping 1024 calculation as well as the labels.

If you keep 1024-based calculations, you must use the binaries prefix that corresponds to this 1024-based.

I understand that the type of calculation can be debatable, but the calculation and the label must be consistent to not display false size.

Now seems like a good time to revisit this discussion: Safari just fixed https://bugs.webkit.org/show_bug.cgi?id=208190 and is now using 1000-based units, as per the Apple HIG. Chrome DevTools has already been doing the same for almost a year. If Firefox DevTools would align, then all browser DevTools would denote file/memory sizes consistently! That would be amazing for web developers.

Whiteboard: [devtools-triage]

Reopening per the last comment from Mathias, if all other DevTools switched to 1000 based units, we should probably do the same.

Status: RESOLVED → REOPENED
Keywords: good-first-bug
Resolution: WONTFIX → ---
Flags: needinfo?(marianapicolo)
Mentor: odvarko
Priority: P3 → P2
Whiteboard: [devtools-triage]
Assignee: nobody → marianapicolo

The bug assignee is inactive on Bugzilla, and this bug has priority 'P2'.
:Honza, could you have a look please?

For more information, please visit auto_nag documentation.

Assignee: marianapicolo → nobody
Flags: needinfo?(odvarko)

I'm picking this up to complete it.

Assignee: nobody → hmanilla
Flags: needinfo?(odvarko)
Attachment #9133481 - Attachment description: Bug 1621919 - Update constant for format bytes. r=Honza → Bug 1621919 - Update constant for format bytes. r=jdescottes
Pushed by hmanilla@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/6fb48bfde203 Update constant for format bytes. r=jdescottes
Status: REOPENED → RESOLVED
Closed: 4 years ago2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 106 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: