UNICEF-Youth-Section/Locast-Android — Issue #11: OOM: CastEdit: crash after trying to replace photo
Author: xxv
Created: 2012-01-19 17:55:51+00:00
State: open
Labels: bug

Steps to reproduce:

1. Start UNICEF GIS
2. click on a map
3. On CastEdit screen, add a photo
4. take photo, commit and return to CastEdit screen
5. press the photo button
6. take photo, commit

app crashes due to the following:

```
I/ActivityManager( 133): Starting activity: Intent { act=android.media.action.IMAGE_CAPTURE cmp=com.android.camera/.ServiceEntry (has extras) } from pid 10374
D/CastEdit(10374): updating content://edu.mit.mobile.android.locast.ver2.provider/itineraries/1/casts/86 with draft=true lon=-71.088163 title= lat=42.360825 modified=1326995304210
D/CastEdit(10374): cast URI iscontent://edu.mit.mobile.android.locast.ver2.provider/itineraries/1/casts/86
I/ActivityManager( 133): Displayed com.android.camera/.ServiceEntry: +531ms
E/QualcommCameraHardware( 73): rotaion = 90
E/HTCCamera( 6260): setSaveDone() - mActionScreen == null
D/CastEdit(10374): addMedia(content://edu.mit.mobile.android.locast.ver2.provider/itineraries/1/casts/86/media, local_uri=file:///sdcard/locast/1326995304170.jpg mimetype=image/jpeg title=1326995304170.jpg created=1326995312671 local_thumb=file:///sdcard/locast/1326995304170.jpg modified=1326995312671)
E/dalvikvm-heap(10374): 8957952-byte external allocation too large for this process.
E/dalvikvm(10374): Out of memory: Heap Size=6343KB, Allocated=3517KB, Bitmap Size=8907KB, Limit=20480KB
E/dalvikvm(10374): Trim info: Footprint=6343KB, Allowed Footprint=6343KB, Trimmed=604KB
E/GraphicsJNI(10374): VM won't let us allocate 8957952 bytes
E/AndroidRuntime(10374): FATAL EXCEPTION: main
E/AndroidRuntime(10374): java.lang.OutOfMemoryError: bitmap size exceeds VM budget(Heap Size=7879KB, Allocated=3513KB, Bitmap Size=8907KB)
E/AndroidRuntime(10374):	at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
E/AndroidRuntime(10374):	at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:694)
E/AndroidRuntime(10374):	at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:494)
E/AndroidRuntime(10374):	at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
E/AndroidRuntime(10374):	at android.graphics.drawable.Drawable.createFromStream(Drawable.java:657)
E/AndroidRuntime(10374):	at android.widget.ImageView.resolveUri(ImageView.java:584)
E/AndroidRuntime(10374):	at android.widget.ImageView.setImageURI(ImageView.java:305)
E/AndroidRuntime(10374):	at edu.mit.mobile.android.locast.ver2.casts.CastEdit.onActivityResult(CastEdit.java:461)
E/AndroidRuntime(10374):	at android.app.Activity.dispatchActivityResult(Activity.java:4108)
E/AndroidRuntime(10374):	at android.app.ActivityThread.deliverResults(ActivityThread.java:2914)
E/AndroidRuntime(10374):	at android.app.ActivityThread.handleSendResult(ActivityThread.java:2970)
E/AndroidRuntime(10374):	at android.app.ActivityThread.access$2000(ActivityThread.java:132)
E/AndroidRuntime(10374):	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1068)
E/AndroidRuntime(10374):	at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(10374):	at android.os.Looper.loop(Looper.java:150)
E/AndroidRuntime(10374):	at android.app.ActivityThread.main(ActivityThread.java:4277)
E/AndroidRuntime(10374):	at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(10374):	at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(10374):	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime(10374):	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime(10374):	at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 133): Force finishing activity edu.mit.mobile.android.locast.ver2/.casts.CastEdit
W/ActivityManager( 133): Activity pause timeout for HistoryRecord{40aaae08 edu.mit.mobile.android.locast.ver2/.casts.CastEdit}
I/ActivityManager( 133): Process edu.mit.mobile.android.locast.ver2 (pid 10374) has died.
```

I suspect this means that we'll need to use a resized to thumbnail size before putting it in the ImageView. The ImageCache module should be able to do that efficiently.

Device: HTC Wildfire S (mdpi device, not a ton of memory.)