Commit aac691b
authored
Added size support to Network tab (#9744)
## 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.dart`
* Added two new getters to the `NetworkRequest` base class:
* `requestBytes`
* `responseBytes`
* Implemented these getters in the `Socket` class using:
* `writeBytes` : request size
* `readBytes` : response size
**Purpose:**
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.dart`
* Added logic to extract response size using the `content-length` header
* Handles both `String` and `List<String>` header formats
**Purpose:**
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.dart`
* Moved `formatBytes` into a reusable utility function
* Uses **decimal (base-10) units** (`kB`, `MB`) to align with Chrome DevTools
* Handles null and negative values safely
**Purpose:**
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`
* Added a new column: **"Size"**
* Displays formatted response size
* Shows `-` when size is unavailable
---
### 5. Request Inspector (Overview Panel)
**File:**
`packages/devtools_app/lib/src/screens/network/network_request_inspector_views.dart`
* Added a new row:
* **Response Size**
* Uses shared `formatBytes` utility
---
### 6. Tests
* Added unit tests for:
* `formatBytes` utility in `http_utils_test.dart`
* `responseBytes` parsing logic in `http_request_data.dart`
* Covers edge cases including:
* string and list headers
* invalid values
* null handling
---
## 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:
* The Dart VM does not expose request payload size in `HttpProfileRequest`
* HTTP request bodies are not always accessible or fully captured
* Headers such as `content-length` are often absent for outgoing requests
* Streaming and chunked requests complicate accurate measurement
While 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:
* Socket `readBytes`
* HTTP `content-length` header (when present)
---
## Screenshot
<img width="1359" height="882" alt="Screenshot 2026-03-27 233804" src="https://github.com/user-attachments/assets/4ddce5eb-1a4b-4a9e-80b6-cd16fa226c13" />
---
## Future Work
* Add request size support when VM-level data becomes available
* Introduce separate request/response size columns
* Improve accuracy via VM instrumentation
---
### General checklist
* [x] I read the Contributor Guide
* [x] I read the Tree Hygiene guidelines
* [x] I followed the Flutter Style Guide
* [x] I signed the CLA
* [x] I updated relevant documentation
---
### Issues checklist
* [x] This PR fixes #6165
---
### Tests checklist
* [x] Added unit tests for new functionality
---
### AI-tooling checklist
* [x] I used AI tooling responsibly and verified all generated content
---
### Feature-change checklist
* [x] This PR changes DevTools UI
* [x] Added entry to `NEXT_RELEASE_NOTES.md`
* [x] Included screenshots
* [x] Verified changes locally1 parent 46811ca commit aac691b
8 files changed
Lines changed: 191 additions & 0 deletions
File tree
- packages/devtools_app
- lib/src
- screens/network
- utils
- release_notes
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
| |||
160 | 163 | | |
161 | 164 | | |
162 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
163 | 172 | | |
164 | 173 | | |
165 | 174 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
625 | 626 | | |
626 | 627 | | |
627 | 628 | | |
| 629 | + | |
628 | 630 | | |
629 | 631 | | |
630 | 632 | | |
| |||
658 | 660 | | |
659 | 661 | | |
660 | 662 | | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
661 | 671 | | |
662 | 672 | | |
663 | 673 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
352 | 353 | | |
353 | 354 | | |
354 | 355 | | |
| 356 | + | |
355 | 357 | | |
356 | 358 | | |
357 | 359 | | |
| |||
360 | 362 | | |
361 | 363 | | |
362 | 364 | | |
| 365 | + | |
363 | 366 | | |
364 | 367 | | |
365 | 368 | | |
| |||
394 | 397 | | |
395 | 398 | | |
396 | 399 | | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
397 | 414 | | |
398 | 415 | | |
399 | 416 | | |
| |||
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
254 | 273 | | |
255 | 274 | | |
| 275 | + | |
256 | 276 | | |
257 | 277 | | |
258 | 278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
43 | 46 | | |
44 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
45 | 51 | | |
46 | 52 | | |
47 | 53 | | |
| |||
Lines changed: 95 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
0 commit comments