Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4590] Android: putting a scrollView in a tableView crashes the app after scrolling

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionCannot Reproduce
Resolution Date2013-04-26T08:59:45.000+0000
Affected Version/sRelease 1.7.1, Release 1.8.2
Fix Version/s2013 Sprint 09
ComponentsAndroid
Labelsapi
ReporterJon Alter
Assigneejithinpv
Created2011-07-05T13:58:29.000+0000
Updated2013-11-07T19:03:28.000+0000

Description

If you put a ScrollView in a TableView it crashes when you scroll down and then back up to the ScrollView. Step 1: run the code below. Step 2: scroll down on the table view and then back up Step 3: notice the app crash
var win = Titanium.UI.createWindow({  
    backgroundColor:'#000'
});
win.open();

var tableViewRows = [];

var scrollView = Titanium.UI.createScrollView({
	contentWidth:500,
	contentHeight:50,
	top:10,
	height:50,
	width:230,
	borderRadius:10,
	backgroundColor:'#13386c'
});

var view1 = Ti.UI.createView({
	backgroundColor:'#336699',
	borderRadius:20,borderWidth:1,borderColor:'#336699',
	width:40,
	height:40,
	left:10
});
scrollView.add(view1);
var l1 = Ti.UI.createLabel({
	text:'1',
	font:{fontSize:13},
	color:'#fff',
	width:'auto',
	textAlign:'center',
	height:'auto'
});
view1.add(l1);

var view2 = Ti.UI.createView({
	backgroundColor:'#336699',
	borderRadius:20,borderWidth:1,borderColor:'#336699',
	width:40,
	height:40,
	left:60
});
scrollView.add(view2);
var l2 = Ti.UI.createLabel({
	text:'2',
	font:{fontSize:13},
	color:'#fff',
	width:'auto',
	textAlign:'center',
	height:'auto'
});
view2.add(l2);

var scrollViewRow = Ti.UI.createTableViewRow({
	height: 'auto',
	className: 'scrollrow'
});	
scrollViewRow.add(scrollView);
tableViewRows.push(scrollViewRow);

for(var i = 0; i < 40; i++)
{
	var row = Ti.UI.createTableViewRow({
		title: 'some text',
		height: 'auto',
		className: 'row'
	});	
	tableViewRows.push(row);
}

var tableView = Titanium.UI.createTableView({
    data: tableViewRows
});
win.add(tableView);
W/dalvikvm(  312): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
E/TiUncaughtHandler(  312): (main) [238,55548] Sending event: exception on thread: main msg:java.lang.IllegalStateException: Ambiguous Z-Order; Titanium 1.7.1,2011/06/21 14:28,293a6d
E/TiUncaughtHandler(  312): java.lang.IllegalStateException: Ambiguous Z-Order

Associated Helpdesk Ticket

http://appc.me/c/APP-797269

Comments

  1. Mutasim Karim 2012-02-26

    This bug is still occuring and can still be reproduced in TiSDK 1.8.1
  2. MAIRDUMONT GmbH & Co. KG 2012-05-24

    I also notice a crash in a very similar scenario with TiSDK 1.8.2 on Nexus S with Android 2.3.6. You don't even need to scroll, just follow these steps: Step 1. Start app. Step 2. Tap tab 2. Step 3. Tap tab 1. Step 4. Notice the app crash. *app.js*
       Titanium.UI.setBackgroundColor('#000');
       
       // create tab group
       var tabGroup = Titanium.UI.createTabGroup();
       var win1 = Titanium.UI.createWindow({  
           title:'Tab 1',
           backgroundColor:'#fff',
           url:'scrollView_in_tableView.js'
       });
       var tab1 = Titanium.UI.createTab({  
           icon:'KS_nav_views.png',
           title:'Tab 1',
           window:win1
       });
       
       var win2 = Titanium.UI.createWindow({  
           title:'Tab 2',
           backgroundColor:'#fff'
       });
       var tab2 = Titanium.UI.createTab({  
           icon:'KS_nav_ui.png',
           title:'Tab 2',
           window:win2
       });
       
       var label2 = Titanium.UI.createLabel({
       	color:'#999',
       	text:'I am Window 2',
       	font:{fontSize:20,fontFamily:'Helvetica Neue'},
       	textAlign:'center',
       	width:'auto'
       });
       
       win2.add(label2);
       
       tabGroup.addTab(tab1);  
       tabGroup.addTab(tab2);  
       
       
       // open tab group
       tabGroup.open();
       
    and *scrollView_in_tableView.js*
       Titanium.UI.setBackgroundColor('#fff');
       var win = Ti.UI.currentWindow;
       
       var data = [{title:"Row 1"},{title:"Row 2"}];
       var table = Titanium.UI.createTableView({data:data});
       
       win.add(table);
       
       var row2 = Titanium.UI.createTableViewRow({
       	touchEnabled: false,
       	backgroundColor: '#ffffff',
       	backgroundSelectedColor: '#ffffff', // iOS
       	selectedBackgroundColor: '#ffffff', // Android
       	height:50
       });
        
       var scrollView = Titanium.UI.createScrollView({
           contentWidth:'auto',
           contentHeight:'auto',
           top:0,
           left:0,
           height:50,
           showVerticalScrollIndicator:false,
           showHorizontalScrollIndicator:false,
           scrollType: 'horizontal'
       });
       var view = Ti.UI.createView({
           backgroundColor:'#996633',
           width:1000,
           height:50,
           top:0,
           left: 0,
           right: 0
       });
       scrollView.add(view);
       row2.add(scrollView);
       
       table.updateRow(1, row2);
       
  3. Blain Hamon 2012-06-06

    Mixing scrollview and tableview should be discouraged in general. In iOS, Apple [advises](https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIWebView_Class/Reference/Reference.html#//apple_ref/doc/c_ref/UIWebView): {quote} *Important* You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled. {quote} Perhaps for similar reasons Android OS has issues and this may be deeper than Titanium.
  4. Ping Wang 2012-06-06

    Mixing scrollview and tableviw is strongly discouraged in Titanium for the reason explained in the last comment.
  5. Neeraj Gupta 2012-06-06

    Reducing the priority as this usage is discouraged in the documentation.
  6. jithinpv 2013-04-26

    cannot reproduce Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 Android Emulator: Android SDK version: 2.2
  7. Dhirendra Jha 2013-05-09

    Verified with above apps but could not reproduce this issue. Tested with Appcelerator Studio build: 3.1.1.201305072102 Titanium SDK version: 3.1.0 (GA), 3.1.1.v20130508001914 Android Emulator: Android SDK version: 2.3 Device: Samsung Galaxy (v2.3.6) Hence closing this issue.

JSON Source