cubiclesoft / jquery-fancyfileuploader

A jQuery plugin to convert the HTML file input type into a fancy file uploader under a MIT or LGPL license. Mobile-friendly too!
58 stars 27 forks source link

Issue with large and multiple images #32

Open enesk opened 1 year ago

enesk commented 1 year ago

I am trying to upload 2k images at once, my browser is crashing than.

Is it possible to preview images one after one?

cubiclesoft commented 1 year ago

Please provide some additional details. I haven't tried to upload 2,000 images all at once before. I don't think file size should be an issue but rather how many UI elements get injected into the DOM. Can you provide some steps to replicate the web browser crash?

enesk commented 1 year ago

I also think, it is about DOM. Because of that, it is important to show them one after one and not all at once.

To replicate this you only need to upload multiple items min. 500-1000..

cubiclesoft commented 1 year ago

Well, I don't have that many images and my computer is fast/capable enough to not reproduce the issue.

Hazarding a wild guess, what happens if you replace this code:

            uploads.append(inforow);

            if (settings.added)  settings.added.call(inforow, e, data);

With this code:

            setTimeout(function() {
                uploads.append(inforow);

                if (settings.added)  settings.added.call(inforow, e, data);
            }, 0);

That should make it so the function won't insert anything into the DOM to force a redraw operation until there is available overhead in the browser. The AddFile() function is at the mercy of the jQuery File Upload callback, which will call the function for each and every file dropped onto the widget as fast as it possibly can. While there will still be DOM nodes that get created, they won't trigger a redraw operation until they get attached to the DOM itself. If that still causes problems, maybe wrap the entire interior of AddFile() with a setTimeout()?

As to a web browser crash itself, I rarely see browser crashes these days. If you are running a 32-bit web browser, you could be running up against 3-4GB RAM limitations of 32-bit software where if they run out of RAM, they will tend to be less stable. The widget isn't exactly subtle on DOM resource usage either.