dfa1234/ngx-image-compress

Image compression fails on Firefox Android

Closed this issue · 3 comments

I'm running into an issue with Firefox on Android (Related #38 ). Apparently, larger files 3-4MB's will cause the app to remain in a 'stuck' state because the compression somehow doesn't work (it doesn't resolve or reject the promise).

In the case below, both console.logs will not get outputted because the promise doesn't resolve or reject:

async compressImage(file: string, fileSource: File): Promise<void | File> {
    const orientation = await this.imgCompress.getOrientation(fileSource);
    return this.imgCompress
		.compressFile(file, orientation, 50, 50)
		.then((image) => {
                         console.log('image', image);
			const imageBlob = this.dataURItoBlob(image.split(',')[1]);
			const imageFile = new File([imageBlob], fileSource.name, {
				type: 'image/jpeg',
			});
			return imageFile;
		 })
                 .catch((err: any) => {
                     console.log('err compress', err);
                  })
	}

Looking in the source code I noticed that in the compress() function the onload event won't fire when larger images are passed to the compressFile() function. Smaller images somehow work and the onload event is fired. I'm not sure why this is the case in firefox considering it works how it's suppose to work in Chrome (also with larger images).

It's not linked to #38, there the problem is related to stackbilz server. You need to make a test from your own server

@adamk22 you can now use this link to make your performance tests

https://image-library.app/

Tested on BrowerStack on a real device and it's working fine, with a image of 5mb.
Closing the issue

image