Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-11986] iOS: App crashes with: "A view can only be associated with at most one view controller at a time"

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2013-01-08T15:19:58.000+0000
Affected Version/sn/a
Fix Version/sRelease 3.1.0, 2013 Sprint 01 API, 2013 Sprint 01
ComponentsiOS
Labelsapi, crash, ios, ios6, triage
ReporterZhenya Kogan
AssigneeVishal Duggal
Created2012-10-03T04:18:14.000+0000
Updated2014-01-11T05:20:24.000+0000

Description

Same build is tested on a device with ios5 and multiple devices with ios6. The problem is consistent on ios6 devices, while ios5 devices work fine. Unfortunately I can't paste a self contained example of the working code, but here's what's going on. From one tab, another tab is set active with a window opened (some of the views and the window are earlier declared and previously used). this is the code, but it's pretty generic if out of context... self.open = function() { trip_tab.open(win, {animated: false}); tabGroup.setActiveTab(trip_tab).open(); }; ... ... ... self.open(); Here's the console log: [ERROR] The application has crashed with an unhandled exception. Stack trace: 0 CoreFoundation 0x03230012 __exceptionPreprocess + 178 1 libobjc.A.dylib 0x02f93e7e objc_exception_throw + 44 2 CoreFoundation 0x0322fdeb +[NSException raise:format:] + 139 3 UIKit 0x00df2309 -[UIView(Internal) _setViewDelegate:] + 226 4 UIKit 0x00e895ac +[UIViewController setViewController:forView:] + 40 5 UIKit 0x00e85a90 -[UIViewController setView:] + 521 6 Citybot 0x00080aec -[TiViewController loadView] + 92 7 Citybot 0x000c6863 -[TiUITabController loadView] + 179 8 UIKit 0x00e85648 -[UIViewController loadViewIfRequired] + 73 9 UIKit 0x00e85882 -[UIViewController view] + 33 10 UIKit 0x00e85b2a -[UIViewController contentScrollView] + 36 11 UIKit 0x00e9cef5 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 36 12 UIKit 0x00e9cfdb -[UINavigationController _layoutViewController:] + 43 13 UIKit 0x00e9d286 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 254 14 UIKit 0x00e9d381 -[UINavigationController _startTransition:fromViewController:toViewController:] + 72 15 UIKit 0x00e9deab -[UINavigationController _startDeferredTransitionIfNeeded:] + 386 16 UIKit 0x00e9dfc9 -[UINavigationController _startDeferredTransitionIfNeeded] + 41 17 UIKit 0x00e9e055 -[UINavigationController __viewWillLayoutSubviews] + 33 18 UIKit 0x00fa33ab -[UILayoutContainerView layoutSubviews] + 233 19 UIKit 0x00df492d -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 279 20 libobjc.A.dylib 0x02fa76b0 -[NSObject performSelector:withObject:] + 70 21 QuartzCore 0x02145fc0 -[CALayer layoutSublayers] + 240 22 QuartzCore 0x0213a33c _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 468 23 QuartzCore 0x0213a150 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26 24 QuartzCore 0x020b80bc _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 324 25 QuartzCore 0x020b9227 _ZN2CA11Transaction6commitEv + 395 26 QuartzCore 0x0215bb50 +[CATransaction flush] + 52 27 UIKit 0x00dba52f _afterCACommitHandler + 132 28 CoreFoundation 0x031f8afe __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30 29 CoreFoundation 0x031f8a3d __CFRunLoopDoObservers + 381 30 CoreFoundation 0x031d67c2 __CFRunLoopRun + 1106 31 CoreFoundation 0x031d5f44 CFRunLoopRunSpecific + 276 32 CoreFoundation 0x031d5e1b CFRunLoopRunInMode + 123 33 GraphicsServices 0x0381c7e3 GSEventRunModal + 88 34 GraphicsServices 0x0381c668 GSEventRun + 104 35 UIKit 0x00da465c UIApplicationMain + 1211 36 Citybot 0x000068a8 main + 456 37 Citybot 0x000031d5 start + 53 2012-10-02 17:36:09.101 Citybot[63976:c07] *** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'A view can only be associated with at most one view controller at a time! View > is associated with . Clear this association before associating this view with .' *** First throw call stack: (0x3230012 0x2f93e7e 0x322fdeb 0xdf2309 0xe895ac 0xe85a90 0x80aec 0xc6863 0xe85648 0xe85882 0xe85b2a 0xe9cef5 0xe9cfdb 0xe9d286 0xe9d381 0xe9deab 0xe9dfc9 0xe9e055 0xfa33ab 0xdf492d 0x2fa76b0 0x2145fc0 0x213a33c 0x213a150 0x20b80bc 0x20b9227 0x215bb50 0xdba52f 0x31f8afe 0x31f8a3d 0x31d67c2 0x31d5f44 0x31d5e1b 0x381c7e3 0x381c668 0xda465c 0x68a8 0x31d5) [INFO] Application has exited from Simulator I just installed 2.1.3 rc2 from here http://builds.appcelerator.com.s3.amazonaws.com/mobile/2_1_X/mobilesdk-2.1.3.v20120927181611-osx.zip I was hoping the problem was this (there is in fact map used in that view/window): TIMOB-10891 iOS 6: Repeatedly opening a tab group containing a map view crashes the application. (Known issue in RC) (described here: http://developer.appcelerator.com/blog/2012/09/titanum-2-1-3-rc2-is-released-with-additional-fixes-for-ios-6-and-iphone-5.html ) But after updating from previous rc to rc2 the problem still exits... Please contact me -- I'll be happy to assist with troubleshooting this. Thank you.

Attachments

FileDateSize
app.js2013-01-08T15:03:39.000+00001481

Comments

  1. Zhenya Kogan 2012-10-03

    Fyi, as a temporary workaround I switched the calls from trip_tab.open(win, {animated: false}); tabGroup.setActiveTab(trip_tab).open(); to tabGroup.setActiveTab(trip_tab).open(); trip_tab.open(win, {animated: false}); This solved the problem, however this is not optimal as a long term fix since there's a short flicker of a previous window in that tab now.
  2. Zhenya Kogan 2012-10-04

    The fix I described above no longer works after 2.1.3 GA update.
  3. Zhenya Kogan 2012-10-28

    Any news on this?
  4. Daniel Sefton 2012-12-06

    We'd be able to look at this faster with a test case, are you sure it's not possible to put one together? I don't expect you to paste your production code, but just try to re-create the problem in a new simple project. Thanks!
  5. Vishal Duggal 2013-01-08

    Sample test project which recreates the problem
  6. Vishal Duggal 2013-01-08

    The Tabgroup implemetation on 2_1_X had a bug with state retention which was fixed as part of TIMOB-10891 Run the attached sample app against 2_1_X and you'll see that opening the tabgroup a second time will close win2. Run this against master or 3_0_X CI and it should work fine (TIMOB-12244 was a bug discovered during the triage of this bug and has been fixed.) The crash happens because a window is being associated with two navControllers at the same time. Since 3_0_X and master now have proper state retention, you shouldn't have to call trip_tab.open(win, {animated: false}); if the window is already open. You could write the app along the guidelines presented in the attached app.js To workaround the bug in 2_1_X I recommend explicitly closing the window before closing the tabGroup.
  7. Vishal Duggal 2013-01-08

    Nothing to do here. State retention has been fixed in 3_0_X and master. App can be fixed with JS workaround
  8. Satyam Sekhri 2013-01-18

    Tested with the attached app.js and instructions in the comment. Verified on: Studio: 3.0.1.201212181159 SDK: 3.0.0.GA, 3.0.1.v20130108154840, 3.1.0.v20130114171802 iOS Device: iOS Simulator 6.0, iPad mini (v6.0) XCode: 4.5.2 CLI: 3.0.22
  9. Alberto Marcone 2013-02-05

    still happening here, just tested it on TiSDK 3.1.0.v20130201161008, iPad 4 Gen, iOS 6. It doesn't always happen, but from time to time my app would freeze with this error. I'm planning on preparing a dummy project, don't really have time now. Just to let you guys know.
  10. Alberto Marcone 2013-02-05

    still happening here, just tested it on TiSDK 3.1.0.v20130201161008, iPad 4 Gen, iOS 6. It doesn't always happen, but from time to time my app would freeze with this error. I'm planning on preparing a dummy project, don't really have time now. Just to let you guys know.

JSON Source