{ "id": "126297", "key": "TIMOB-16450", "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": [ { "id": "14826", "description": "Release 5.1.0-remaining iOS9 features, Android M features", "name": "Release 5.1.0", "archived": false, "released": true, "releaseDate": "2015-11-20" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2015-09-16T20:51:13.000+0000", "created": "2014-02-12T00:48:49.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "SupportTeam" ], "versions": [ { "id": "16723", "description": "Windows Platform Support, ListView updates, Vector overlays in maps", "name": "Release 4.1.0", "archived": false, "released": true, "releaseDate": "2015-07-08" } ], "issuelinks": [], "assignee": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "updated": "2015-10-15T18:16:46.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "h4. Problem Description\r\nWhen using the imageAsResize function in blob, it will start eventually to fail with a warning message about no more memory available. \r\n\r\nh4. Test Code\r\n{code}\r\n var count = 0;\r\n \r\nvar win = Ti.UI.createWindow({\r\n backgroundImage : 'b1.png',\r\n layout : 'vertical'\r\n});\r\nvar closeBtn = Ti.UI.createButton({\r\n title : 'close',\r\n top : '44dp',\r\n});\r\nvar resizeBtn = Ti.UI.createButton({\r\n title : 'resize: ' + count,\r\n top : '20dp',\r\n});\r\nvar imageView = Ti.UI.createImageView({\r\n width : '200dp',\r\n height : '200dp',\r\n});\r\n \r\n//--\r\nwin.add(closeBtn);\r\nwin.add(resizeBtn);\r\nwin.add(imageView);\r\n \r\n//--\r\n \r\nresizeBtn.addEventListener('click', function() {\r\n var f = Ti.Filesystem.getFile('b1.jpg');\r\n var blob = f.read();\r\n f = null;\r\n win.remove(imageView);\r\n imageView.view = null;\r\n imageView = null; \r\n imageView = Ti.UI.createImageView({\r\n width : '200dp',\r\n height : '200dp',\r\n\t});\r\n imageView.image = blob.imageAsResized(960, 960);\r\n blob = null;\r\n win.add(imageView);\r\n count++;\r\n resizeBtn.title = 'resize: ' + count;\r\n});\r\ncloseBtn.addEventListener('click', function() {\r\n win.close();\r\n});\r\n \r\nwin.open();\r\n{code}\r\n\r\nh4. Attachments \r\nCheck the attachments for b1.jpg\r\n\r\nh4. Steps to reproduce\r\n1. Create mobile project (classic titanium)\r\n2. Copy-Paste the code from the testcase into app.js\r\n3. Copy bg1.jpg into Resources directory\r\n4. Deploy into device\r\n5. Click in resize until the image doesn't appear anymore.\r\n\r\nh4. Extra info\r\nwhen the image doesn't appear anymore, you will see a message in the console saying:\r\n\r\n{code}\r\n\r\n[ERROR] : TiBlob: (KrollRuntimeThread) [3227,231234] Unable to resize the image. Not enough memory: null\r\n[ERROR] : TiBlob: java.lang.OutOfMemoryError\r\n[ERROR] : TiBlob: \tat android.graphics.Bitmap.nativeCreate(Native Method)\r\n[ERROR] : TiBlob: \tat android.graphics.Bitmap.createBitmap(Bitmap.java:809)\r\n[ERROR] : TiBlob: \tat android.graphics.Bitmap.createBitmap(Bitmap.java:786)\r\n[ERROR] : TiBlob: \tat android.graphics.Bitmap.createBitmap(Bitmap.java:718)\r\n[ERROR] : TiBlob: \tat android.graphics.Bitmap.createScaledBitmap(Bitmap.java:594)\r\n[ERROR] : TiBlob: \tat org.appcelerator.titanium.TiBlob.imageAsResized(TiBlob.java:543)\r\n[ERROR] : TiBlob: \tat org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)\r\n[ERROR] : TiBlob: \tat org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:64)\r\n[ERROR] : TiBlob: \tat org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:884)\r\n[ERROR] : TiBlob: \tat org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1107)\r\n[ERROR] : TiBlob: \tat org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:327)\r\n[ERROR] : TiBlob: \tat android.os.Handler.dispatchMessage(Handler.java:98)\r\n[ERROR] : TiBlob: \tat android.os.Looper.loop(Looper.java:136)\r\n[ERROR] : TiBlob: \tat org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)\r\n[INFO] : I/dalvikvm-heap: Grow heap (frag case) to 182.277MB for 1474561\r\n{code} \r\n\r\nh4. Q&A Link\r\nhttp://developer.appcelerator.com/question/162431/android-memory-leaks\r\n", "attachment": [ { "id": "45831", "filename": "b1.jpg", "author": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "created": "2014-02-12T00:48:49.000+0000", "size": 2037092, "mimeType": "image/jpeg" } ], "flagged": false, "summary": "Android: imageAsResized is leaking memory", "creator": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "subtasks": [], "reporter": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "environment": "Titanium SDK 4.1.0.GA\r\nAndroid OS 4.4 Device: Nexus 4\r\nAndroid OS 4.4.2 Device: LG G2", "closedSprints": [ { "id": 485, "state": "closed", "name": "2015 Sprint 19 SDK", "startDate": "2015-09-12T00:30:29.539Z", "endDate": "2015-09-26T00:30:00.000Z", "completeDate": "2015-09-28T02:29:14.458Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "359807", "author": { "name": "samueleast", "key": "samueleast", "displayName": "Samuel East", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I am also having this problem and news...", "updateAuthor": { "name": "samueleast", "key": "samueleast", "displayName": "Samuel East", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-08-13T13:24:47.000+0000", "updated": "2015-08-13T13:24:47.000+0000" }, { "id": "364057", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "PR: https://github.com/appcelerator/titanium_mobile/pull/7197\r\n\r\nIn addition to `imageAsResized`, `imageAsThumbnail`, `imageWithAlpha`, `imageWithRoundedCorner` and `imageWithTransparentBorder` were also fixed to the memory from growing too large.\r\n\r\nTest code as above. Please test with other images and the other methods as well. The b1.jpg is quite large in general, hence for the other methods that do not resize, use a smaller image to test Alpha, Rounded Corner and TransparentBorder.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-09-16T08:37:41.000+0000", "updated": "2015-09-16T08:37:41.000+0000" }, { "id": "364136", "author": { "name": "timpoulsen", "key": "timpoulsen", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/Havana" }, "body": "I'm glad this is fixed. It would be nice if you guys would implement support for {{camera.getParameters.setPictureSize()}} in the native camera module to help with memory problems like this. I created a module for this because the Titanium camera module resulted in too many memory errors. See https://github.com/skypanther/picatsize -- which is essentially TiCamera with a few modifications. Feel free to use whatever you want from it.", "updateAuthor": { "name": "timpoulsen", "key": "timpoulsen", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/Havana" }, "created": "2015-09-17T00:18:29.000+0000", "updated": "2015-09-17T00:18:29.000+0000" }, { "id": "364141", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~timpoulsen] Thanks. I'll try to take a look into your code.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-09-17T02:16:46.000+0000", "updated": "2015-09-17T02:16:46.000+0000" }, { "id": "366949", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix.\r\n1.Tested the `imageAsResized` & `imageAsThumbnail` with the attached image which is around 1.9MB.\r\n2.Tested the imageWithAlpha`, `imageWithRoundedCorner` and `imageWithTransparentBorder` with a smaller image as these don't resize.\r\n\r\nDid not see any out of memory errors in any case with the fix.\r\n\r\nClosing.\r\n\r\nEnvironment:\r\nAppc Studio : 4.3.1.201509302304\r\nTi SDK : 5.1.0.v20151014101225\r\nTi CLI : 5.0.5\r\nAlloy : 1.7.16\r\nMAC Yosemite : 10.10.5\r\nAppc NPM : 4.2.1-1\r\nAppc CLI : 5.1.0-38\r\nNode: v0.10.37\r\nAndroid 4.2.2", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-10-15T18:16:07.000+0000", "updated": "2015-10-15T18:16:07.000+0000" } ], "maxResults": 12, "total": 12, "startAt": 0 } } }