Slowdown on compress image with modified RegExp prototype
Opened this issue · 1 comments
filipevserra commented
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:
- Open https://image-library.app/
- In browser console run the line:
globalThis.Object["defineProperty"](globalThis.RegExp.prototype, 'mynewproperty', {});
- Click on Upload and Compress Image and chose a huge image (7MB or more)
It'll take almost 30 seconds to conclude. Without the change on RegExp prototype, it takes only 2 or 3 seconds.
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
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.