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
2121const anyUncompressed = computed (() => Boolean (uncompressedFiles .value .length ));
2222const toCompress = ref <FileObj []>([]);
2323
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 ;
2426const availableThreads = Math .max (navigator .hardwareConcurrency - 2 , 1 );
27+ const workerThreadAmount = Math .min (workerLimit , availableThreads );
2528
2629async function editFileObj(fileObj : FileObj ) {
2730 try {
@@ -37,7 +40,7 @@ async function editFileObj(fileObj: FileObj) {
3740// add files to toCompress array when a thread is available
3841watchEffect (() => {
3942 if (isCompressing .value ) {
40- const amountToPush = availableThreads - toCompress .value .filter (getUncompressedFiles ).length ;
43+ const amountToPush = workerThreadAmount - toCompress .value .filter (getUncompressedFiles ).length ;
4144 const pool = uncompressedFiles .value .filter ((item ) => ! toCompress .value .includes (item )).slice (0 , amountToPush );
4245 if (pool .length ) toCompress .value = [... toCompress .value , ... pool ];
4346 }
You can’t perform that action at this time.
0 commit comments