Error: Trying to start a session but instruments is still around

Getting this exception while starting tests. The Simulator starts and the app gets installed and invoked. Not able to figure out.

I used Appium 1.3.1 and also 1.3.4 both instances I ran into this. The App itself is built using iOS 8.1 sdk.
Does it need to be built with debug turned on? That is one thing I have not tried.

org.openqa.selenium.WebDriverException: Unable to launch the app: Error: Trying to start a session but instruments is still around (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 6 milliseconds
Build info: version: ‘2.44.0’, revision: ‘76d78cf’, time: ‘2014-10-23 20:02:37’
System info: host: ‘MacBook-Pro.local’, ip: ‘10.1.10.186’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.9.5’, java.version: ‘1.7.0_65’
Session ID: 43452376-6009-4a98-a873-1b458e34e38d
Driver info: com.mytest.mobile.qa.functions.AppWebDriver
Capabilities [{newCommandTimeout=45000, app=/Users/local/workspace/MobileAutomation/…/…/Documents/Workrelated/MyTest.app, platform=MAC, databaseEnabled=false, javascriptEnabled=true, platformName=iOS, deviceName=iPhone 6, browserName=iOS, launchTimeout=9000000, webStorageEnabled=false, networkConnectionEnabled=false, desired={newCommandTimeout=45000, app=/Users/local/workspace/MobileAutomation/…/…/Documents/Workrelated/MyTest.app, deviceName=iPhone 6, platformName=iOS, launchTimeout=9000000}, locationContextEnabled=false, warnings={}, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:76)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:87)
at io.appium.java_client.AppiumDriver.launchApp(AppiumDriver.java:412)
at com.mytest.mobile.qa.tests.LoginViewTest.setUp(LoginViewTest.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

APPIUM IDE OUTPUT:

info: [IOS_SYSLOG_ROW ] Jan 21 17:19:28 MacBook-Pro.local MyTest[47591]: Normal message received by listener connection. Ignoring.
info: [debug] [INST] 2015-01-22 01:19:27 +0000 Debug: evaluation finished
info: [debug] [INST] 2015-01-22 01:19:27 +0000 Debug: responding with:
info: [debug] [INST] 2015-01-22 01:19:27 +0000 Debug: Running system command #2: /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:0,“value”:“PORTRAIT”}…
info: [debug] [INST] 2015-01-22 01:19:28 +0000 Debug: Got new command 2 from instruments: au.mainApp().getTreeForXML()
info: [debug] [INST] 2015-01-22 01:19:28 +0000 Debug: evaluating au.mainApp().getTreeForXML()

info: [debug] [INST] 2015-01-22 01:19:28 +0000 Debug: evaluation finished
info: [debug] [INST] 2015-01-22 01:19:28 +0000 Debug: responding with:true,“visible”:true,“hint”:null,“path”:"/0/0",“x”:0,“y”:0,“width”:320,“height”:568},">":[{“UIAImage”:{"@":{“name”:null,“label”:null,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0/0/0",“x”:0,“y”:0,“width”:320,“height”:568},">":[]}},{“UIAActivityIndicator”:{"@":{“name”:“In progress”,“label”:“In progress”,“value”:“1”,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0/0/1",“x”:140,“y”:468,“width”:37,“height”:37},">":[]}}]}},{“UIAWindow”:{"@":{“name”:null,“label”:null,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:false,“hint”:null,“path”:"/0/1",“x”:0,“y”:0,“width”:320,“height”:568},">":[{“UIAStatusBar”:{"@":{“name”:null,“label”:null,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:false,“hint”:null,“path”:"/0/1/0",“x”:0,“y”:0,“width”:320,“height”:20},">":[{“UIAElement”:{"@":{“name”:“Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top”,“label”:null,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:false,“hint”:“Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top”,“path”:"/0/1/0/0",“x”:6,“y”:0,“width”:38,“height”:20},">":[]}},{“UIAElement”:{"@":{“name”:“3 of 3 Wi-Fi bars”,“label”:“3 of 3 Wi-Fi bars”,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:false,“hint”:“Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top”,“path”:"/0/1/0/1",“x”:49,“y”:0,“width”:13,“height”:20},">":[]}},{“UIAElement”:{"@":{“name”:“5:19 PM”,“label”:“5:19 PM”,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:false,“hint”:“Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top”,“path”:"/0/1/0/2",“x”:138,“y”:0,“width”:45,“height”:20},">":[]}},{“UIAElement”:{"@":{“name”:“100% battery power”,“label”:“100% battery power”,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:false,“hint”:“Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top”,“path”:"/0/1/0/3",“x”:290,“y”:0,“width”:25,“height”:20},">":[]}}]}}]}}]}}}
info: [debug] [INST] 2015-01-22 01:19:28 +0000 Debug: Running system command #3: /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{“status”:0,“value”:{“UIAApplication”:{"@":{“name”:“MyTest”,“label”:“MyTest”,“value”:null,“dom”:null,…

info: [IOS_SYSLOG_ROW ] Jan 21 17:19:28 MacBook-Pro.local securityd[47568]: SecTaskCopyAccessGroups No keychain access group specified whilst running in simulator, falling back to default set

info: [debug] Socket data received (2744 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {“status”:0,“value”:{“UIAApplication”:{"@":{“name”:“MyTest”,“label”:“MyTest”,“value”:null,“dom”:null,“enabled”:true,“valid”:true,“visible”:true,“hint”:null,“path”:"/0",“x”:0,“y”:0,“width”:320,“height”:568},">":[{“UIAWindow”:{"@":{“name”:null,“label”:null,“value”:null,“dom”:null,“enabled”:true,“valid”:
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to the default of 7200 secs
info: [debug] Appium session started with sessionId 1337bc63-2bd0-42b7-9f42-c83955dcd169
info: <-- POST /wd/hub/session 303 13000.057 ms - 9
info: --> GET /wd/hub/session/1337bc63-2bd0-42b7-9f42-c83955dcd169 {}
info: [debug] Responding to client with success: {“status”:0,“value”:{“webStorageEnabled”:false,“locationContextEnabled”:false,“browserName”:“iOS”,“platform”:“MAC”,“javascriptEnabled”:true,“databaseEnabled”:false,“takesScreenshot”:true,“networkConnectionEnabled”:false,“warnings”:{},“desired”:{“app”:"/Users/local/workspace/MobileAutomation/…/…/Documents/Workrelated/MyTest.app",“platformName”:“iOS”,“deviceName”:“iPhone 5s”,“launchTimeout”:9000000},“app”:"/Users/local/workspace/MobileAutomation/…/…/Documents/Workrelated/MyTest.app",“platformName”:“iOS”,“deviceName”:“iPhone 5s”,“launchTimeout”:9000000},“sessionId”:“1337bc63-2bd0-42b7-9f42-c83955dcd169”}
info: <-- GET /wd/hub/session/1337bc63-2bd0-42b7-9f42-c83955dcd169 200 0.879 ms - 610 {“status”:0,“value”:{“webStorageEnabled”:false,“locationContextEnabled”:false,“browserName”:“iOS”,“platform”:“MAC”,“javascriptEnabled”:true,“databaseEnabled”:false,“takesScreenshot”:true,“networkConnectionEnabled”:false,“warnings”:{},“desired”:{“app”:"/Users/local/workspace/MobileAutomation/…/…/Documents/Workrelated/MyTest.app",“platformName”:“iOS”,“deviceName”:“iPhone 5s”,“launchTimeout”:9000000},“app”:"/Users/local/workspace/MobileAutomation/…/…/Documents/Workrelated/MyTest.app",“platformName”:“iOS”,“deviceName”:“iPhone 5s”,“launchTimeout”:9000000},“sessionId”:“1337bc63-2bd0-42b7-9f42-c83955dcd169”}

error: Trying to start a session but instruments is still around

info: --> POST /wd/hub/session/1337bc63-2bd0-42b7-9f42-c83955dcd169/timeouts/implicit_wait {“ms”:60000}
info: [debug] Set iOS implicit wait to 60000ms
info: [debug] Responding to client with success: {“status”:0,“value”:null,“sessionId”:“1337bc63-2bd0-42b7-9f42-c83955dcd169”}

Closing this… found the problem… my bad.,

  • I was trying to launch the App in my code. While, I had configured Appium to launch it automatically.
    so when the App was already running, launchApp() caused that problem. I did not see this when running on Android but encountered it in iOS.