Estimate progress when Content-Length header is missing

pull/1445/head
tobspr 2 years ago
parent c74e4b9819
commit e870317a4f

@ -81,13 +81,10 @@
xhr.responseType = "arraybuffer"; xhr.responseType = "arraybuffer";
xhr.onprogress = function (ev) { xhr.onprogress = function (ev) {
if (ev.lengthComputable) { if (ev.lengthComputable) {
console.log(ev.total);
progressHandler(ev.loaded / ev.total); progressHandler(ev.loaded / ev.total);
} else { } else {
if (!notifiedNotComputable) { progressHandler(Math.min(1, ev.loaded / 1250000));
notifiedNotComputable = true;
console.warn("Progress not computable:", ev);
progressHandler(0);
}
} }
}; };

@ -197,7 +197,7 @@ export class BackgroundResourcesLoader {
} else { } else {
if (!notifiedNotComputable) { if (!notifiedNotComputable) {
notifiedNotComputable = true; notifiedNotComputable = true;
console.warn("Progress not computable:", ev); console.warn("Progress not computable:", src, ev);
progressHandler(0); progressHandler(0);
} }
} }

Loading…
Cancel
Save