{ "id": "136395", "key": "TIMOB-17674", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "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": "2014-09-10T19:40:16.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [ "Android", "ImageView", "TCSupport" ], "versions": [ { "id": "15422", "description": "Release 3.3.0", "name": "Release 3.3.0", "archived": false, "released": true, "releaseDate": "2014-07-16" } ], "issuelinks": [], "assignee": null, "updated": "2018-02-28T20:04:10.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": "If an application has two different images with urls/paths that map to the same hash code at java.lang.String level then Ti.UI.ImageView can show the wrong one.\r\n\r\nTiUIImageView internally uses a memory cache for the Bitmaps with TiDrawableReference.hashCode() as keys. In case of an url-based drawable reference TiDrawableReference.hashCode() turns into a simple java.lang.String.hashCode(url) wrapper.\r\n\r\nSee line 115 of\r\nhttps://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/titanium/view/TiDrawableReference.java\r\nand line 694 of\r\nhttps://github.com/appcelerator/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIImageView.java \r\n\r\njava.lang.String.hashCode() is very likely to generate collisions.\r\nThe following code prints the same number for both urls.\r\n{code}\r\n\tpublic static void main(String[] args)\r\n\t{\r\n\t\tint h1 = \"file:///data/data/it.xenesys.Nomination/app_appdata/ITEMFASHION_0002TW1.png\".hashCode();\r\n\t\tint h2 = \"file:///data/data/it.xenesys.Nomination/app_appdata/ITEMFASHION_0002TVP.png\".hashCode();\r\n\t\tSystem.out.println(\"Hash code 1: \" + Integer.toString(h1));\r\n\t\tSystem.out.println(\"Hash code 2: \" + Integer.toString(h2));\r\n\t}\r\n{code}\r\n\r\nThe cache should use a stronger hashing algorithm (such as SHA1) and possibly add more data to be hashed (the file size?).\r\n", "attachment": [], "flagged": false, "summary": "Android: On Android Ti.UI.ImageView can show the wrong image (cache bug, explained)", "creator": { "name": "s.stefanek", "key": "s.stefanek", "displayName": "Szymon Tomasz Stefanek", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "s.stefanek", "key": "s.stefanek", "displayName": "Szymon Tomasz Stefanek", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Titanium 3.3.0GA\r\nLinux Ubuntu 13.04\r\nAndroid", "comment": { "comments": [ { "id": "328566", "author": { "name": "l0wb1rd", "key": "l0wb1rd", "displayName": "Low Bird", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This also happens with BLOB type images sometimes. If you build a gallery from the mediastore (MICRO_KIND blobs) with lots of imageviews, you falsely hit the cach very quickly.", "updateAuthor": { "name": "l0wb1rd", "key": "l0wb1rd", "displayName": "Low Bird", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-10-20T06:36:23.000+0000", "updated": "2014-10-20T06:36:23.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }