Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-5285

iOS: Showing and Hiding Popover Causing App Crash

    Details

      Description

      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.

      app.js

      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
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                stephentramer Stephen Tramer
                Reporter:
                dtoth Dawson Toth
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-4472
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration