Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5337] iOS: Popover Crash when Switching Tabs

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2011-11-22T11:29:40.000+0000
Affected Version/sRelease 1.8.0
Fix Version/sSprint 2011-38, Release 1.8.0
ComponentsiOS
Labelsbranch-5062, module_popover, qe-testadded
ReporterDawson Toth
AssigneeStephen Tramer
Created2011-09-22T11:21:19.000+0000
Updated2014-06-19T12:46:45.000+0000

Description

Problem

If you start to show a popover, but then switch to another tab, the app will crash.

Error Message

Popovers cannot be presented from a view which does not have a window.

Reproduction

Drop the following in an app.js. Run it, and it will crash.
var tab1, tab2, win;
var tabs = Ti.UI.createTabGroup();
tabs.addTab(tab1 = Ti.UI.createTab({
    window: win = Ti.UI.createWindow({
        rightNavButton: Ti.UI.createButton({
            title: 'Launch Popover',
            url: 'what'
        })
    })
}));
win.rightNavButton.addEventListener('click',
    function() {
        Ti.UI.iPad.createPopover({
            width: 250, height: 100,
            title: 'Test Popover Crash'
        }).show({ view: win.rightNavButton });
    });
tabs.addTab(tab2 = Ti.UI.createTab({
    title: 'Touch Me',
    window: Ti.UI.createWindow({
        url: 'what'
    })
}));
tabs.open();

function cycle() {
    tabs.setActiveTab(0);
    win.rightNavButton.fireEvent('click');
    tabs.setActiveTab(1);
}

win.addEventListener('open', cycle);
setInterval(cycle, 1000);

Console Log

ep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: [ERROR] The application has crashed with an unhandled exception. Stack trace:
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 0   CoreFoundation                      0x34c6563d __exceptionPreprocess + 96
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 1   libobjc.A.dylib                     0x34243c5d objc_exception_throw + 24
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 2   CoreFoundation                      0x34c65491 +[NSException raise:format:arguments:] + 68
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 3   CoreFoundation                      0x34c654cb +[NSException raise:format:] + 34
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 4   UIKit                               0x33a9ca73 -[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated:] + 142
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 5   UIKit                               0x33a9c123 -[UIPopoverController presentPopoverFromBarButtonItem:permittedArrowDirections:animated:] + 506
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 6   mmxii-lt                            0x000a1179 -[TiUIiPadPopoverProxy updatePopoverNow] + 108
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 7   mmxii-lt                            0x000a0f9d -[TiUIiPadPopoverProxy show:] + 708
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 8   CoreFoundation                      0x34bd2f03 -[NSObject(NSObject) performSelector:withObject:] + 22
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 9   Foundation                          0x362777a9 __NSThreadPerformPerform + 268
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 10  CoreFoundation                      0x34c3ca79 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 11  CoreFoundation                      0x34c3e75f __CFRunLoopDoSources0 + 382
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 12  CoreFoundation                      0x34c3f4eb __CFRunLoopRun + 230
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 13  CoreFoundation                      0x34bcfec3 CFRunLoopRunSpecific + 230
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 14  CoreFoundation                      0x34bcfdcb CFRunLoopRunInMode + 58
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 15  GraphicsServices                    0x337f641f GSEventRunModal + 114
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 16  GraphicsServices                    0x337f64cb GSEventRun + 62
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 17  UIKit                               0x3382dd69 -[UIApplication _run] + 404
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 18  UIKit                               0x3382b807 UIApplicationMain + 670
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 19  mmxii-lt                            0x00004257 main + 50
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: 20  mmxii-lt                            0x00003da0 start + 40
Sep 22 20:09:38 unknown mmxii-lt[142] <Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Popovers cannot be presented from a view which does not have a window.'
	*** Call stack at first throw:
	(
		0   CoreFoundation                      0x34c6564f __exceptionPreprocess + 114
		1   libobjc.A.dylib                     0x34243c5d objc_exception_throw + 24
		2   CoreFoundation                      0x34c65491 +[NSException raise:format:arguments:] + 68
		3   CoreFoundation                      0x34c654cb +[NSException raise:format:] + 34
		4   UIKit                               0x33a9ca73 -[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated:] + 142
		5   UIKit                               0x33a9c123 -[UIPopoverController presentPopoverFromBarButtonItem:permittedArrowDirections:animated:] + 506
		6   mmxii-lt                            0x000a1179 -[TiUIiPadPopoverProxy updatePopoverNow] + 108
		7   mmxii-lt                            0x000a0f9d -[TiUIiPadPopoverProxy show:] + 708
		8   CoreFoundation                      0x34bd2f03 -[NSObject(NSObject) performSelector:withObject:] + 22
		9   Foundation                          0x362777a9 __NSThreadPerformPerform + 268
		10  CoreFoundation                      0x34c3ca79 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
		11  CoreFoundation                      0x34c3e75f __CFRunLoopDoSources0 + 382
		12  CoreFoundation                      0x34c3f4eb __CFRunLoopRun + 230
		13  CoreFoundation                      0x34bcfec3 CFRunLoopRunSpecific + 230
		14  CoreFoundation                      0x34bcfdcb CFRunLoopRunInMode + 58
		15  GraphicsServices                    0x337f641f GSEventRunModal + 114
		16  GraphicsServices                    0x337f64cb GSEventRun + 62
		17  UIKit                               0x3382dd69 -[UIApplication _run] + 404
		18  UIKit                               0x3382b807 UIApplicationMain + 670
		19  mmxii-lt                            0x00004257 main + 50
		20  mmxii-lt                            0x00003da0 start + 40
	)
Sep 22 20:09:38 unknown UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9][142] <Notice>: terminate called after throwing an instance of 'NSException'
Sep 22 20:09:38 unknown ReportCrash[143] <Notice>: Formulating crash report for process mmxii-lt[142]
Sep 22 20:09:38 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:com.medtronic.eu.mmxii.m3[0x7ee9]) Job appears to have crashed: Abort trap: 6
Sep 22 20:09:38 unknown SpringBoard[29] <Warning>: Application 'mmxii-lt' exited abnormally with signal 6: Abort trap: 6
Sep 22 20:09:38 unknown ReportCrash[143] <Error>: libMobileGestalt loadBasebandMobileEquipmentInfo: CommCenter error: 1:45
Sep 22 20:09:38 unknown ReportCrash[143] <Error>: libMobileGestalt copyInternationalMobileEquipmentIdentity: Could not get mobile equipment info dictionary
Sep 22 20:09:38 unknown ReportCrash[143] <Error>: libMobileGestalt copyInternationalMobileEquipmentIdentity: Could not get mobile equipment info dictionary
Sep 22 20:09:38 unknown ReportCrash[143] <Error>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/mmxii-lt_2011-09-22-200938_Dawsons-iPad-1.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0

Comments

  1. Dawson Toth 2011-09-22

    Repro app.js en route.
  2. Dawson Toth 2011-09-22

    Added reproduction and environment tested in.
  3. Stephen Tramer 2011-09-23

    Continues to crash test app even after integrating fix.
  4. Michael Pettiford 2011-11-21

    Tested with Ti Studio 1.0.7.201111182325 on OSX Lion Ti Mob SDK 1.8.0.1.v20111121090256 iPad 2 OS 5.0, iPad 2 OS 4.3.5 Popover doesn't cause crash when switching tabs

JSON Source