Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10218] iOS: Simulator sometimes launches twice

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-07-15T07:46:49.000+0000
Affected Version/sRelease 2.1.0
Fix Version/sSprint 2012-16 Core, Release 3.0.0
ComponentsiOS
Labelscore, module_build, qe-port, qe-testadded, tooling
ReporterMike Morearty
AssigneeMax Stepanov
Created2012-07-27T14:30:32.000+0000
Updated2013-07-15T07:46:49.000+0000

Description

Problem

When you run a Titanium app in the iPhone Simulator -- either from Titanium Studio or from the command-line "builder.py run myproj" -- it sometimes launches two instances of the iPhone Simulator instead of one. Then, one of them displays an error message complaining that the iPhone Simulator is already running. Expected behavior: Only one instance of iPhone Simulator launches. Note, this bug is intermittent -- it only happens once in a while.

Test case

1. Create app for iPhone 2. Run it in iPhone Simulator 3. If only one iPhone Simulator opens, run it again. Keep repeating; eventually, two simulators will open.

Comments

  1. Mike Morearty 2012-07-27

    Pull request: https://github.com/appcelerator/titanium_mobile/pull/2650 It looks like you guys have been going back and forth on this a bit already: https://github.com/appcelerator/titanium_mobile includes several commits over time that go back and forth on the implementation of how to bring the iPhone Simulator to the foreground, including commit c8d81b8 by Jeff Haynie and commits 46aa65d and b947aea by Blain Hamon. This bug is caused by a race condition: First, iphone/builder.py launches the iPhone Simulator with a call to subprocess.Popen(); and then, it executes some AppleScript to bring the iPhone Simulator to the foreground -- but sometimes, the simulator that is being started by Popen() has not yet fully launched (the process has probably started, but AppleScript doesn't "know" that yet), so when AppleScript is told to bring it to the foreground, it launches another instance of it. My fix is to change the AppleScript so that it first waits (up to several seconds) for the iPhone Simulator to finish launching, and *then* tell it to come to the foreground.
  2. Mike Morearty 2012-07-29

    By the way, in my pull request, I followed the pattern that this project has followed so far with AppleScript: The AppleScript file I added is a "compiled" script, instead of plain text. But I would suggest that it might be nice to use plain text for all short AppleScript files, because if the files are short, then storing them as plain text has essentially no impact on their speed, and offers a few small advantages: * it means you can do "diff"s on them, e.g. with git. * it means you can view their contents with any editor, not just the "AppleScript Editor" application.
  3. Max Stepanov 2012-08-08

    PR merged https://github.com/appcelerator/titanium_mobile/pull/2650
  4. Olga Romero 2012-08-13

    erified fix with: Titanium Studio, build: 2.1.1.201207271312 Titanium SDK: 2.2.0.v20120810194112 Mac osx 10.8 Mountain Lion iOS Simulator 5.1
  5. Priya Agarwal 2013-07-15

    Reopening just to update label.
  6. Priya Agarwal 2013-07-15

    Updated Label and Verified with: Titanium Studio:3.1.2.201307091843 Titanium SDK: 3.1.2.v20130710144553 acs:1.0.3 alloy:1.1.3 npm:1.2.14 titanium:3.1.1 itanium-code-processor:1.0.1 OS: OSX 10.8 Device:iPhone simulator(v 6.0) Xcode: 4.5.1 Only one instance of iphone simulator launches.

JSON Source