Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slowdown on compress image with modified RegExp prototype #109

Open
filipevserra opened this issue Nov 29, 2023 · 1 comment
Open

Slowdown on compress image with modified RegExp prototype #109

filipevserra opened this issue Nov 29, 2023 · 1 comment

Comments

@filipevserra
Copy link

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
Copy link
Owner

dfa1234 commented Jul 22, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants