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

Android: setting backgroundImage of TableViewRow to null or empty string crashes app

    Details

    • Story Points:
      1

      Description

      Problem

      Setting the backgroundImage property of a TableViewRow to null crashes the app with a NullPointerException/force close. Setting backgroundImage to an empty string locks up the app (which will eventually crash if you keep clicking or try to back out).

      Rationale

      This is a problem because we have the need to apply a background image to a row, and then at some point later remove that background image completely.

      Tested on

      Droid Razr 2.3.5
      Android 2.2 emulator

      Runtime engines

      V8/Rhino

      Reproduction steps

      1. Drop the following app.js code into a new project - initially, the row has no background image (property no specified)
      2. click the row once...a background image appears (and the caption changes)
      3. click the row again...a Force Close messaage appears on the screen, and a NullPointerException appears in the console

      if you repeat the test with the "1st test" line commented out and the "2nd test" line uncommented, the app will freeze (nothing new appears in the console window) and then crash if you click the row again or try to "back" out.

      Repro sequence

      var win1 = Ti.UI.createWindow({  
          backgroundColor:'black'
      });
       
      var TheListBox=Ti.UI.createTableView({width:'auto'});
      var BIRow=Ti.UI.createTableViewRow({color:'white',
                                          title:'No background image...click to toggle'});
      TheListBox.appendRow(BIRow);
       
      win1.open();
      win1.add(TheListBox);
       
      BIRow.addEventListener('click',ToggleBI);
      function ToggleBI()
      {
        if (!BIRow.backgroundImage)
        {
          BIRow.backgroundImage='appicon.png';
          BIRow.title='Titanium background image...click to toggle';
        }
        else 
        {
          BIRow.backgroundImage=null; // 1st test...NullPointerException
          //BIRow.backgroundImage=''; // 2nd test...lockup/freeze...crash on next click
          BIRow.title='No background image...click to toggle';
        }
      }
      

      Console output

      cation: (main) [34,34] Titanium 1.8.1 (2012/01/27 17:31 a24502a)
      03-31 22:59:19.411  5847  5847 I TiApplication: (main) [52,86] Titanium Javascript runtime: v8
      03-31 22:59:19.411  5847  5855 D dalvikvm: Trying to load lib /data/data/com.appcelerator.test/lib/libstlport_shared.so 0x4051cf58
      03-31 22:59:19.411  5847  5855 D dalvikvm: Added shared lib /data/data/com.appcelerator.test/lib/libstlport_shared.so 0x4051cf58
      03-31 22:59:19.411  5847  5855 D dalvikvm: No JNI_OnLoad found in /data/data/com.appcelerator.test/lib/libstlport_shared.so 0x4051cf58, skipping init
      03-31 22:59:19.411  5847  5855 D dalvikvm: Trying to load lib /data/data/com.appcelerator.test/lib/libkroll-v8.so 0x4051cf58
      03-31 22:59:19.419  5847  5855 D dalvikvm: Added shared lib /data/data/com.appcelerator.test/lib/libkroll-v8.so 0x4051cf58
      03-31 22:59:19.442  5847  5847 W TiApplication: (main) [38,124] activity stack is emtpy, unable to get current activity
      03-31 22:59:19.442  5847  5847 I TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
      03-31 22:59:19.513  5847  5847 W TiApplication: (main) [70,70] activity stack is emtpy, unable to get current activity
      03-31 22:59:19.513  5847  5847 W TiApplication: (main) [1,71] activity stack is emtpy, unable to get current activity
      03-31 22:59:19.513  5847  5847 W TiApplication: (main) [0,71] activity stack is emtpy, unable to get current activity
      03-31 22:59:19.716  5847  5855 E TiApplication: (KrollRuntimeThread) [201,272] APP PROXY: ti.modules.titanium.app.AppModule@405ac7e0
      03-31 22:59:19.864  5847  5847 D dalvikvm: GC_EXTERNAL_ALLOC freed 490K, 45% free 3304K/5959K, external 2741K/2773K, paused 36ms
      03-31 22:59:19.911  5847  5847 I TiRootActivity: (main) [0,0] checkpoint, on root activity resume. activity = com.appcelerator.test._1bestpracticesActivity@40594d48
      03-31 22:59:19.942   509   722 W InputManagerService: Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@4092bfd8 (uid=10035 pid=890)
      03-31 22:59:19.950   509   801 I gralloc : Allocated 0x660072 size 6488161
      03-31 22:59:19.997   509   604 I ActivityManager: Displayed com.appcelerator.test/._1bestpracticesActivity: +743ms
      03-31 22:59:21.122   509   509 I gralloc : Allocated 0x660072 size 6488161
      03-31 22:59:23.349   509   603 I AlarmManager: sending alarm Alarm{4067a338 type 0 com.android.vending}
      03-31 22:59:23.771  1836  1838 D dalvikvm: GC_CONCURRENT freed 149K, 45% free 4022K/7239K, external 2357K/2773K, paused 1ms+1ms
      03-31 22:59:23.825  1836  1836 D Finsky  : [1] 5.onFinished: Installation state replication succeeded.
      03-31 22:59:24.458   509   603 I AlarmManager: sending alarm Alarm{40bd1650 type 0 com.google.android.gsf}
      03-31 22:59:24.481   897  4041 I EventLogService: Aggregate from 1333254564412 (log), 1333254564412 (data)
      03-31 22:59:25.872   509   600 D BatteryTempPolicy: updateBatteryTemp temperature = 310, Threshhold = 3
      03-31 22:59:25.880   258   495 E NetlinkListener: ignoring non-kernel netlink multicast message
      03-31 22:59:25.880   256   283 E NetlinkListener: ignoring non-kernel netlink multicast message
      03-31 22:59:25.880   254   291 E NetlinkListener: ignoring non-kernel netlink multicast message
      03-31 22:59:25.880   258   584 E NetlinkListener: ignoring non-kernel netlink multicast message
      03-31 22:59:25.911   664   664 D StatusBarPolicy: handleBatteryUpdate
      03-31 22:59:30.997   890   890 D dalvikvm: GC_EXPLICIT freed 527K, 49% free 4499K/8775K, external 8803K/10851K, paused 76ms
      03-31 22:59:36.005  2207  2207 D dalvikvm: GC_EXPLICIT freed 15K, 38% free 4178K/6663K, external 2357K/2773K, paused 75ms
      03-31 22:59:40.989  2281  2281 D dalvikvm: GC_EXPLICIT freed 8K, 44% free 3173K/5575K, external 2357K/2773K, paused 57ms
      03-31 22:59:46.005  2082  2082 D dalvikvm: GC_EXPLICIT freed 299K, 42% free 3443K/5895K, external 2357K/2773K, paused 72ms
      03-31 22:59:49.552  5847  5886 W TiAnalyticsSvc: (Thread-13) [29641,29641] Analytics Service Started
      03-31 22:59:49.575  5847  5886 I TiAnalyticsSvc: (Thread-13) [26,29667] Network unavailable, can't send analytics
      03-31 22:59:49.575  5847  5886 W TiAnalyticsSvc: (Thread-13) [0,29667] Stopping Analytics Service
      03-31 22:59:54.606  4351  4351 D dalvikvm: GC_EXPLICIT freed 11K, 42% free 3131K/5379K, external 2357K/2773K, paused 58ms
      03-31 22:59:59.630  2191  2191 D dalvikvm: GC_EXPLICIT freed 163K, 47% free 4043K/7559K, external 2357K/2773K, paused 78ms
      03-31 22:59:59.997   509   603 I AlarmManager: sending alarm Alarm{40d99778 type 1 android}
      03-31 23:00:05.075  2216  2216 D dalvikvm: GC_EXPLICIT freed 17K, 44% free 3042K/5379K, external 2357K/2773K, paused 24ms
      03-31 23:00:10.099  2226  2226 D dalvikvm: GC_EXPLICIT freed 6K, 44% free 3022K/5379K, external 2357K/2773K, paused 42ms
      03-31 23:00:10.552  5847  5855 W TypeConverter: jsValueToJavaObject returning null
      03-31 23:00:10.552  5847  5847 D AndroidRuntime: Shutting down VM
      03-31 23:00:10.552  5847  5847 W dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x4001e560)
      03-31 23:00:10.560  5847  5847 E TiApplication: (main) [20975,50642] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 1.8.1,2012/01/27 17:31,a24502a
      03-31 23:00:10.560  5847  5847 E TiApplication: java.lang.NullPointerException
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at ti.modules.titanium.ui.widget.tableview.TiBaseTableViewItem.setBackgroundFromProxy(TiBaseTableViewItem.java:182)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at ti.modules.titanium.ui.widget.tableview.TiTableViewRowProxyItem.setRowData(TiTableViewRowProxyItem.java:213)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at ti.modules.titanium.ui.widget.tableview.TiTableViewRowProxyItem.setRowData(TiTableViewRowProxyItem.java:84)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at ti.modules.titanium.ui.widget.tableview.TiTableView$TTVListAdapter.getView(TiTableView.java:210)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.widget.AbsListView.obtainView(AbsListView.java:1435)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.widget.ListView.makeAndAddView(ListView.java:1824)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.widget.ListView.fillSpecific(ListView.java:1365)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.widget.ListView.layoutChildren(ListView.java:1651)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.widget.AbsListView.onLayout(AbsListView.java:1286)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.view.View.layout(View.java:7184)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.view.View.layout(View.java:7184)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:382)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.view.View.layout(View.java:7184)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:382)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.view.View.layout(View.java:7184)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.view.View.layout(View.java:7184)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.view.View.layout(View.java:7184)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.view.View.layout(View.java:7184)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.view.ViewRoot.performTraversals(ViewRoot.java:1180)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.view.ViewRoot.handleMessage(ViewRoot.java:1914)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.os.Handler.dispatchMessage(Handler.java:99)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.os.Looper.loop(Looper.java:130)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at android.app.ActivityThread.main(ActivityThread.java:3859)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at java.lang.reflect.Method.invokeNative(Native Method)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at java.lang.reflect.Method.invoke(Method.java:507)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:840)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:598)
      03-31 23:00:10.560  5847  5847 E TiApplication: 	at dalvik.system.NativeStart.main(Native Method)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: FATAL EXCEPTION: main
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: java.lang.NullPointerException
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at ti.modules.titanium.ui.widget.tableview.TiBaseTableViewItem.setBackgroundFromProxy(TiBaseTableViewItem.java:182)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at ti.modules.titanium.ui.widget.tableview.TiTableViewRowProxyItem.setRowData(TiTableViewRowProxyItem.java:213)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at ti.modules.titanium.ui.widget.tableview.TiTableViewRowProxyItem.setRowData(TiTableViewRowProxyItem.java:84)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at ti.modules.titanium.ui.widget.tableview.TiTableView$TTVListAdapter.getView(TiTableView.java:210)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.widget.AbsListView.obtainView(AbsListView.java:1435)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.widget.ListView.makeAndAddView(ListView.java:1824)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.widget.ListView.fillSpecific(ListView.java:1365)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.widget.ListView.layoutChildren(ListView.java:1651)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.widget.AbsListView.onLayout(AbsListView.java:1286)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.view.View.layout(View.java:7184)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.view.View.layout(View.java:7184)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:382)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.view.View.layout(View.java:7184)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:382)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.view.View.layout(View.java:7184)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.view.View.layout(View.java:7184)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.view.View.layout(View.java:7184)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.view.View.layout(View.java:7184)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.view.ViewRoot.performTraversals(ViewRoot.java:1180)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.view.ViewRoot.handleMessage(ViewRoot.java:1914)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:99)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:130)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:3859)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at java.lang.reflect.Method.invokeNative(Native Method)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Method.java:507)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:840)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:598)
      03-31 23:00:10.591  5847  5847 E AndroidRuntime: 	at dalvik.system.NativeStart.main(Native Method)
      03-31 23:00:10.599   509   783 W ActivityManager:   Force finishing activity com.appcelerator.test/._1bestpracticesActivity
      03-31 23:00:10.708   509   526 D dalvikvm: GC_EXTERNAL_ALLOC freed 1343K, 36% free 9055K/14023K, external 10065K/10188K, paused 85ms
      03-31 23:00:10.724   509   526 W ApplicationContext: Unable to create files directory
      03-31 23:00:10.747   509   526 I gralloc : Allocated 0x61663d64 size 2103800684
      03-31 23:00:11.099   509   524 W ActivityManager: Activity pause timeout for HistoryRecord{40a2c3d8 com.appcelerator.test/._1bestpracticesActivity}
      03-31 23:00:11.099   509   524 I ActivityManager: No longer want amep.games.af_final:remote (pid 4351): hidden #21
      03-31 23:00:11.122   890   890 D ActivitityRenderTarget: onResume
      03-31 23:00:11.177   890  5830 W IMGSRV  : eglglue.c:778: InitContext: ignoring buffer type CBUF_TYPE_PDS_VERT_SECONDARY_PREGEN_BUFFER
      03-31 23:00:11.192   509   515 I gralloc : Allocated 0x660072 size 6488161
      03-31 23:00:11.294   509   873 I gralloc : Allocated 0x660072 size 6488161
      03-31 23:00:11.349   509   722 I gralloc : Allocated 0x660072 size 6488161
      03-31 23:00:11.356   509   820 W ActivityManager: Scheduling restart of crashed service amep.games.af_final/com.appenda.AppNotify in 5000ms
      03-31 23:00:11.599   509   524 I ActivityManager: No longer want com.motorola.im.service (pid 4333): hidden #21
      03-31 23:00:11.622   509   827 W ActivityManager: Scheduling restart of crashed service com.motorola.im/.service.RemoteImService in 14734ms
      03-31 23:00:11.731   509   526 I gralloc : Allocated 0x61663d64 size 2103800684
      

      API docs

      http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.TableViewRow.backgroundImage-property.html

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hpham Hieu Pham
                Reporter:
                bitshftr Shawn Lipscomb
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

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

                    Git Integration