{ "id": "129942", "key": "TIMOB-16968", "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": "16270", "description": "2014 Sprint 10", "name": "2014 Sprint 10", "archived": true, "released": true, "releaseDate": "2014-05-22" }, { "id": "16271", "description": "2014 Sprint 10 SDK", "name": "2014 Sprint 10 SDK", "archived": true, "released": true, "releaseDate": "2014-05-22" }, { "id": "15422", "description": "Release 3.3.0", "name": "Release 3.3.0", "archived": false, "released": true, "releaseDate": "2014-07-16" }, { "id": "15972", "description": "Release 3.4.0", "name": "Release 3.4.0", "archived": false, "released": true, "releaseDate": "2014-09-28" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2014-05-21T19:25:39.000+0000", "created": "2014-05-05T06:48:22.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "android", "crash", "listview", "module_kitchensink", "qe-testadded", "triage" ], "versions": [], "issuelinks": [], "assignee": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2014-07-29T23:55:01.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": "On occasion I am seeing app crashes with the log below. Unfortunately, I have not been able to reproduce this in a simple test case, but it does happen on occasion in my app, during certain sequences. The issue is clearly stated in the error log: the ListView has been modified outside the UI thread.\r\n\r\nReviewing the ListView code, there are several places where such issues can occur. In ListSectionProxy.java, for example the following methods *definitely* modify the ListView without first making sure the UI thread is running: {{setHeaderView}}, {{setFooterView}}, {{setHeaderTitle}}, and {{setFooterTitle}}. And indeed - *the issues in my code went away* after I stopped calling {{setHeaderTitle}}. Note that these methods ensure the UI thread is running only to call {{adapter.notifyDataSetChanged()}}, but the changes themselves may clearly be made outside the UI thread - which is a bug. \r\n\r\nAdditionally - I'm not sure that setting the ListView.sections property is UI thread safe.\r\n\r\nI strongly suggest Appcelerator reviews ListView code to ensure it is all UI thread safe.\r\n\r\n{color:red}\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): FATAL EXCEPTION: main\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): java.lang.IllegalStateException: *The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread.* [in ListView(-1, class android.widget.ListView) with Adapter(class android.widget.HeaderViewListAdapter)]\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.widget.ListView.layoutChildren(ListView.java:1510)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.widget.AbsListView.onLayout(AbsListView.java:1260)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.view.View.layout(View.java:7175)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.widget.FrameLayout.onLayout(FrameLayout.java:338)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat ti.modules.titanium.ui.widget.listview.TiListView$ListViewWrapper.onLayout(TiListView.java:139)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.view.View.layout(View.java:7175)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:580)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.view.View.layout(View.java:7175)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.widget.FrameLayout.onLayout(FrameLayout.java:338)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.view.View.layout(View.java:7175)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.support.v4.view.ViewPager.onLayout(ViewPager.java:1589)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.view.View.layout(View.java:7175)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:580)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.view.View.layout(View.java:7175)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.widget.FrameLayout.onLayout(FrameLayout.java:338)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.view.View.layout(View.java:7175)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.widget.LinearLayout.onLayout(LinearLayout.java:1047)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.view.View.layout(View.java:7175)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.widget.FrameLayout.onLayout(FrameLayout.java:338)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.view.View.layout(View.java:7175)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.widget.LinearLayout.onLayout(LinearLayout.java:1047)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.view.View.layout(View.java:7175)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.widget.FrameLayout.onLayout(FrameLayout.java:338)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.view.View.layout(View.java:7175)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.view.ViewRoot.performTraversals(ViewRoot.java:1140)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.view.ViewRoot.handleMessage(ViewRoot.java:1859)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.os.Handler.dispatchMessage(Handler.java:99)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.os.Looper.loop(Looper.java:130)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat android.app.ActivityThread.main(ActivityThread.java:3683)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat java.lang.reflect.Method.invokeNative(Native Method)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat java.lang.reflect.Method.invoke(Method.java:507)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)\r\n05-04 19:03:15.566: E/AndroidRuntime(9698): \tat dalvik.system.NativeStart.main(Native Method)\r\n{color}", "attachment": [], "flagged": false, "summary": "Android: App crashes due to ListView modifications", "creator": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "subtasks": [], "reporter": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "environment": "Android SDK 3.3.0", "closedSprints": [ { "id": 104, "state": "closed", "name": "2014 Sprint 10 SDK", "startDate": "2014-05-12T16:00:00.000Z", "endDate": "2014-05-24T00:00:00.000Z", "completeDate": "2014-05-27T18:11:47.424Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "303467", "author": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "body": "See pull request: https://github.com/appcelerator/titanium_mobile/pull/5658\r\nMy issues have been fixed for now by this PR, but I still urge Appcelerator to review all the ListView code to make sure there are no further manifestations of this bug. Specifically - is the creation dictionary being handled in the UI thread?\r\n\r\nSee explanation of why this PR is required: https://github.com/mokesmokes/titanium_mobile/commit/1b88f411ef87449343a51af6d301dc629290f26b", "updateAuthor": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "created": "2014-05-05T11:50:19.000+0000", "updated": "2014-05-05T17:19:06.000+0000" }, { "id": "304940", "author": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "body": "No comment from Appcelerator on an issue that causes app crashes???", "updateAuthor": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "created": "2014-05-15T06:52:42.000+0000", "updated": "2014-05-15T06:52:42.000+0000" }, { "id": "305021", "author": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Mark, we have a number of tickets coming in from different sources as we wind down 3.3.0 and I was not alerted to this one yet. I've placed it into triage. Thank you for following up.", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-05-15T09:33:02.000+0000", "updated": "2014-05-15T09:33:02.000+0000" }, { "id": "305022", "author": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "body": "That's fine. Just a quick overview to help you guys with this one: all I did was modify the 4 offending ListSection methods that were not written in the usual pattern of running methods on the UI thread - very straight forward and the review should be simple. Unfortunately as this is a threading/timing issue the crash is not easy to replicate - even debug prints can move the timing one way or another, also device dependent, etc - but it definitely was happening on occasion and this fixed it.", "updateAuthor": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "created": "2014-05-15T09:41:52.000+0000", "updated": "2014-05-15T09:41:52.000+0000" }, { "id": "305983", "author": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "body": "3.3.X PR: https://github.com/appcelerator/titanium_mobile/pull/5720", "updateAuthor": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-05-21T20:58:51.000+0000", "updated": "2014-05-21T20:58:51.000+0000" }, { "id": "309406", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~hpham] - can you please provide any test steps/code to verify the fix for this ticket.", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-06-17T21:05:44.000+0000", "updated": "2014-06-17T21:05:44.000+0000" }, { "id": "309730", "author": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Testing steps: Run KS -> views -> list views -> headers and footers, make sure everything is working as expected.", "updateAuthor": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-06-18T22:09:07.000+0000", "updated": "2014-06-18T22:09:07.000+0000" }, { "id": "309760", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix by running test in KS -> views -> list views -> headers and footers & did not find any issues.\r\n\r\nClosing.\r\n\r\nEnvironment:\r\nAppc Studio : 3.3.0.201406171619\r\nTi SDK : 3.3.0.v20140617161713\r\nMac OSX : 10.8.5\r\nAlloy : 1.4.0-rc\r\nCLI - 3.3.0-rc\r\nCode Processor: 1.1.1\r\nSamsung Galaxy S4 - android 4.2.2", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-06-19T00:00:55.000+0000", "updated": "2014-06-19T00:00:55.000+0000" } ], "maxResults": 9, "total": 9, "startAt": 0 } } }