-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Mobile(iOS safari) crashes with multiple upload and ngf-resize enabled #1307
Comments
You can do the resizing and fixing orientation 5 at a time with delays. Remove the directives and on |
Thanks for the tips. I am still seeing crashing iphones with the following setup
If you could offer a suggestion that would be very helpful. I am starting to look at the Safari iphone web inspector, so that should help as well. |
You missed the part to split the files into chunks of 5 and do the processing sequentially.
|
Thanks, I got this working now. |
This is what I have, and it is working pretty well. However I am still seeing crashes when > 70 images are selected. I am hoping to handle upwards of 250 images at a time. Seems like the browser is still running out of memory. Any advice is much appreciated. Here is my entire controller
|
Also it seem like images are not rotated correctly. Am I missing anything with my implementation of |
You can try to make the chunk size smaller or uploading the next chunk in a $timeout to give it more time. The rotation code seems to be fine. |
Thanks again for working with me on this. It seems that chunking is not reducing the memory footprint. Running the code in this fiddle uses upwards of 1.1gb of ram for 171 images totaling 694.3 MB. It appears the promises are causing the memory to spike. Is there a way to iterate each file opening it for resizing and uploading and closing it before moving to the next file. Fiddle: http://jsfiddle.net/nwy08oak/11/ (If you select a folder full of images and monitor chrome's Task Manager, you can see the memory use. Something seems to be leaking.) Thanks |
The memory usage goes down for me once the garbage collector kicks in. Have you tried the timeout approach I mentioned? http://jsfiddle.net/nwy08oak/12/ |
I am still struggling with this. Do you have any additional suggestions? Safari on my Iphone 6 crases at about 85 images in when visiting http://jsfiddle.net/nwy08oak/12/. I think the promises are not resolving properly and garbage collection is missing them. Thanks again for all your help, |
Does it work on chrome Iphone6? |
Nope. Crashes tab. Memory uses are near 1.2gb On Friday, February 5, 2016, Danial Farid [email protected] wrote:
|
I've encountered this same issue on Chrome for OS X this morning. If I select 10-15 images at 4MB each it works fine, but if I select more (e.g. 30 or 50) it crashes. I wonder if it would help solve this issue if you set the directive to immediately start uploading images once they've been processed. It seems like currently it processes all the selected images and waits to start uploading until that task has completed. Maybe that would solve the memory issue, which is what this looks like. Update I also tested this on Chrome (latest) for Windows and it crashed with just 10 photos selected (5MB each). |
@danielbonnell what's your code? Does the jsfiddle mentioned above crashes too on windows? |
@danialfarid I didn't test the JSFiddle on Windows, just my code. In my controller I have the following
In my view I have the following button:
I just tested the JSFiddle on my Mac and I had no problem "uploading" 250+ photos. Should I be resizing the photos in my |
I refactored my Here is the function:
When I check the Chrome Task Manager I can see that at its peak, the tab was using 3.0GB of memory, vs about 146MB base usage. Not a problem on my system, but would likely crash lesser computers. |
@danialfarid I just tested that JSFiddle on Windows (Windows 7, 4GB RAM) with 42 images (5MB each) and it did NOT crash. I also tested my last code snippet on the same Windows and it crashed with 42 pictures (5MB each). On my Mac with 8GB of RAM it didn't crash, even when I threw 260+ 5MB images at it at once. |
@danielbonnell Thanks for providing some additional examples. I am hoping to use this library on a mobile application where RAM is much more sparse. My hunch is that the promises are never collected properly. @danialfarid Thanks for all your work thus far on this. Kindly let me know if this is something you think you can tackle. If not, I am happy to poke under the hood and create a pull request. |
It appears that for each
These are added to the |
@shawnzam they are not added to the document they are just created in a local var and will be garbage collected. I am pretty sure there is no memory leak but there might be some unnecessary data being stored for the purpose of caching and faster response which could be optimized like $ngfDataUrl. I will try to find those and reduce the memory consumption for the later releases. |
Thank a lot. For now I will add a cumbersome 3 second timeout for each chunk, with a chunk size for 10. This allows for ~80 images safely from my testing with mobile devices. I will limit the upload to 80 images and ask users to repeat the process for larger sets. Kindly let me know how you make out. |
@danialfarid I still suspect it may be memory related. I ran a test this morning and I noticed something peculiar. When I first load up my app I can see that it's consuming 280MB of memory. I then select 50 files to upload. As expected, the memory usages spikes up to 1.2GB. But then once the process completes, it only drops back down to 946MB, which doesn't make sense. I tried @shawnzam idea of setting a delay, which definitely seems to have improved the performance, but memory is still an issue. |
@danielbonnell it won't drop back to where it started, garbage collection is done on demand when extra memory is needed so as long as it doesn't crash if you keep this process going, like for 1000 files there is no memory leak, however holding 1000 files data in memory might consume all the available memory and make it crash. You can try repeating the process that bumped thee memory usage to 1GB several times to see if it would eventually crash. |
At version 12.0.1 I have made the plugin to use less memory for storing data urls and blob urls.
|
Thanks. I'll give it a try tomorrow. Do you still suggest we chunk the files list? |
Maybe, just try it without chunking first, and lower the queue size if it crashes to see if that helps. |
@danialfarid Thanks for the update. Can you confirm that this JSFiddle uses the preferred method for optimizing memory. http://jsfiddle.net/swqdyvs2/3/ At first glance I am not seeing any improvement in memory use. Even when modifying |
Use setDefaults instead |
I am sorry to report that this release may have made the issue worse on mobile devices. At least on an iPhone. Here is my working fiddle: http://jsfiddle.net/n5Lf4o84/2/ No matter what I setDefaults to I seem to crash the browser with < 40 images. I also tried extending the timeout from 100ms, to 1000ms, but this did not have any effect. |
So if you switch back to 11.x.x with the same fiddle it would let you upload more files until it crashes? |
Also in the fiddle you are not setting the defaults correctly. see the code I posted, setDefaults is a function not an object. Try to set the queue size to 1 like I specified above. |
I am sorry, I sent you the wrong fiddle. That was an out of date one! Even setting my |
Is it any better than the older version? Does it handle more files before it crashes? |
ng-file-upload v(12.01)
ng-file-upload v(11.2.3)
|
ok so it is about the same in both versions. Try to make the process slower, more delay and less files at a time. You can also try to splice the files that are already resized out of the files array and upload them to release the reference to those files. |
1 similar comment
ok so it is about the same in both versions. Try to make the process slower, more delay and less files at a time. You can also try to splice the files that are already resized out of the files array and upload them to release the reference to those files. |
Thanks for sticking with me on this. Do you mean slice from the |
Something like this: http://jsfiddle.net/n5Lf4o84/12/ |
Thanks, Just to fill you in that this solution does not seem to affect memory usage. I appreciate all your work, but I am not able to invest anymore time in solving this issue. If you are able to make progress, kindly update this issue, as I'll try to keep an eye on it. thx |
here is the Safari bug, if you are affected, add yourself to the CC list |
I am working with the latest version of ng-file-upload.
I have a button with the following attributes.
And a controller like so:
This seems to only work if less than 6 photos are selected from an iPhone 6. If I select more, mobile safari either crashes or reloads the page displaying a warning that something went wrong. Any idea how to solve this issue?
The text was updated successfully, but these errors were encountered: