File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,10 @@ const uncompressedFiles = computed(() => files.value.filter(getUncompressedFiles
21
21
const anyUncompressed = computed (() => Boolean (uncompressedFiles .value .length ));
22
22
const toCompress = ref <FileObj []>([]);
23
23
24
+ // limit to 6 concurrent workers in order to work around a bug in Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1885198
25
+ const workerLimit = 6 ;
24
26
const availableThreads = Math .max (navigator .hardwareConcurrency - 2 , 1 );
27
+ const workerThreadAmount = Math .min (workerLimit , availableThreads );
25
28
26
29
async function editFileObj(fileObj : FileObj ) {
27
30
try {
@@ -37,7 +40,7 @@ async function editFileObj(fileObj: FileObj) {
37
40
// add files to toCompress array when a thread is available
38
41
watchEffect (() => {
39
42
if (isCompressing .value ) {
40
- const amountToPush = availableThreads - toCompress .value .filter (getUncompressedFiles ).length ;
43
+ const amountToPush = workerThreadAmount - toCompress .value .filter (getUncompressedFiles ).length ;
41
44
const pool = uncompressedFiles .value .filter ((item ) => ! toCompress .value .includes (item )).slice (0 , amountToPush );
42
45
if (pool .length ) toCompress .value = [... toCompress .value , ... pool ];
43
46
}
You can’t perform that action at this time.
0 commit comments