Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-1643] Scrollview more than 10 children views cause app freeze

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:56:45.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.6.0 M06
ComponentsiOS
Labelsdefect, ios, release-1.6.0, scrollview
Reporterctredway
AssigneeBlain Hamon
Created2011-04-15T02:58:09.000+0000
Updated2011-04-17T01:56:45.000+0000

Description

Ok, if a scrollview is placed in a window and more than 10 child views are added, any new children views added cause the app to freeze.

Another scenario is that if the window is opened before child views are added to the scroll view, only 10 views can be added without causing a freeze. The code below demonstrates this.

var win = Ti.UI.currentWindow;

var scrollView = Titanium.UI.createScrollView({
borderSize: 1, borderColor: 'blue', maxZoomScale: 1, minZoomScale: 1, contentHeight: 'auto' }); win.add(scrollView);

// Load fisrt page for (var i=0; i<50; i++) {
scrollView.add(Titanium.UI.createView({

   left: (i % 4) * 70,
   top: parseInt(i / 4) * 70,
   width: 64,
   height: 64,
   backgroundColor: '#ccc'

})); }

alert('Application is NOT freezed');

win.open();

setTimeout(function(){

win.remove(scrollView);

},1000);

setTimeout(function(){

alert('Application is NOT freezed');

var scrollView2 = Titanium.UI.createScrollView({
   borderSize: 1,
   borderColor: 'blue',
   maxZoomScale: 1,
   minZoomScale: 1,
   contentHeight: 'auto'
});
win.add(scrollView2);

for (var i=0; i<50; i++) {
   scrollView2.add(Titanium.UI.createView({
       left: (i % 4) * 70,
       top: parseInt(i / 4) * 70,
       width: 64,
       height: 64,
       backgroundColor: '#000'
   }));
};

},3000)

run on the iphone, iOS 4.0.2 Ti SDK 1.4

Comments

  1. Jeff Haynie 2011-04-15

    (from [72d5c4fd14db55459aea52d39f1f69818642f054]) [#1643 state:fixed-in-qa] Expensive but necessary, we can't recursively lock children, not even for reading. https://github.com/appcelerator/titanium_mobile/commit/72d5c4fd14db55459aea52d39f1f69818642f054"> https://github.com/appcelerator/titanium_mobile/commit/72d5c4fd14db...

  2. Pedro Enrique 2011-04-15

    Tested the code provided on iPhone Simulator (4.2) and iPhone 4 (4.2.1)

    Works as expected

    Ti SDK 1.6 (Jan 26 2011 16:47 rb481fe0b)
    Ti. Dev. 1.3

  3. Anthony Chung 2011-04-15

    I am getting a similar issue with a scrollview - the app doesn't freeze so much as the scrollview just doesn't display.
    The bug doesn't appear on simulator, iphone 4 but it happens on iphone 3g.

    Is this issue outstanding still? and has it been tested on iphone 3g? Are there any workarounds for the time being?
    much appreciated,
    Anthony

    My usecase:
    Scrollview has 4 children.
    Scrollview has fixed height and width with contentWidth and contentHeight on auto.
    The 4 children are variable heights that get added to a holder view which has height:'auto' and layout'vertical'.
    This is then added to the scrollView.

JSON Source