Instruments without delay questions - appium tests slow

I have not tried running 1.5 at all yet. I’m a committed late adopter.

@SrinivasanSekar can you see my comments here and then respond ?
For Appium versions prior to 1.5.0 we may have had to do all this setup/execution to get IWD working. But I think that for Appium 1.5.0 or greater…Appium takes care of this automatically…based on my logs?
Please let me know if that is correct or not.

Thanks.

From my experience you’ll know if Instruments is still imposing the forced 1 second delay as every… single… comand… will… have… a… 1… second… Well, you get the picture. :slight_smile: I had a small test suite that took 104 minutes to run, then only 44 minutes after patching with iwd.

Thanks @Christopher_Graham. Is that for a real device or a Simulator? Also what version of Appium are you on ?

In any case am from the link you pasted I started from Step 2…I did not do anything about Step 1 since I already have that folder in my Mac machine. That should suffice, right?

fyi…I’m currently on Appium 1.5.1, Xcode 7.3, iPhone simulator 6s Plus

@Aleksei @moizjv @alangithubtrader @rompic

Thought you may be able to help ? Thanks!

did you try following this post?

I am not using appium 1.5 yet and I am still on xcode 7.2.1. But I think it’s safe to assume that iwd is still not integrated with 1.5.0 if I were to guess.

thanks @alangithubtrader

If that is the case then why am I getting this in the logs when I launch Appium?
[Instruments] On xcode 7.0+, instruments-without-delay does not work, skipping instruments-without-delay
[debug] [Instruments] Found Insruments-Without-Delay: /usr/local/lib/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd7

we have:

  • appium 1.5.1
  • xCode 7.3
  • maven tests
  • CI with Jenkins where tests are starting

and this solves speed problem with Simulator: https://github.com/appium/appium/blob/9dcc6459da668ab5c2d0dfed9d89a08a4ab4db58/docs/en/advanced-concepts/iwd_xcode7.md

I’m currently using Xcode 7.2.1 Appium 1.5.1 here are the instructions I whipped up for my team, let me know if they help you. Note we have npm installed in our user directory to negate need for sudo.

Fix Instruments 1 Second Delay (negatively affects iOS simulator test speed):

1. Uninstall old version of appium-instruments with:

npm uninstall appium-instruments     (use sudo if you happened to install it with sudo previously)

2. Install the latest version of appium-instruments with:

npm install appium-instruments       (should not require sudo)

3. Install worked correctly if no errors were logged, and you have a folder ~/node_modules/appium-instruments/bin   with xcode-iwd.sh in it.

4. Change to your appium-instruments directory, not your appium directory.

5. Run script per instructions here: https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/iwd_xcode7.md

My script was: sh ./bin/xcode-iwd.sh /Applications/Xcode.app /Users/your_username/node_modules/appium-instruments/

6. To verify your .plist was updated, run the following command in terminal:

/usr/libexec/PlistBuddy -c print /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/Developer/Library/LaunchDaemons/com.apple.instruments.deviceservice.plist

It should include the following lines pointing to your appium-instruments directory, not your appium directory. These are what negate the 1 second instruments command delay. Make sure the path:

      EnvironmentVariables = Dict {
        LIB_PATH = /Users/your_username/node_modules/appium-instruments//thirdparty/iwd7/
        DYLD_INSERT_LIBRARIES = /Users/your_username/node_modules/appium-instruments//thirdparty/iwd7/DTMobileISShim.dylib
    }
1 Like

@Aleksei @Christopher_Graham I get all that I guess the gist of all that is that I have to run that shell command:
eg. sh ./bin/xcode_iwd.sh /Applications/Xcode.app /Users/xyz/appium-instruments/

However I am not sure why my point keeps getting lost in translation…maybe because I am not emphasizing it clearly =). What I was saying that even without doing all that if I just run appium this is what I see in the Appium log:
[Instruments] On xcode 7.0+, instruments-without-delay does not work, skipping instruments-without-delay
[debug] [Instruments] Found Insruments-Without-Delay: /usr/local/lib/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd7

So does that mean that with Appium 1.5.1 we are getting to run fwd by default? without having to run that shell script command?

I see the same, and even after running the iwd script my logs look like yours.

[Instruments] On xcode 7.0+, instruments-without-delay does not work, skipping instruments-without-delay
[debug] [Instruments] Found Insruments-Without-Delay: /Users/chrigrah/npm/lib/node_modules/appium/node_modules/appium-ios-driver/node_modules/appium-instruments/thirdparty/iwd7

However, until you run the iwd script and see the correct paths in your .plist like I’ve described you should observe your tests have a forced 1 second delay between every command. At least I did, even when seeing those lines in my Appium logs.

Run the script and successfully add the correct paths to your .plist, you’ll STILL see the exact same Appium logging (with the old Appium paths to .iwd) but your tests will run much faster since there’s no 1 second forced delay.

it is not correct! there is a bug in doc :slight_smile:
correct should be like: sh ./bin/xcode-iwd.sh /Applications/Xcode.app /Users/xyz/appium-instruments/

Thanks @Christopher_Graham I will try it out and see where I get with it

Thanks @Aleksei. Great catch and I noticed that too. If I am running with a CI tool though…would I need to give that command in the execute section? just so that it is run before the actual command to launch appium/run maven test ?

The original instructions here: https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/iwd_xcode7.md as well as the instructions I provided are correct. Looks like @Styris made a typo in his comment. Copy-and-paste is your friend. :slight_smile:

only once and reboot machine. after xCode update repeat the same again.

@Aleksei
Yeah…but I think with Travis-CI you have to do it every time?

@Christopher_Graham @Aleksei I tried your steps (already had 1-2 prior to that). In step 4 I did a cd to the appium-instruments/bin folder. After that I typed this command:
sh ./xcode-iwd.sh /Applications/Xcode.app /Users/xyz/appium-instruments/
Then I ran the plist command you posted
I got this as output:
Dict {
JetsamProperties = Dict {
JetsamMemoryLimit = 0
}
Program = /Developer/Library/PrivateFrameworks/DVTInstrumentsFoundation.framework/DTServiceHub
Label = com.apple.instruments.deviceservice
POSIXSpawnType = Adaptive
MachServices = Dict {
com.apple.instruments.deviceservice.xpc = true
com.apple.instruments.deviceservice.lockdown = true
}
EnableTransactions = true
}

I guess something is amiss? (Fyi my file is at: /usr/local/lib/node_modules/appium/node_modules/appium-ios-driver/node_modules/appium-instruments/bin/xcode-iwd.sh)

Latest version of appium-instruments doesn’t install into the appium directory, that’s where the old version installed. For you, based on your current paths, the new version should install into /usr/local/lib/node_modules/appium-instruments

That’s why I included the uninstall and fresh install as step 1 and step 2, those were the key to success for me.

I believe the old version in the appium subdirectory are for older versions of Xcode. At least I was stuck with the delay until working through all of the steps as I described and getting the .plist updated with the latest paths.

Thanks @Christopher_Graham I believe it I was able to do it. However the only difference was that in line 5 I had to run it with sudo…prior to that I was not getting it.

I haven’t run the tests yet to notice the difference but will try. A couple of questions:

  1. Do I need to run these commands every time I restart my computer? Or just the one time that I already did?
  2. Does this work for a real device?

We’ve installed npm into our users directories to negate need for sudo, so it didn’t require sudo on my end. You can find instructions to do that here: http://www.competa.com/blog/2014/12/how-to-run-npm-without-sudo/

Everytime you update Xcode.

I only test on sims, so cannot comment on real devices at this time.