wymsee / cordova-imagePicker

Cordova Plugin For Multiple Image Selection
MIT License
407 stars 859 forks source link

App becoming non-responsive #17

Open shai126 opened 10 years ago

shai126 commented 10 years ago

Hi

As soon as I grab the scroller and drag it down to get to old-ish photos, or do a big swipe, or even just scroll about 30 rows down in the gallery, the app freezes/crashes.

Is anyone else experiencing the app becoming totally unresponsive when scrolling far down the image gallery? Is the plugin trying to load hundreds of photos at once, not just the ones ending up in the viewport / is it not releasing the photos I've scrolled past? I'm happy to dig into the code and see what I can do to help fix, but wanted to see if anyone else has experienced this first...

(Plugin v1.0.4. Gallery has somewhere between 500 and 1000 photos. Samsung Galaxy S3, Android 4.3)

Thanks

shai126 commented 10 years ago

The exception thrown:

07-05 20:31:56.490  13175-15366/com.myapp.myapp I/dalvikvm-heap﹕ Forcing collection of SoftReferences for 499408-byte allocation
07-05 20:31:56.515  13175-15366/com.myapp.myapp I/dalvikvm-heap﹕ Clamp target GC heap from 70.173MB to 64.000MB
07-05 20:31:56.515  13175-15366/com.myapp.myapp D/dalvikvm﹕ GC_BEFORE_OOM freed <1K, 5% free 62420K/65104K, paused 28ms, total 28ms

07-05 20:31:56.515 13175-15366/com.myapp.myapp E/dalvikvm-heap﹕ Out of memory on a 499408-byte allocation.

07-05 20:31:56.515  13175-15366/com.myapp.myapp I/dalvikvm﹕ "pool-3-thread-50" prio=5 tid=75 RUNNABLE
07-05 20:31:56.515  13175-15366/com.myapp.myapp I/dalvikvm﹕ | group="main" sCount=0 dsCount=0 obj=0x429ace20 self=0x5d3c52e0
07-05 20:31:56.515  13175-15366/com.myapp.myapp I/dalvikvm﹕ | sysTid=15366 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1564235568
07-05 20:31:56.515  13175-15366/com.myapp.myapp I/dalvikvm﹕ | state=R schedstat=( 73131291 50156923 73 ) utm=5 stm=2 core=3
07-05 20:31:56.515  13175-15366/com.myapp.myapp I/dalvikvm﹕ at android.graphics.Bitmap.nativeCreate(Native Method)
07-05 20:31:56.515  13175-15366/com.myapp.myapp I/dalvikvm﹕ at android.graphics.Bitmap.createBitmap(Bitmap.java:726)
07-05 20:31:56.515  13175-15366/com.myapp.myapp I/dalvikvm﹕ at android.graphics.Bitmap.createBitmap(Bitmap.java:703)
07-05 20:31:56.515  13175-15366/com.myapp.myapp I/dalvikvm﹕ at android.graphics.Bitmap.createBitmap(Bitmap.java:636)
07-05 20:31:56.515  13175-15366/com.myapp.myapp I/dalvikvm﹕ at com.synconset.ImageFetcher$BitmapFetcherTask.doInBackground(ImageFetcher.java:199)
07-05 20:31:56.515  13175-15366/com.myapp.myapp I/dalvikvm﹕ at com.synconset.ImageFetcher$BitmapFetcherTask.doInBackground(ImageFetcher.java:164)
07-05 20:31:56.515  13175-15366/com.myapp.myapp I/dalvikvm﹕ at android.os.AsyncTask$2.call(AsyncTask.java:287)
07-05 20:31:56.515  13175-15366/com.myapp.myapp I/dalvikvm﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:234)
07-05 20:31:56.515  13175-15366/com.myapp.myapp I/dalvikvm﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
07-05 20:31:56.515  13175-15366/com.myapp.myapp I/dalvikvm﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
07-05 20:31:56.515  13175-15366/com.myapp.myapp I/dalvikvm﹕ at java.lang.Thread.run(Thread.java:841)
07-05 20:31:56.515  13175-15366/com.myapp.myapp I/dalvikvm﹕ [ 07-05 20:31:56.545 13175:15360 I/dalvikvm-heap ]
    Clamp target GC heap from 69.681MB to 64.000MB
07-05 20:31:56.545  13175-15366/com.myapp.myapp W/dalvikvm﹕ threadid=75: thread exiting with uncaught exception (group=0x41c45700)

If I comment out the fetcher.fetch(Integer.valueOf(id), imageView, colWidth, rotate); there's no crash (but also no images of course!) so the memory issue is in the fetching of the bitmaps...

Anyone have any ideas of where to look? Might there be some memory that can be released that isn't?

Thanks again

CSullivan102 commented 10 years ago

We've merged PR #24 into master for version 1.0.5 if you want to check that out.