Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-16968

Android: App crashes due to ListView modifications

    Details

    • Sprint:
      2014 Sprint 10 SDK

      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.

      Reviewing 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.

      Additionally - I'm not sure that setting the ListView.sections property is UI thread safe.

      I strongly suggest Appcelerator reviews ListView code to ensure it is all UI thread safe.


      05-04 19:03:15.566: E/AndroidRuntime(9698): FATAL EXCEPTION: main
      05-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)]
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.ListView.layoutChildren(ListView.java:1510)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.AbsListView.onLayout(AbsListView.java:1260)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at ti.modules.titanium.ui.widget.listview.TiListView$ListViewWrapper.onLayout(TiListView.java:139)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:580)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1589)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:580)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.View.layout(View.java:7175)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.ViewRoot.performTraversals(ViewRoot.java:1140)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.os.Handler.dispatchMessage(Handler.java:99)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.os.Looper.loop(Looper.java:130)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at android.app.ActivityThread.main(ActivityThread.java:3683)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at java.lang.reflect.Method.invokeNative(Native Method)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at java.lang.reflect.Method.invoke(Method.java:507)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
      05-04 19:03:15.566: E/AndroidRuntime(9698): at dalvik.system.NativeStart.main(Native Method)

        Attachments

          Activity

            People

            • Assignee:
              hpham Hieu Pham
              Reporter:
              mokesmokes Mark Mokryn
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-18708
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Source Code