Skip to content

Commit 1a9a353

Browse files
committed
Track the transferSize as the byteSize and the decoded size for img file size
This is the data that Chrome shows for the equivalent UIs so it's more consistent.
1 parent 0ac68a9 commit 1a9a353

File tree

1 file changed

+9
-4
lines changed
  • packages/react-devtools-shared/src/backend/fiber

1 file changed

+9
-4
lines changed

packages/react-devtools-shared/src/backend/fiber/renderer.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3326,7 +3326,7 @@ export function attach(
33263326
start = resourceEntry.startTime;
33273327
end = start + resourceEntry.duration;
33283328
// $FlowFixMe[prop-missing]
3329-
byteSize = (resourceEntry.encodedBodySize: any) || 0;
3329+
byteSize = (resourceEntry.transferSize: any) || 0;
33303330
}
33313331
}
33323332
}
@@ -3411,6 +3411,7 @@ export function attach(
34113411
let start = -1;
34123412
let end = -1;
34133413
let byteSize = 0;
3414+
let fileSize = 0;
34143415
// $FlowFixMe[method-unbinding]
34153416
if (typeof performance.getEntriesByType === 'function') {
34163417
// We may be able to collect the start and end time of this resource from Performance Observer.
@@ -3421,7 +3422,9 @@ export function attach(
34213422
start = resourceEntry.startTime;
34223423
end = start + resourceEntry.duration;
34233424
// $FlowFixMe[prop-missing]
3424-
byteSize = (resourceEntry.encodedBodySize: any) || 0;
3425+
fileSize = (resourceEntry.decodedBodySize: any) || 0;
3426+
// $FlowFixMe[prop-missing]
3427+
byteSize = (resourceEntry.transferSize: any) || 0;
34253428
}
34263429
}
34273430
}
@@ -3440,6 +3443,10 @@ export function attach(
34403443
value.naturalWidth = instance.naturalWidth;
34413444
value.naturalHeight = instance.naturalHeight;
34423445
}
3446+
if (fileSize > 0) {
3447+
// Cross-origin images won't have a file size that we can access.
3448+
value.fileSize = fileSize;
3449+
}
34433450
const promise = Promise.resolve(value);
34443451
(promise: any).status = 'fulfilled';
34453452
(promise: any).value = value;
@@ -3452,8 +3459,6 @@ export function attach(
34523459
owner: fiber, // Allow linking to the <link> if it's not filtered.
34533460
};
34543461
if (byteSize > 0) {
3455-
// Cross-origin images won't have a file size that we can access.
3456-
value.fileSize = byteSize;
34573462
// $FlowFixMe[cannot-write]
34583463
ioInfo.byteSize = byteSize;
34593464
}

0 commit comments

Comments
 (0)