{ "id": "133432", "key": "AC-1269", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2014-07-31T00:32:02.000+0000", "created": "2014-07-20T14:02:36.000+0000", "labels": [ "android", "defect" ], "versions": [], "issuelinks": [ { "id": "39437", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "inwardIssue": { "id": "130892", "key": "TIMOB-17089", "fields": { "summary": "Android: Activity/Fragment restore can sometimes crash app due to view ID collision", "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" } }, "priority": { "name": "Critical", "id": "1" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "updated": "2016-03-08T07:37:39.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": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "I met a crash while the crash log show below:\r\n{quote}\r\njava.lang.RuntimeException: Unable to start activity :java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.widget.AbsListView$SavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/0x65. Make sure other views do not use the same id.\r\nat android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)\r\nat android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2317)\r\nat android.app.ActivityThread.access$600(ActivityThread.java:151)\r\nat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1299)\r\nat android.os.Handler.dispatchMessage(Handler.java:99)\r\n{quote}\r\nAfter analysis, I found that crash caused by a magic number 101(0x65), code like below.\r\n\r\n1. \r\n{quote}\r\npublic class TiTableView extends FrameLayout\r\n\timplements OnSearchChangeListener\r\n{\r\n\t{color:red}public static final int TI_TABLE_VIEW_ID = 101;{color}\r\n\tprivate static final String TAG = \"TiTableView\";\r\n{quote}\r\n2. \r\n{quote}\r\npublic class TiTableViewHeaderItem extends TiBaseTableViewItem\r\n{\r\n\tprivate RowView rowView;\r\n\tprivate TiUIView headerView;\r\n\tprivate boolean isHeaderView = false;\r\n\r\n\tclass RowView extends RelativeLayout\r\n\t{\r\n\t\tprivate TextView textView;\r\n\t\tprivate Item item;\r\n\r\n\t\tpublic RowView(Context context)\r\n\t\t{\r\n\t\t\tsuper(context);\r\n\t\t\tsetGravity(Gravity.CENTER_VERTICAL);\r\n\r\n\t\t\ttextView = new TextView(context);\r\n\t\t\t{color:red}textView.setId(101);{color}\r\n{quote}\r\n\tWhile the App hide in background, for any reason(like system GC), part of app memory released. At this time when the app re-launch from background, it will trigger onRestoreInstanceState, like below logs with 101=xxxx, it must be one of user-defined component, but both system and user-defined ids repetition, crash happen:\r\n{quote}\r\n[INFO] : TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: Bundle[{android:viewHierarchyState=Bundle[{android:views={7=android.view.AbsSavedState$1@41959308, 12=android.view.AbsSavedState$1@41959308, 13=android.view.AbsSavedState$1@41959308, 14=android.view.AbsSavedState$1@41959308, 15=android.view.AbsSavedState$1@41959308, 16=android.view.AbsSavedState$1@41959308, 17=android.view.AbsSavedState$1@41959308, 18=android.view.AbsSavedState$1@41959308, 19=android.view.AbsSavedState$1@41959308, 20=android.view.AbsSavedState$1@41959308, 21=android.view.AbsSavedState$1@41959308, 22=android.view.AbsSavedState$1@41959308, 23=android.view.AbsSavedState$1@41959308, 24=android.view.AbsSavedState$1@41959308, 25=android.view.AbsSavedState$1@41959308, 26=android.view.AbsSavedState$1@41959308, 27=android.view.AbsSavedState$1@41959308, 28=android.view.AbsSavedState$1@41959308, 29=android.view.AbsSavedState$1@41959308, 30=android.view.AbsSavedState$1@41959308, 31=android.view.AbsSavedState$1@41959308, 32=android.view.AbsSavedState$1@41959308, 33=android.view.AbsSavedState$1@41959308, 34=android.view.AbsSavedState$1@41959308, 35=android.view.AbsSavedState$1@41959308, 36=android.view.AbsSavedState$1@41959308, 37=android.view.AbsSavedState$1@41959308, 38=android.view.AbsSavedState$1@41959308, 39=android.view.AbsSavedState$1@41959308, 41=android.view.AbsSavedState$1@41959308, 42=android.view.AbsSavedState$1@41959308, 43=android.view.AbsSavedState$1@41959308, 44=android.view.AbsSavedState$1@41959308, 45=android.view.AbsSavedState$1@41959308, 46=android.view.AbsSavedState$1@41959308, 47=android.view.AbsSavedState$1@41959308, 48=android.view.AbsSavedState$1@41959308, 49=android.view.AbsSavedState$1@41959308, 50=android.view.AbsSavedState$1@41959308, 51=android.view.AbsSavedState$1@41959308, 52=android.view.AbsSavedState$1@41959308, 53=android.view.AbsSavedState$1@41959308, 54=android.view.AbsSavedState$1@41959308, 55=android.view.AbsSavedState$1@41959308, 56=android.view.AbsSavedState$1@41959308, 57=android.view.AbsSavedState$1@41959308, 58=android.view.AbsSavedState$1@41959308, 59=android.view.AbsSavedState$1@41959308, 60=android.view.AbsSavedState$1@41959308, 61=android.view.AbsSavedState$1@41959308, 63=android.view.AbsSavedState$1@41959308, 64=TextView.SavedState{44f7b300 start=0 end=0 text= locale=zh-TW}, 65=android.view.AbsSavedState$1@41959308, 66=android.view.AbsSavedState$1@41959308, 68=android.view.AbsSavedState$1@41959308, 69=android.view.AbsSavedState$1@41959308, 70=android.view.AbsSavedState$1@41959308, 71=android.view.AbsSavedState$1@41959308, 72=android.view.AbsSavedState$1@41959308, 73=android.view.AbsSavedState$1@41959308, 74=android.view.AbsSavedState$1@41959308, 75=android.view.AbsSavedState$1@41959308, 76=android.view.AbsSavedState$1@41959308, 77=android.view.AbsSavedState$1@41959308, 78=android.view.AbsSavedState$1@41959308, 79=android.view.AbsSavedState$1@41959308, 80=android.view.AbsSavedState$1@41959308, 81=android.view.AbsSavedState$1@41959308, 82=android.view.AbsSavedState$1@41959308, 83=android.view.AbsSavedState$1@41959308, 84=android.view.AbsSavedState$1@41959308, 85=android.view.AbsSavedState$1@41959308, 86=android.view.AbsSavedState$1@41959308, 87=android.view.AbsSavedState$1@41959308, 88=android.view.AbsSavedState$1@41959308, 89=android.view.AbsSavedState$1@41959308, 90=android.view.AbsSavedState$1@41959308, 91=android.view.AbsSavedState$1@41959308, 92=android.view.AbsSavedState$1@41959308, 93=android.view.AbsSavedState$1@41959308, 94=android.view.AbsSavedState$1@41959308, 95=android.view.AbsSavedState$1@41959308, 96=android.view.AbsSavedState$1@41959308, 97=android.view.AbsSavedState$1@41959308, 98=android.view.AbsSavedState$1@41959308, 99=android.view.AbsSavedState$1@41959308, 100=android.view.AbsSavedState$1@41959308, {color:red}101=AbsListView.SavedState{44f8f800 selectedId=-9223372036854775808 firstId=-1 viewTop=0 position=0 height=540 filter=null checkState=null}, {color}102=android.view.AbsSavedState$1@41959308, 103=android.view.AbsSavedState$1@41959308, 104=android.view.AbsSaved\r\n{quote}\r\n\tI patched the SDK, change the id to a random big number, it would not crash now, but it is not a good solution, pls. handle it.", "attachment": [], "flagged": false, "summary": "App crashed and the crash log show \"This view's id is id/0x65\".", "creator": { "name": "plan9@qq.com", "key": "plan9@qq.com", "displayName": "Minglei Chen", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "plan9@qq.com", "key": "plan9@qq.com", "displayName": "Minglei Chen", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "TiSDK 3.2.3", "comment": { "comments": [ { "id": "314963", "author": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "body": "Hi, \r\n\r\nWould you please us a test case for this problem, that will be really helpful. Thanks.\r\n\r\nRegards,\r\nShuo", "updateAuthor": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "created": "2014-07-21T02:32:37.000+0000", "updated": "2014-07-21T02:32:37.000+0000" }, { "id": "315946", "author": { "name": "plan9@qq.com", "key": "plan9@qq.com", "displayName": "Minglei Chen", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This can be easily reproduced like this: build an application with many text views, at least 101. Add one table view. Now to cause the state restore, move the application to the back, enter system settings -> display -> font size, and change the size. Open the task list and select your app to bring it to front. The font size change will cause view state recalculation which will crash the app.", "updateAuthor": { "name": "plan9@qq.com", "key": "plan9@qq.com", "displayName": "Minglei Chen", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-07-28T06:02:24.000+0000", "updated": "2014-07-28T06:02:24.000+0000" }, { "id": "315947", "author": { "name": "plan9@qq.com", "key": "plan9@qq.com", "displayName": "Minglei Chen", "active": true, "timeZone": "America/Los_Angeles" }, "updateAuthor": { "name": "plan9@qq.com", "key": "plan9@qq.com", "displayName": "Minglei Chen", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-07-28T06:03:32.000+0000", "updated": "2014-07-28T06:03:32.000+0000" }, { "id": "316368", "author": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "updateAuthor": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "created": "2014-07-31T00:32:02.000+0000", "updated": "2014-07-31T00:32:02.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }