-1

It's happening very randomly, sometimes on opening first window, sometimes after 9 or more.

I've got this bug after upgrading from Titanium 3.1 to 3.2 where NavigationGroup was replaced with NavigationWindow.

One of below stacktraces shows up:

*** -[__NSArrayM objectAtIndex:]: index 4 beyond bounds [0 .. 1]
[INFO]  2014-01-30 17:03:34.552 myapp[46210:80b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 4 beyond bounds [0 .. 1]'
[INFO]  *** First throw call stack:
[INFO]  (
[INFO]          0   CoreFoundation                      0x0470f5e4 __exceptionPreprocess + 180
[INFO]          1   libobjc.A.dylib                     0x042198b6 objc_exception_throw + 44
[INFO]          2   CoreFoundation                      0x046b04e6 -[__NSArrayM objectAtIndex:] + 246
[INFO]          3   myapp                               0x0007afc0 -[TiViewProxy insertSubview:forProxy:] + 1520
[INFO]          4   myapp                               0x0007a8f8 -[TiViewProxy refreshView:] + 2232
[INFO]          5   myapp                               0x0007bb53 -[TiViewProxy layoutChildrenIfNeeded] + 259
[INFO]          6   myapp                               0x00203927 +[TiLayoutQueue layoutProxy:] + 87
[INFO]          7   myapp                               0x002036f2 performLayoutRefresh + 530
[INFO]          8   CoreFoundation                      0x046cdbd6 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
[INFO]          9   CoreFoundation                      0x046cd5bd __CFRunLoopDoTimer + 1181
[INFO]          10  CoreFoundation                      0x046b5628 __CFRunLoopRun + 1816
[INFO]          11  CoreFoundation                      0x046b4ac3 CFRunLoopRunSpecific + 467
[INFO]          12  CoreFoundation                      0x046b48db CFRunLoopRunInMode + 123
[INFO]          13  GraphicsServices                    0x049699e2 GSEventRunModal + 192
[INFO]          14  GraphicsServices                    0x04969809 GSEventRun + 104
[INFO]          15  UIKit                               0x01c32d3b UIApplicationMain + 1225
[INFO]          16  myapp                               0x00003558 main + 456
[INFO]          17  libdyld.dylib                       0x051f270d start + 1
[INFO]          18  ???                                 0x00000001 0x0 + 1
[INFO]  )
[INFO]  libc++abi.dylib: terminating with uncaught exception of type NSException

or much more complex:

*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[9]
[INFO]  2014-01-30 17:17:40.232 myapp[47304:80b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[9]'
[INFO]  *** First throw call stack:
[INFO]  (
[INFO]          0   CoreFoundation                      0x0470f5e4 __exceptionPreprocess + 180
[INFO]          1   libobjc.A.dylib                     0x042198b6 objc_exception_throw + 44
[INFO]          2   CoreFoundation                      0x046c3316 -[__NSPlaceholderArray initWithObjects:count:] + 390
[INFO]          3   CoreFoundation                      0x046c513e -[NSArray initWithArray:range:copyItems:] + 558
[INFO]          4   CoreFoundation                      0x046c4f00 -[NSArray initWithArray:copyItems:] + 80
[INFO]          5   CoreFoundation                      0x046e718d -[__NSArrayM copyWithZone:] + 77
[INFO]          6   libobjc.A.dylib                     0x0422bbc1 -[NSObject copy] + 41
[INFO]          7   UIKit                               0x01c9c609 -[UIView(UIViewGestures) gestureRecognizers] + 43
[INFO]          8   UIKit                               0x01c97e76 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1176
[INFO]          9   UIKit                               0x01c97cd7 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 761
[INFO]          10  UIKit                               0x01c97cd7 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 761
[INFO]          11  UIKit                               0x01c97cd7 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 761
[INFO]          12  UIKit                               0x01c8f500 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 162
[INFO]          13  UIKit                               0x01c8f388 -[UIView(Hierarchy) _postMovedFromSuperview:] + 260
[INFO]          14  UIKit                               0x01c9a4c1 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1847
[INFO]          15  UIKit                               0x01c8d9b1 -[UIView(Hierarchy) addSubview:] + 56
[INFO]          16  UIKit                               0x01c29e05 -[_UIParallaxDimmingView didMoveToWindow] + 129
[INFO]          17  UIKit                               0x01c98077 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1689
[INFO]          18  UIKit                               0x01c97cd7 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 761
[INFO]          19  UIKit                               0x01c8f500 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 162
[INFO]          20  UIKit                               0x01c8f388 -[UIView(Hierarchy) _postMovedFromSuperview:] + 260
[INFO]          21  UIKit                               0x01c9a4c1 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1847
[INFO]          22  UIKit                               0x01c8d9b1 -[UIView(Hierarchy) addSubview:] + 56
[INFO]          23  UIKit                               0x01c26892 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke + 2001
[INFO]          24  UIKit                               0x01c943ef +[UIView(Animation) performWithoutAnimation:] + 82
[INFO]          25  UIKit                               0x01c25c96 -[_UINavigationParallaxTransition animateTransition:] + 1155
[INFO]          26  UIKit                               0x01d60e4e -[UINavigationController _startCustomTransition:] + 3446
[INFO]          27  UIKit                               0x01d6d0c7 -[UINavigationController _startDeferredTransitionIfNeeded:] + 688
[INFO]          28  UIKit                               0x01d6dcb9 -[UINavigationController __viewWillLayoutSubviews] + 57
[INFO]          29  UIKit                               0x01ea7181 -[UILayoutContainerView layoutSubviews] + 213
[INFO]          30  UIKit                               0x14d0356f -[UILayoutContainerViewAccessibility(SafeCategory) layoutSubviews] + 50
[INFO]          31  UIKit                               0x01c9d267 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
[INFO]          32  libobjc.A.dylib                     0x0422b81f -[NSObject performSelector:withObject:] + 70
[INFO]          33  QuartzCore                          0x0347c2ea -[CALayer layoutSublayers] + 148
[INFO]          34  QuartzCore                          0x034700d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
[INFO]          35  QuartzCore                          0x0346ff40 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
[INFO]          36  QuartzCore                          0x033d7ae6 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
[INFO]          37  QuartzCore                          0x033d8e71 _ZN2CA11Transaction6commitEv + 393
[INFO]          38  QuartzCore                          0x033d9544 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
[INFO]          39  CoreFoundation                      0x046d74ce __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
[INFO]          40  CoreFoundation                      0x046d741f __CFRunLoopDoObservers + 399
[INFO]          41  CoreFoundation                      0x046b5344 __CFRunLoopRun + 1076
[INFO]          42  CoreFoundation                      0x046b4ac3 CFRunLoopRunSpecific + 467
[INFO]          43  CoreFoundation                      0x046b48db CFRunLoopRunInMode + 123
[INFO]          44  GraphicsServices                    0x049699e2 GSEventRunModal + 192
[INFO]          45  GraphicsServices                    0x04969809 GSEventRun + 104
[INFO]          46  UIKit                               0x01c32d3b UIApplicationMain + 1225
[INFO]          47  myapp                               0x00003558 main + 456
[INFO]          48  libdyld.dylib                       0x051f270d start + 1
[INFO]          49  ???                                 0x00000001 0x0 + 1
[INFO]  )

[INFO]  libc++abi.dylib: terminating with uncaught exception of type NSException

Function executed when opening new window:

var openingView = false;
Alloy.Globals.open = function(name, args) {
  var view;
  args = args || {};

  if (typeof name === 'string') {
    view = Alloy.createController(name, args).getView();
  } else if (name.getView) {
    view = name.getView();
    name = view.id;
  }

  if (openingView === false) {
    openingView = true;

    view.addEventListener('focus', function viewFocus(event) {
      openingView = false;
      view.removeEventListener('focus', viewFocus);
    });


    if (view) {
      if (view.loading) {
        view.addEventListener('loaded', function onLoaded() {
          Alloy.Globals.nav.openWindow(view);
          view.removeEventListener('loaded', onLoaded);
        });
      } else {
        Alloy.Globals.nav.openWindow(view);
      }
    }
  }
};
daniula
  • 6,898
  • 4
  • 32
  • 49

1 Answers1

0

It's hard to tell without seeing the JS code that causes the crash, but it seems as if you are trying to access and object outside the array or that in null: -[__NSArrayM objectAtIndex:]: index 4 beyond bounds [0 .. 1]

Try posting the code where you recognize the crash happens.

developer82
  • 13,237
  • 21
  • 88
  • 153
  • The biggest problem is that I have no idea in which part of the code is triggering this issue. I was removing smaller and bigger parts of it and it's still there. Also whole process is very time consuming, because it's hard to trigger this bug very easily. – daniula Jan 31 '14 at 11:29
  • Does it happen right when you open the app, or after you perform some operations in it? I would try to write to console / log sequential numbers in my code and see what the last number that is shown - that's how I usually know where my app crashes and then try to narrow it down even more. – developer82 Jan 31 '14 at 13:33
  • It's happening when I'm adding new windows to NavigationWindow. I was trying trick with with console.logs() and during crash none of them was showing up. I started suspecting that this issue is going somewhere behind. – daniula Jan 31 '14 at 13:36