Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18260] iOS: Removing a ListView while SearchBar has focus results in crash

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-12-19T07:56:21.000+0000
Affected Version/sRelease 3.4.1, Release 3.5.0
Fix Version/sRelease 3.5.0, Release 4.0.0
ComponentsiOS
Labelslistview, popover, qe-3.5.0, searchbar
ReporterFokke Zandbergen
AssigneeVishal Duggal
Created2014-12-18T10:41:30.000+0000
Updated2015-08-10T21:55:04.000+0000

Description

A popover that has a SearchBar attached to a ListView will crash if it hides will the SearchBar still has focus. Same goes for when the ListView is removed from its parent view while the SearchBar has focus, so that seems to be the actual problem. The crashlog is attached.

Test case #1

1. Install an app with the following code on an iPad (crashes on iOS Simulator as well, but doesn't show crashlog) 2. Tap the button 3. Tap the searchbar to focus 4. Tap outside the popover to hide it 5. App crashes after a second or so
var w = Ti.UI.createWindow({
  backgroundColor: 'white'
});

var b = Ti.UI.createButton({
  title: 'Click'
});

b.addEventListener('click', function() {

  var cw = Ti.UI.createWindow({
    width: 300,
    height: 300
  });

  var lv = Ti.UI.createListView({
    searchView: Ti.UI.createSearchBar()
  });

  cw.add(lv);

  var p = Ti.UI.iPad.createPopover({
    width: 300,
    height: 300,
    contentView: cw
  });

  p.show({
    view: b
  });

});

w.add(b);
w.open();

Test case #2

1. Install an app with the following code on an iOS device (crashes on iOS Simulator as well, but doesn't show crashlog) 2. Tap the searchbar to focus 3. Tap the button to remove the ListView 4. App crashes after a second or so
var w = Ti.UI.createWindow({
  backgroundColor: 'white'
});

var lv = Ti.UI.createListView({
  top: 100,
  searchView: Ti.UI.createSearchBar()
});

var b = Ti.UI.createButton({
  top: 30,
  title: 'Click me after focussing on search field'
});

b.addEventListener('click', function() {
  w.remove(lv);
});

w.add(b);
w.add(lv);

w.open();

Attachments

FileDateSize
popsearch.crash2014-12-18T10:41:30.000+000040547

Comments

  1. Vishal Duggal 2014-12-19

    Combined test case
       var win = Ti.UI.createWindow({
         backgroundColor: 'white'
       });
       var navWin = Titanium.UI.iOS.createNavigationWindow({
          window: win
       });
       var b1 = Ti.UI.createButton({title:'TEST1', top:60});
       win.add(b1);
       b1.addEventListener('click',function(){
           var w = Ti.UI.createWindow({backgroundColor:'white'})
           var lv = Ti.UI.createListView({
             top: 100,
             searchView: Ti.UI.createSearchBar()
           });
           var b = Ti.UI.createButton({
             top: 30,
             title: 'Click me after focussing on search field'
           });
           b.addEventListener('click', function() {
             w.remove(lv);
           });
           w.add(b);
           w.add(lv);
           navWin.openWindow(w, {animated:true});
       });
       if(Ti.Platform.osname == 'ipad'){
           var b2 = Ti.UI.createButton({title:'TEST2', top:120});
           win.add(b2);
           b2.addEventListener('click',function(){
               var w = Ti.UI.createWindow({
                 backgroundColor: 'white'
               });
               var b = Ti.UI.createButton({
                 title: 'Click'
               });
               b.addEventListener('click', function() {
                 var cw = Ti.UI.createWindow({
                   width: 300,
                   height: 300
                 });
                 var lv = Ti.UI.createListView({
                   searchView: Ti.UI.createSearchBar()
                 });
                 cw.add(lv);
                 var p = Ti.UI.iPad.createPopover({
                   width: 300,
                   height: 300,
                   contentView: cw
                 });
                 p.show({
                   view: b
                 });
               });
               w.add(b);
               navWin.openWindow(w, {animated:true});
           });
       }
       navWin.open();
       
  2. Vishal Duggal 2014-12-19

    Pulls pending master - https://github.com/appcelerator/titanium_mobile/pull/6513 3_5_X - https://github.com/appcelerator/titanium_mobile/pull/6514
  3. Ingo Muschenetz 2014-12-19

    Please review this one.
  4. Chee Kiat Ng 2014-12-19

    CR and FT passed. Merged PRs.
  5. Fokke Zandbergen 2014-12-19

    Thanks for the super quick fix guys. Just patched my 3.5.0.Beta and it works indeed.
  6. Eric Wieber 2014-12-30

    Verified fixed using: Titanium SDK 3.5.0.v20141222103320 Studio 3.4.1.201410281743 Xcode 6.1.1 On: iPad mini, iOS 8.1 iPhone 6, iOS 8.2b3 iPhone 4S Sim, iOS 8.1
  7. Fokke Zandbergen 2015-01-08

    [~ingo] [~ewieber] I can still reproduce it with the code following and the next steps/environment 1. Tap the button to open the popover 2. Tap the searchbar and enter "odd" 3. Hide the soft keyboard using the dedicated button on the soft keyboard 4. App crashes Titanium SDK 3.5.0.v20141222103320 CLI 3.4.1 Xcode 6.1.1 iPad MD788NF/A (Air), iOS 8.1.2 I've found that it only happens if the number of items filtered is less then needed to fill the few height of the listview. If you increase the number of items to 50 you won't be able to replicate.
       var w = Ti.UI.createWindow({
         backgroundColor: 'white'
       });
       
       var b = Ti.UI.createButton({
         title: 'Click Me'
       });
       
       b.addEventListener('click', function() {
       
         var cw = Ti.UI.createWindow({
           width: 300
         });
       
         var items = [];
       
         for (var i = 1, oe; i <= 20; i++) {
           oe = (i % 2 === 0) ? 'even' : 'odd';
           items.push({
             properties: {
               title: 'Row #' + i + ' (' + oe + ')',
               searchableText: oe
             }
           });
         }
       
         var lv = Ti.UI.createListView({
           searchView: Ti.UI.createSearchBar(),
           sections: [Ti.UI.createListSection({
             items: items
           })]
         });
       
         cw.add(lv);
       
         var p = Ti.UI.iPad.createPopover({
           contentView: cw
         });
       
         p.show({
           view: b
         });
       });
       
       w.add(b);
       w.open();
       
  8. Fokke Zandbergen 2015-01-08

    Don't know what happend to the code above. Here it is:
       var w = Ti.UI.createWindow({
         backgroundColor: 'white'
       });
       
       var b = Ti.UI.createButton({
         title: 'Click Me'
       });
       
       b.addEventListener('click', function() {
       
         var cw = Ti.UI.createWindow({
           width: 300
         });
       
         var items = [];
       
         for (var i = 1, oe; i <= 20; i++) {
           oe = (i % 2 === 0) ? 'even' : 'odd';
           items.push({
             properties: {
               title: 'Row #' + i + ' (' + oe + ')',
               searchableText: oe
             }
           });
         }
       
         var lv = Ti.UI.createListView({
           searchView: Ti.UI.createSearchBar(),
           sections: [Ti.UI.createListSection({
             items: items
           })]
         });
       
         cw.add(lv);
       
         var p = Ti.UI.iPad.createPopover({
           contentView: cw
         });
       
         p.show({
           view: b
         });
       });
       
       w.add(b);
       w.open();
       
  9. Fokke Zandbergen 2015-01-08

    Ah... shows OK after refresh.
  10. Eric Wieber 2015-01-08

JSON Source