Donaldcwl / browser-image-compression

Image compression in web browser
MIT License
1.27k stars 160 forks source link

Black image after compression on iOS #190

Open rafavalerio opened 1 year ago

rafavalerio commented 1 year ago

Overview

I've seen mentions of this issue earlier and apparently, it has been fixed on v2.0.2. But even after the update, I am still facing this issue on iOS (16.4.1, iPhone 12 and 13, Safari and Chrome) only (Android, or other desktop browsers are fine).

The issue happens when trying to perform a bulk image upload (Currently using AntDesign - Upload for that).

Single images or a smaller number (up to 10) works fine, but any higher than that will result in black images.

These are the compression options I am using at the moment:

{
  maxSizeMB: 1,
  maxWidthOrHeight: 1500,
  useWebWorker: false, // Tried with both true/false, but the issue persists
}

Can it be related to running the compression simultaneously? Any idea why it works on Android (even on older devices like Pixel 5), but fails on an iPhone 12?

Donaldcwl commented 1 year ago

@rafavalerio There is a limit on memory usage in browsers which may be the reason for the black image outputs you are experiencing. I suggest trying to run the compression process sequentially instead of in parallel to determine if the issue persists.

If it works fine, we may need to find a way to restrict concurrent compression in order to prevent this problem from occurring.

Russell-Pollari commented 1 month ago

Found a similar issue on Ipad pro (images turning all black) see: https://github.com/Donaldcwl/browser-image-compression/issues/222