Skip to content

Commit a6ab8cb

Browse files
authored
[Web] Fix NDArrayCache loading report callback (#16631)
1 parent 72ce701 commit a6ab8cb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

web/src/runtime.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,7 @@ export class Instance implements Disposable {
15121512
totalBytes += list[i].nbytes;
15131513
}
15141514
let fetchedBytes = 0;
1515+
let fetchedShards = 0;
15151516
let timeElapsed = 0;
15161517

15171518
const cacheOnly = await artifactCache.hasAllKeys(list.map(key => new URL(key.dataPath, ndarrayCacheUrl).href))
@@ -1550,9 +1551,7 @@ export class Instance implements Disposable {
15501551
}
15511552

15521553
const processShard = async (i: number) => {
1553-
reportCallback(i);
15541554
const shard = list[i];
1555-
fetchedBytes += shard.nbytes;
15561555
const dataUrl = new URL(shard.dataPath, ndarrayCacheUrl).href;
15571556
let buffer;
15581557
try {
@@ -1591,6 +1590,8 @@ export class Instance implements Disposable {
15911590
}
15921591
}
15931592
timeElapsed = Math.ceil((perf.now() - tstart) / 1000);
1593+
fetchedBytes += shard.nbytes;
1594+
reportCallback(fetchedShards++);
15941595
}
15951596
await Promise.all(list.map((_, index) => processShard(index)));
15961597
reportCallback(list.length);

0 commit comments

Comments
 (0)