Added size support to Network tab#9744
Conversation
srawlins
left a comment
There was a problem hiding this comment.
Looks great, thank you!
packages/devtools_app/lib/src/screens/network/network_request_inspector_views.dart
Outdated
Show resolved
Hide resolved
|
Merge in the master branch to resolve that merge conflict. |
|
Hi @srawlins |
|
Hi @srawlins, One test failed: The failing Thanks! |
| // - 2048 → "2.0 KB" | ||
| // - 1048576 → "1.0 MB" | ||
| // Values are rounded to one decimal place for KB and MB. | ||
| String _formatBytes(int? bytes) { |
There was a problem hiding this comment.
I think we should should use Chrome DevTools network panel as a model for our network panel as much as possible. It looks like they decided to standardize on using kB (1000 bytes) instead of KiB (1024 bytes) as their unit of measurement [1]. We should do the same unless there is a good reason not to.
[1] https://developer.chrome.com/blog/new-in-devtools-88#consistent-kb
There was a problem hiding this comment.
yes.. right
i didn't knew about this, thanks for pointing it out.
| statusColumn, | ||
| typeColumn, | ||
| durationColumn, | ||
| const ResponseSizeColumn(), |
There was a problem hiding this comment.
[nit] add this to the list of static const fields above
|
|
||
| @override | ||
| int? get responseBytes { | ||
| final headers = responseHeaders; |
There was a problem hiding this comment.
I don't think we need to assign responseHeaders to a new variable here, can simply write:
final contentLength = responseHeaders?['content-length'];
There was a problem hiding this comment.
yes , we can merge it in a single line,
Thanks for this
| @override | ||
| String getValue(NetworkRequest dataObject) { | ||
| return dataObject.uri; | ||
| String getValue(NetworkRequest data) { |
There was a problem hiding this comment.
I don't think this change is necessary
There was a problem hiding this comment.
yes my bad, i changed it trying to fix a test fail, i will revert it back.
…ition, simplify code, and revert unnecessary changes
elliette
left a comment
There was a problem hiding this comment.
Thanks! A few changes but looks good!
| // - 1000000 → "1.0 MB" | ||
| // Values are rounded to one decimal place for kB and MB. | ||
| // Uses decimal (base-10) units to match Chrome DevTools. | ||
| String _formatBytes(int? bytes) { |
There was a problem hiding this comment.
Move formatBytes into http_utils.dart so it can be used here and in network_request_inspector_view.dart, and add a test
There was a problem hiding this comment.
Added the tests in test/shared/http/http_utils_test.dart.
|
|
||
| ## Network profiler updates | ||
|
|
||
| - Added response size ("Res Size") column to the Network tab and displayed response size in the request inspector overview. - |
There was a problem hiding this comment.
Can remove ("Res Size"), i.e. "Added response size column to..."
| } | ||
|
|
||
| @override | ||
| int? get responseBytes { |
There was a problem hiding this comment.
Sure, added tests in /test/shared/http/http_request_data_test.dart
…ate units and added tests for responseBytes & formatBytes
Overview
This PR adds support for displaying response payload size in the Network tab
and fixes #6165.
It introduces a new "Size" column in the network requests table and displays response size in the Overview panel of the request inspector.
Changes
1. Data Model Updates
File:
packages/devtools_app/lib/src/screens/network/network_model.dartAdded two new getters to the
NetworkRequestbase class:requestBytesresponseBytesImplemented these getters in the
Socketclass using:writeBytes: request sizereadBytes: response sizePurpose:
Expose byte-level data in a unified way for all network request types.
2. HTTP Data Handling
File:
packages/devtools_app/lib/src/shared/http/http_request_data.dartcontent-lengthheaderStringandList<String>header formatsPurpose:
Provide response size for HTTP requests when available, without requiring changes to the Dart VM.
3. Shared Utility
File:
packages/devtools_app/lib/src/screens/network/utils/http_utils.dartformatBytesinto a reusable utility functionkB,MB) to align with Chrome DevToolsPurpose:
Ensure consistent formatting across the network table and inspector views.
4. Network Table UI
File:
packages/devtools_app/lib/src/screens/network/network_screen.dart-when size is unavailable5. Request Inspector (Overview Panel)
File:
packages/devtools_app/lib/src/screens/network/network_request_inspector_views.dartAdded a new row:
Uses shared
formatBytesutility6. Tests
Added unit tests for:
formatBytesutility inhttp_utils_test.dartresponseBytesparsing logic inhttp_request_data.dartCovers edge cases including:
Why request size is not included
Request size is not reliably available for HTTP requests due to limitations in the current DevTools and VM service APIs:
HttpProfileRequestcontent-lengthare often absent for outgoing requestsWhile socket-level request size (
writeBytes) is available, it is not consistently applicable to HTTP requests.Therefore, including request size would require changes in the Dart SDK / VM layer.
This PR focuses on response size, which can be reliably determined using:
readBytescontent-lengthheader (when present)Screenshot
Future Work
Pre-launch Checklist
General checklist
Issues checklist
Tests checklist
AI-tooling checklist
Feature-change checklist
NEXT_RELEASE_NOTES.md