dfa1234 / ngx-image-compress

Angular library for uploading and compressing images
https://image-library.app
MIT License
86 stars 37 forks source link

Slowdown on compress image with modified RegExp prototype #109

Open filipevserra opened 9 months ago

filipevserra commented 9 months ago

Uploading a huge image to the demo site (https://image-library.app/) in the "Upload and Compress Image", it'll take a long time to finish if some extensions or libs change the prototype of RegExp. Reducing the steps to the minimum to reproduce the problem, I have:

Thirdy party products to protect JS code can causes this changes on RegExp.

The problem occurs only on Chrome and Edge. Firefox works fine.

dfa1234 commented 1 month ago

Very interesting issue

There are some regex in the code

const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
const isIOS = /iPad|iPhone|iPod/i.test(navigator.userAgent);

For now the only solution for you is to only use the compress function, and do the upload on your side.

I will investigate because it's interesting, but it is in low priority for now.