{ "id": "165818", "key": "TIMOB-24379", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2017-02-07T13:22:11.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [], "versions": [], "issuelinks": [ { "id": "58843", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "166770", "key": "TIMOB-24528", "fields": { "summary": "Android: Fails to load images that exceed GPU max texture size", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2020-10-26T18:07:47.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "I'm running into an issue when testing a fullscreen-photo in my [\"Studentenfutter\" sample app|https://github.com/hansemannn/studentenfutter-app]. It works the first time, displays a black/blank background on the second time and crashes on the third time:\r\n\r\n{code}\r\n[DEBUG] Window: Checkpoint: postWindowCreated()\r\n[INFO] art: Clamp target GC heap from 103MB to 96MB\r\n[INFO] art: Alloc partial concurrent mark sweep GC freed 579(33KB) AllocSpace objects, 1(16KB) LOS objects, 8%% free, 87MB/96MB, paused 373us total 8.788ms\r\n[INFO] art: Clamp target GC heap from 103MB to 96MB\r\n[INFO] art: Alloc concurrent mark sweep GC freed 264(23KB) AllocSpace objects, 0(0B) LOS objects, 8%% free, 87MB/96MB, paused 178us total 10.782ms\r\n[INFO] art: Forcing collection of SoftReferences for 20MB allocation\r\n[INFO] art: Clamp target GC heap from 103MB to 96MB\r\n[INFO] art: Alloc concurrent mark sweep GC freed 3(144B) AllocSpace objects, 0(0B) LOS objects, 8%% free, 87MB/96MB, paused 126us total 9.588ms\r\n[ERROR] art: Throwing OutOfMemoryError \"Failed to allocate a 21313932 byte allocation with 8775660 free bytes and 8MB until OOM\"\r\n[DEBUG] skia: --- decoder->decode returned false\r\n[ERROR] TiDrawableReference: (pool-3-thread-1) [34,11127] Unable to load bitmap. Not enough memory: Failed to allocate a 21313932 byte allocation with 8775660 free bytes and 8MB until OOM\r\n[ERROR] TiDrawableReference: java.lang.OutOfMemoryError: Failed to allocate a 21313932 byte allocation with 8775660 free bytes and 8MB until OOM\r\n[ERROR] TiDrawableReference: \tat dalvik.system.VMRuntime.newNonMovableArray(Native Method)\r\n[ERROR] TiDrawableReference: \tat android.graphics.BitmapFactory.nativeDecodeStream(Native Method)\r\n[ERROR] TiDrawableReference: \tat android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:635)\r\n[ERROR] TiDrawableReference: \tat android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:611)\r\n[ERROR] TiDrawableReference: \tat org.appcelerator.titanium.view.TiDrawableReference.getBitmap(TiDrawableReference.java:348)\r\n[ERROR] TiDrawableReference: \tat org.appcelerator.titanium.view.TiDrawableReference.getBitmap(TiDrawableReference.java:300)\r\n[ERROR] TiDrawableReference: \tat org.appcelerator.titanium.util.TiLoadImageManager$LoadImageJob.run(TiLoadImageManager.java:128)\r\n[ERROR] TiDrawableReference: \tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)\r\n[ERROR] TiDrawableReference: \tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)\r\n[ERROR] TiDrawableReference: \tat java.lang.Thread.run(Thread.java:818)\r\n[INFO] art: Clamp target GC heap from 103MB to 96MB\r\n[INFO] art: Explicit concurrent mark sweep GC freed 68(19KB) AllocSpace objects, 1(16KB) LOS objects, 8%% free, 87MB/96MB, paused 191us total 8.591ms\r\n[WARN] EGL_emulation: eglSurfaceAttrib not implemented\r\n[WARN] OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xdf0a7f60, error=EGL_SUCCESS\r\n[DEBUG] skia: --- SkImageDecoder::Factory returned null\r\n[DEBUG] skia: --- SkImageDecoder::Factory returned null\r\n[DEBUG] skia: --- SkImageDecoder::Factory returned null\r\n[DEBUG] skia: --- SkImageDecoder::Factory returned null\r\n[INFO] art: Alloc partial concurrent mark sweep GC freed 2075(130KB) AllocSpace objects, 4(20MB) LOS objects, 19%% free, 67MB/83MB, paused 175us total 9.134ms\r\n[INFO] art: Alloc concurrent mark sweep GC freed 7(192B) AllocSpace objects, 0(0B) LOS objects, 19%% free, 67MB/83MB, paused 117us total 8.259ms\r\n[INFO] art: Forcing collection of SoftReferences for 40MB allocation\r\n[INFO] art: Alloc concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 19%% free, 67MB/83MB, paused 131us total 7.863ms\r\n[ERROR] art: Throwing OutOfMemoryError \"Failed to allocate a 42627852 byte allocation with 16777216 free bytes and 28MB until OOM\"\r\n[DEBUG] skia: --- decoder->decode returned false\r\n[WARN] EGL_emulation: eglSurfaceAttrib not implemented\r\n[WARN] OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xdf0aa920, error=EGL_SUCCESS\r\n[DEBUG] Window: Window is closed normally.\r\n{code}\r\n\r\nThe image it is trying to load is [this one|http://api.studentenfutter-os.de//_Resources//Persistent//e0132881499cbd44e5b7ef68f9427a55548c85ba//01486472627.jpeg]\r\n\r\nTo reproduce, just clone the repo and run the app in the Simulator.", "attachment": [], "flagged": false, "summary": "Android: Image Views not releasing memory, resulting in crash", "creator": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "environment": "SDK 6.0.1.GA\r\nGoogle Nexus 5, Android 5.0.0 (API 21)", "comment": { "comments": [ { "id": "406727", "author": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~hansknoechel] I cannot reproduce using your app. I even tried to load a 23MB (7016x9933) JPEG in ImageView which worked fine.\r\n\r\n{code:js}\r\nvar win = Ti.UI.createWindow({backgroundColor: 'gray'}),\r\n img = Ti.UI.createImageView({\r\n width: Ti.UI.FILL,\r\n height: Ti.UI.FILL,\r\n image: 'http://www.eso.org/public/archives/print_posters/large/print_poster_0047.jpg'\r\n });\r\n\r\nwin.add(img);\r\nwin.open();\r\n{code}", "updateAuthor": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-02-09T12:52:07.000+0000", "updated": "2017-02-09T12:52:07.000+0000" }, { "id": "406728", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Did you open the window multiple times? And please note I've only tested on the Simulator, so it might only happen to devices with low RAM.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-02-09T12:55:44.000+0000", "updated": "2017-02-09T12:55:44.000+0000" }, { "id": "416631", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hey [~jquick], could this also be related to your ticket TIMOB-24528?", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-04-01T10:34:49.000+0000", "updated": "2017-04-01T10:34:49.000+0000" }, { "id": "416769", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The issue here is that Titanium is not calling Bitmap.recycle() on the ImageView's drawable bitmap when we're done using it. Calling the Java Bitmap.recycle() method will immediately delete the bitmap from memory on the C/C++ side (images are actually loaded via libpng and libjpeg on Android). As it is now, we have to wait for the Java garbage collector to recycle it for us.\r\n\r\nThe solution for [TIMOB-24528] will help apps load very large images that are too large to be displayed by the GPU or UI. It won't solve OutOfMemory exception issues (but can help reduce it in certain situations). Since the referenced app displays camera shots, this will help the app display images on certain Android devices that always fail to display the taken photo (ie: where the camera megapixel count exceeds the GPU's max texture size).", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-04-04T17:52:25.000+0000", "updated": "2017-04-04T17:52:25.000+0000" }, { "id": "440622", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~jquick] Is there a workaround for this btw? I really would love to show full-screen images in my canteen app. It actually crashes with remote images, I am not sure this was clear so far.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-08-09T17:34:43.000+0000", "updated": "2018-08-09T17:34:43.000+0000" }, { "id": "440626", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "You should be able to work-around it via hyperloop if you're willing.\r\n\r\nPart of the problem here is that we have \"TiImageLruCache\" which keeps hard references to previously displayed images such as photos. We should get rid of our LRU cache in the future since it's not our job to decide which images should remain in memory. It's the Titanium developer's job to do that... and they can retain the references in a portable way via blobs in JavaScript. But for now, we need to trigger the Java code to clear the LRU cache before loading the next photo.\r\n\r\nSo, what you need to do in hyperloop is call our {{TiAppllication.onLowMemory()}} method. That will clear the LRU cache.\r\nhttps://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/titanium/TiApplication.java#L390\r\n\r\nYou can get a hold of a {{TiApplication}} instance by fetching the current activity and calling the Java {{Activity.getApplication()}} method. Our {{TiApplication}} Java class inherits from {{Application}}.\r\nhttps://developer.android.com/reference/android/app/Activity.html#getApplication()\r\n", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-08-09T19:48:36.000+0000", "updated": "2018-08-09T19:48:36.000+0000" }, { "id": "440629", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Unfortunately it crashes with the 1st image already. And interestingly, the scrollview in which the Image View of my App is embedded in takes like 6s to process before displaying.\r\n ", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-08-09T21:58:12.000+0000", "updated": "2018-08-09T21:58:12.000+0000" }, { "id": "440630", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "If it's with the 1st image, then that's a different issue.\r\nIs it blocking for 6 seconds or is it still working async?\r\nDo you have a stack trace? (Or is the trace on the ticket the error you're running in to?)\r\n\r\nAlso, I know my refactored image handling from last year (PR below) is better at this. Would you mind giving it a try if possible (might be too old to deal with; so I can understand if you don't).\r\nhttps://github.com/appcelerator/titanium_mobile/pull/8951\r\n", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-08-09T22:22:19.000+0000", "updated": "2018-08-09T22:23:28.000+0000" } ], "maxResults": 10, "total": 10, "startAt": 0 } } }