Uploaded image for project: 'Appcelerator - INBOX'
  1. Appcelerator - INBOX
  2. AC-2611

Trying to create an image from thumbnail on Android, crashes the app on some devices.

    Details

      Description

      This crashes on the Motorola Razr running Android 4.0.4, but runs OK on a Samsung Galaxy Y running Android 2.3.6 and on a Galaxy S3 running 4.1.2.

      The code snippet is the following:

      iv = Ti.UI.createImageView();
       
       
      var takePhoto = Ti.UI.createButton({
                      title:"Take Photo",
                      width: 129,
                      height: 44,
                      top: 80,
                      left: 25,
                      idx: i
                  }, function(){
                      Ti.Media.showCamera({
          				allowEditing: false,
          				mediaTypes: Ti.Media.MEDIA_TYPE_PHOTO,
          				saveToPhotoGallery: false,
          				success: function(e){
      						iv.setImage(e.media.imageAsThumbnail(129, 0, 0));
      						
          				},
      					error: function(e) {
      						alert(e);
      					}
          			});
                  });
      

      Here is the output on logcat monitor with the full crash path:

      04-30 19:35:53.270: D/dalvikvm(13250): GC_FOR_ALLOC freed 542K, 25% free 15615K/20707K, paused 49ms
      04-30 19:35:53.270: I/dalvikvm-heap(13250): Forcing collection of SoftReferences for 31961104-byte allocation
      04-30 19:35:53.340: D/dalvikvm(13250): GC_BEFORE_OOM freed 0K, 25% free 15615K/20707K, paused 68ms
      04-30 19:35:53.340: E/dalvikvm-heap(13250): Out of memory on a 31961104-byte allocation.
      04-30 19:35:53.340: I/dalvikvm(13250): "KrollRuntimeThread" prio=5 tid=11 RUNNABLE
      04-30 19:35:53.340: I/dalvikvm(13250):   | group="main" sCount=0 dsCount=0 obj=0x41500870 self=0x21051f0
      04-30 19:35:53.340: I/dalvikvm(13250):   | sysTid=13266 nice=0 sched=0/0 cgrp=default handle=34716648
      04-30 19:35:53.340: I/dalvikvm(13250):   | schedstat=( 0 0 0 ) utm=298 stm=48 core=1
      04-30 19:35:53.340: I/dalvikvm(13250):   at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
      04-30 19:35:53.340: I/dalvikvm(13250):   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:530)
      04-30 19:35:53.340: I/dalvikvm(13250):   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:586)
      04-30 19:35:53.340: I/dalvikvm(13250):   at org.appcelerator.titanium.TiBlob.getImage(TiBlob.java:492)
      04-30 19:35:53.340: I/dalvikvm(13250):   at org.appcelerator.titanium.TiBlob.imageAsThumbnail(TiBlob.java:540)
      04-30 19:35:53.340: I/dalvikvm(13250):   at org.appcelerator.kroll.runtime.v8.V8Function.nativeInvoke(Native Method)
      04-30 19:35:53.340: I/dalvikvm(13250):   at org.appcelerator.kroll.runtime.v8.V8Function.callSync(V8Function.java:57)
      04-30 19:35:53.340: I/dalvikvm(13250):   at org.appcelerator.kroll.runtime.v8.V8Function.call(V8Function.java:43)
      04-30 19:35:53.340: I/dalvikvm(13250):   at org.appcelerator.kroll.runtime.v8.V8Function$1.run(V8Function.java:70)
      04-30 19:35:53.340: I/dalvikvm(13250):   at android.os.Handler.handleCallback(Handler.java:605)
      04-30 19:35:53.340: I/dalvikvm(13250):   at android.os.Handler.dispatchMessage(Handler.java:92)
      04-30 19:35:53.340: I/dalvikvm(13250):   at android.os.Looper.loop(Looper.java:137)
      04-30 19:35:53.340: I/dalvikvm(13250):   at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
      04-30 19:35:53.340: D/skia(13250): --- decoder->decode returned false
      04-30 19:35:53.340: W/System.err(13250): java.lang.OutOfMemoryError
      04-30 19:35:53.348: W/System.err(13250): 	at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
      04-30 19:35:53.348: W/System.err(13250): 	at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:530)
      04-30 19:35:53.348: W/System.err(13250): 	at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:586)
      04-30 19:35:53.348: W/System.err(13250): 	at org.appcelerator.titanium.TiBlob.getImage(TiBlob.java:492)
      04-30 19:35:53.348: W/System.err(13250): 	at org.appcelerator.titanium.TiBlob.imageAsThumbnail(TiBlob.java:540)
      04-30 19:35:53.348: W/System.err(13250): 	at org.appcelerator.kroll.runtime.v8.V8Function.nativeInvoke(Native Method)
      04-30 19:35:53.348: W/System.err(13250): 	at org.appcelerator.kroll.runtime.v8.V8Function.callSync(V8Function.java:57)
      04-30 19:35:53.348: W/System.err(13250): 	at org.appcelerator.kroll.runtime.v8.V8Function.call(V8Function.java:43)
      04-30 19:35:53.348: W/System.err(13250): 	at org.appcelerator.kroll.runtime.v8.V8Function$1.run(V8Function.java:70)
      04-30 19:35:53.348: W/System.err(13250): 	at android.os.Handler.handleCallback(Handler.java:605)
      04-30 19:35:53.356: W/System.err(13250): 	at android.os.Handler.dispatchMessage(Handler.java:92)
      04-30 19:35:53.356: W/System.err(13250): 	at android.os.Looper.loop(Looper.java:137)
      04-30 19:35:53.356: W/System.err(13250): 	at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
      04-30 19:35:53.512: E/TiExceptionHandler(13250): (main) [187280,278564] ----- Titanium Javascript Runtime Error -----
      04-30 19:35:53.512: E/TiExceptionHandler(13250): (main) [0,278564] - In form.js:408,49
      04-30 19:35:53.512: E/TiExceptionHandler(13250): (main) [0,278564] - Message: Uncaught Error: Java Exception occurred
      04-30 19:35:53.512: E/TiExceptionHandler(13250): (main) [0,278564] - Source: 						placeholder[changeImage].setImage(e.media.imageAsThumbnail(129, 0, 0));
      04-30 19:35:53.535: E/V8Exception(13250): Exception occurred at form.js:408: Uncaught Error: Java Exception occurred
      

        Attachments

          Activity

            People

            • Assignee:
              shossain Shak Hossain (Inactive)
              Reporter:
              ygbr Ygor Lemos
            • Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Git Integration