Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23218] Android: OutOfMemoryError in ImageView.toBlob

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionCannot Reproduce
Resolution Date2019-11-19T18:48:40.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
LabelsAndroid, Android5, Android6.0, ImageView, OutOfMemory, engTriage, toBlob
ReporterAndrey Tkachenko
AssigneeUnknown
Created2016-04-08T06:06:38.000+0000
Updated2019-11-19T18:48:40.000+0000

Description

I got OutOfMemory with this code. Steps to reproduce: 1. Create default Alloy project 2. Load and save big image to the assets 3. Add this test code to the click event handler 4. Click several times to the view with click event attached 5. See result in log Image: https://static.pexels.com/photos/479/landscape-nature-sunset-trees.jpg
var iv = Ti.UI.createImageView({
	width : Ti.UI.SIZE,
	height : Ti.UI.SIZE,
	image : '/images/landscape-nature-sunset-trees.jpg'
});
var blob = iv.toBlob();
iv.image = null;
iv = null;
Ti.API.info('OK!');
[ERROR] TiDrawableReference: (KrollRuntimeThread) [6078,6078] Unable to load bitmap. Not enough memory: Failed to allocate a 23887884 byte allocation with 8219096 free bytes and 7MB until OOM
[ERROR] TiDrawableReference: java.lang.OutOfMemoryError: Failed to allocate a 23887884 byte allocation with 8219096 free bytes and 7MB until OOM
[ERROR] TiDrawableReference: 	at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
[ERROR] TiDrawableReference: 	at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
[ERROR] TiDrawableReference: 	at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
[ERROR] TiDrawableReference: 	at org.appcelerator.titanium.view.TiDrawableReference.getBitmap(TiDrawableReference.java:348)
[ERROR] TiDrawableReference: 	at org.appcelerator.titanium.view.TiDrawableReference.getBitmap(TiDrawableReference.java:300)
[ERROR] TiDrawableReference: 	at ti.modules.titanium.ui.widget.TiUIImageView.toBlob(TiUIImageView.java:947)
[ERROR] TiDrawableReference: 	at ti.modules.titanium.ui.ImageViewProxy.toBlob(ImageViewProxy.java:93)
[ERROR] TiDrawableReference: 	at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
[ERROR] TiDrawableReference: 	at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62)
[ERROR] TiDrawableReference: 	at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:918)
[ERROR] TiDrawableReference: 	at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1141)
[ERROR] TiDrawableReference: 	at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:356)
[ERROR] TiDrawableReference: 	at android.os.Handler.dispatchMessage(Handler.java:98)
[ERROR] TiDrawableReference: 	at android.os.Looper.loop(Looper.java:148)
[ERROR] TiDrawableReference: 	at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:118)

Comments

  1. Nazmus Salahin 2016-04-10

    Hello, I am unable to reproduce this issue on Nexus 7 using the sample code and given steps. I tried with sdk 5.2.2.GA and 5.4.0 but got same result. I used the given image for testing. My index.js file is as follows.
       function doClick(e) {
       	Ti.API.info('Starting...');
       	var iv = Ti.UI.createImageView({
       
       		width : Ti.UI.SIZE,
       
       		height : Ti.UI.SIZE,
       
       		image : '/images/landscape-nature-sunset-trees.jpg'
       
       	});
       
       	var blob = iv.toBlob();
       
       	iv.image = null;
       
       	iv = null;
       	
       
       	Ti.API.info('OK!');
       
       }
       
       $.index.open();
       
       
    After building the app when I clicked the view several times at once the following console log is produced. *Console Log:*
       [INFO] :   Starting...
       [INFO] :   OK!
       [INFO] :   Starting...
       [WARN] :   art: Suspending all threads took: 5.523ms
       [INFO] :   art: Background partial concurrent mark sweep GC freed 49(9KB) AllocSpace objects, 2(12MB) LOS objects, 16% free, 80MB/96MB, paused 6.286ms total 26.184ms
       [INFO] :   OK!
       [INFO] :   Starting...
       [INFO] :   OK!
       [INFO] :   Starting...
       [INFO] :   OK!
       [INFO] :   Starting...
       [INFO] :   OK!
       [INFO] :   Starting...
       [WARN] :   art: Suspending all threads took: 19.805ms
       [INFO] :   art: Background partial concurrent mark sweep GC freed 29(9KB) AllocSpace objects, 4(12MB) LOS objects, 12% free, 109MB/125MB, paused 20.721ms total 40.740ms
       [INFO] :   OK!
       
    *Environment*: *Device info:* Nexux7 (android 6.0.1) *Node.js Version:* 0.12.7 *npm Version:* 2.11.3 *Titanium SDKs:* 5.2.2.GA and 5.2.1.GA *Java Development Kit Version:* 1.8.0_73 *Titanium CLI Version:* 5.0.5 *Appcelerator CLI Version:* 5.2.2 *Appcelerator Studio:* 4.4.0.201511241829
  2. Andrey Tkachenko 2016-04-15

    Can be reviewed?
  3. Andrey Tkachenko 2016-04-18

    @Nazmus Salahin can you try in genymotion emulator?
  4. John Staunton 2018-05-29

    I get the same thing in Genymotion emulator and on pretty much any x86 device (tried 3 different ones)
  5. Alan Hutton 2019-11-19

    Closing issue as “Cannot Reproduce”. Although the URL links is no longer available we tested with a large image. Axway Appcelerator Studio, build: 5.1.4.201909061933  macOS : 10.15 Node.js Version : 8.9.1 npm Version : 5.5.1 Appcelerator CLI : 7.1.1 Titanium CLI CLI Version : 5.2.1 node-appc Version : 0.2.49 Titanium SDKs : 8.2.1.GA

JSON Source