Hi,
I have the latest version of studio and I'm having an issue with loading and image from a local file on droid. I cannot reproduce the error on IOS. Here's what I'm doing
1) I select a photo from the gallery with
var x = Titanium.Media.openPhotoGallery({ mediaTypes:[Ti.Media.MEDIA_TYPE_PHOTO], success:function(event) { var BlogPost = require("BlogPost"); var image = event.media; setPhotoData(image); // var newWin = newWin = Alloy.createController("Contribute").getView(); var newWinName = "Contribute"; var WindowManager = require("WindowManager"); WindowManager.openSlideLeft(newWinName); // windowManager.push(newWin); // newWin.open(); } });2) I compress and save the photo to the local disk with
// compress the photo and save it to disk var ImageFactory = require('ti.imagefactory'); var smallImage = ImageFactory.compress(img, BlogPost.photoCompression); var filename = Titanium.Filesystem.applicationDataDirectory + BlogPost.localDiskPhotoFileName; f = Titanium.Filesystem.getFile(filename); f.write(smallImage);3) I display the image with
$.imgBlogPhoto.image = null; var filename = Titanium.Filesystem.applicationDataDirectory + BlogPost.localDiskPhotoFileName; f = Titanium.Filesystem.getFile(filename); $.imgBlogPhoto.image = f.read(); Ti.API.info ( "Image File Size = " + f.size); f = null;I can reproduce the issue by doing Step 1 and 2 one time, and repeating step 3 several times. Other posts say that this is an emulator issue but I have confirmed it happens when its installed on my phone. I also have printed out my image disk file size and available memory and both are OK when the issue occurs.
Thanks
Here's my log file:
[INFO] : Available Memory = 2558448 [INFO] : Image File Size = 35270 [INFO] : I/dalvikvm-heap: Clamp target GC heap from 32.408MB to 32.000MB [INFO] : I/dalvikvm-heap: Clamp target GC heap from 32.757MB to 32.000MB [INFO] : I/dalvikvm-heap: Clamp target GC heap from 32.773MB to 32.000MB [WARN] : TiUIScrollView: (main) [2518,79237] Scroll direction could not be determined based on the provided view properties. Default VERTICAL scroll direction being used. Use the 'scrollType' property to explicitly set the scrolling direction. [INFO] : Available Memory = 2596512 [INFO] : Image File Size = 35270 [ERROR] : E/dalvikvm-heap: 611840-byte external allocation too large for this process. [INFO] : I/dalvikvm-heap: Clamp target GC heap from 33.269MB to 32.000MB [ERROR] : GraphicsJNI: VM won't let us allocate 611840 bytes [ERROR] : TiDrawableReference: (pool-3-thread-2) [81,79318] Unable to load bitmap. Not enough memory: bitmap size exceeds VM budget [ERROR] : TiDrawableReference: java.lang.OutOfMemoryError: bitmap size exceeds VM budget [ERROR] : TiDrawableReference: at android.graphics.BitmapFactory.nativeDecodeStream(Native Method) [ERROR] : TiDrawableReference: at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:470) [ERROR] : TiDrawableReference: at org.appcelerator.titanium.view.TiDrawableReference.getBitmap(TiDrawableReference.java:324) [ERROR] : TiDrawableReference: at org.appcelerator.titanium.util.TiLoadImageManager$LoadImageJob.run(TiLoadImageManager.java:128) [ERROR] : TiDrawableReference: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088) [ERROR] : TiDrawableReference: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)