Problem
Showing and hiding a popover repeatedly can cause the app to crash.
Sample Code
Drop the following in an app.js. Launch, and watch the fireworks. It crashes for me after only a couple iterations, but it may take longer depending on how the planets align.
var win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
var launchPopover = Ti.UI.createButton({
title: 'Show Popover',
top: 5, right: 5, left: 5,
height: 30
});
var popover = Ti.UI.iPad.createPopover({
width: 250, height: 100,
title: 'Test Popover Crash'
});
win.addEventListener('open', function() {
while (true) {
delay(100);
popover.show({ view: launchPopover });
delay(100);
popover.hide();
}
});
win.add(launchPopover);
win.open();
function delay(time) {
var end = new Date().getTime() + time;
while (end > new Date().getTime()) {
}
}
Exception
[DEBUG] application booted in 33.083022 ms
[ERROR] The application has crashed with an unhandled exception. Stack trace:
0 CoreFoundation 0x025ba58c __exceptionPreprocess + 156
1 libobjc.A.dylib 0x0270e313 objc_exception_throw + 44
2 CoreFoundation 0x02572ef8 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x02572e6a +[NSException raise:format:] + 58
4 UIKit 0x00c5bbcc -[UIPopoverController dealloc] + 86
5 Foundation 0x0068d891 __delayedPerformCleanup + 74
6 CoreFoundation 0x025331de CFRunLoopTimerInvalidate + 446
7 CoreFoundation 0x0259d0b7 __CFRunLoopDoTimer + 1799
8 CoreFoundation 0x024f92c9 __CFRunLoopRun + 1817
9 CoreFoundation 0x024f8840 CFRunLoopRunSpecific + 208
10 CoreFoundation 0x024f8761 CFRunLoopRunInMode + 97
11 GraphicsServices 0x041901c4 GSEventRunModal + 217
12 GraphicsServices 0x04190289 GSEventRun + 115
13 UIKit 0x0091dc93 UIApplicationMain + 1160
14 play 0x00003f9a main + 410
15 play 0x00002865 start + 53
2011-09-14 18:27:30.549 play[55559:207] *** Terminating app due to uncaught exception 'NSGenericException', reason: '-[UIPopoverController dealloc] reached while popover is still visible.'
*** Call stack at first throw:
(
0 CoreFoundation 0x025ba5a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0270e313 objc_exception_throw + 44
2 CoreFoundation 0x02572ef8 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x02572e6a +[NSException raise:format:] + 58
4 UIKit 0x00c5bbcc -[UIPopoverController dealloc] + 86
5 Foundation 0x0068d891 __delayedPerformCleanup + 74
6 CoreFoundation 0x025331de CFRunLoopTimerInvalidate + 446
7 CoreFoundation 0x0259d0b7 __CFRunLoopDoTimer + 1799
8 CoreFoundation 0x024f92c9 __CFRunLoopRun + 1817
9 CoreFoundation 0x024f8840 CFRunLoopRunSpecific + 208
10 CoreFoundation 0x024f8761 CFRunLoopRunInMode + 97
11 GraphicsServices 0x041901c4 GSEventRunModal + 217
12 GraphicsServices 0x04190289 GSEventRun + 115
13 UIKit 0x0091dc93 UIApplicationMain + 1160
14 play 0x00003f9a main + 410
15 play 0x00002865 start + 53
)
terminate called after throwing an instance of 'NSException'
[DEBUG] App Spec: <DTiPhoneSimulatorApplicationSpecifier 0x100303e00> specified by path /Code/play/build/iphone/build/Debug-iphonesimulator/play.app
[DEBUG] SDK Root: <DTiPhoneSimulatorSystemRoot 0x100302300> path=/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk version=4.3 name=Simulator - iOS 4.3
[DEBUG] using device family ipad
[DEBUG] Session started
[DEBUG] Session did end with error (null)
[INFO] Application has exited from Simulator
Issue still exists. Tested with 1.8.0.v20111006001414 with iPad 2 4.3.5. Let it sit and eventually it will crash. Or you can rotate the device and it will crash faster.
Alan: I'm not seeing a crash. I ran the example code on my iPad 2 running 4.3.5 with 1.8.0, rotating it quite vigorously, for 5 or so minutes before I gave up. Were you running it for longer? If you are still seeing this crash, would you reopen the ticket and provide a crash log? version=1.8.0 timestamp=10/28/11 15:46 githash=79c174b...
Tested with Ti Studio 1.0.7.201111182325 on OSX Lion Ti Mob SDK 1.8.0.1.v20111121090256 iPhone 4S OS 5.0, iPad 2 OS 4.3.5 Popover not causing crash when rotating or in one orientation