Instruments without delay questions - appium tests slow

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.

How did you implemented it?

I’ve already provided detailed instructions above.

I’ve followed your instructions and got the next output

EnvironmentVariables = Dict {
        LIB_PATH = /usr/local/lib/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd7/
        DYLD_INSERT_LIBRARIES = /usr/local/lib/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd7/DTMobileISShim.dylib
    }

I’ve installed the instruments with npm install -g …

any way , when I’m launching the appium I’m still getting :

> 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-ios-driver/node_modules/appium-instruments/thirdparty/iwd7
> [debug] [Instruments] Spawning instruments with command: '/Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate -D /var/folders/80/rv4jbh0d0nn4bhnmnnn2zclc0000gp/T/appium-instruments/instrumentscli0.trace -w "iPhone 6s (9.1) [" /Users/ie54553/Automation/AutomationProject/CVM_BUILD/IOS/CitiVelocity.app -e UIASCRIPT "/Users/ie54553/Library/Application Support/appium/bootstrap/bootstrap-0d06df35bd7969e8.js" -e UIARESULTSPATH /var/folders/80/rv4jbh0d0nn4bhnmnnn2zclc0000gp/T/appium-instruments'

and my execution is still slow … (slower than it was on appium 1.4.16 and IWD patch …

I’m running xcode 7.1.1 and ios 9.1

@Aleksei maybe you’ll have some input as well ?

Thanks guys

Oh, now I see that actually the path is wrong ,

EnvironmentVariables = Dict {
LIB_PATH = /usr/local/lib/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd7/
DYLD_INSERT_LIBRARIES = /usr/local/lib/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd7/DTMobileISShim.dylib
}

And there is no such directory …

So I’ve uninstalled the appium-instruments from global and reinstalled it under my user , and rerun the IWD path but the EnvVariables path remains the same …

What else I can do ? reinstall the Xcode ?

The iwd script can only CREATE but not UPDATE the values if they are existing. Sorry, forgot about that part of my adventure. I should’ve logged an issue on GIT so that script can handle CREATE as well as UPDATE. Off to do that now.

You should be seeing a clear failure when it cannot update the currently existing paths:

CHRIGRAH-M-2038:appium-instruments chrigrah$ sh ./bin/xcode-iwd.sh /Applications/Xcode.app /Users/chrigrah/node_modules/appium-instruments/
Add: ":EnvironmentVariables" Entry Already Exists
Add: ":EnvironmentVariables:DYLD_INSERT_LIBRARIES" Entry Already Exists
Add: ":EnvironmentVariables:LIB_PATH" Entry Already Exists

My workaround was to modify the appium-instruments/bin/xcode-iwd.sh to use ‘Set’ instead of ‘Add’ to force it to update. Changed file is as follows:

plist_path=$1/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/Developer/Library/LaunchDaemons/com.apple.instruments.deviceservice.plist
iwd_path=$2/thirdparty/iwd7
# /usr/libexec/PlistBuddy -c "Add :EnvironmentVariables dict" $plist_path
/usr/libexec/PlistBuddy -c "Set :EnvironmentVariables:DYLD_INSERT_LIBRARIES string $iwd_path/DTMobileISShim.dylib" $plist_path
/usr/libexec/PlistBuddy -c "Set :EnvironmentVariables:LIB_PATH string $iwd_path/" $plist_path
1 Like

Logged a Git issue here for the script to be able to update in addition to add paths: https://github.com/appium/appium-instruments/issues/69

yep, that’s what eventually did , updated it manually trough vi …

Thanks

Does that work on both iOS 9.x and 8.4? I managed to make my tests run without delay on 9.x but when I run them on 8.4 they are still slow.

i think it does not work with older. Cause when we did not have problem with delay before i met same issue! It was fine with 8.X (at that time) but slow with 7.X.

@Christopher_Graham and @Aleksei thanks for helping out.
So this takes care of iOS Simulator. Anything similar we could do on the Android side of things to speed up tests?
Thanks.

I primarily do iOS testing and 99.9% of the time in the simulator as it’s fast and easy. For Android testing I’ve always used real devices as the Android emulator is smash-my-head-against-my-desk slow. Downside is many Android devices drain the battery faster than USB can charge them when executing the tests, even with the display brightness at min. I haven’t really spent enough time with Android to have tackled all of those problems.

@Christopher_Graham on my MAC…the iOS simulator is launched automatically (based on my capabilities) when the tests are running. Is it very similar in Android simulator as well? Is it just a matter of declaring the capabilities and the android simulator (I downloaded the free version of Genymotion) will launch automatically?
Someone mentioned to me that you have to manually launch the android simulator (which would work locally but not on CI)…but they were not so sure about it.

Thanks.

Yes, here are some brief (but good) instructions:

https://nishantverma.gitbooks.io/appium-for-android/content/working_with_genymotion_emulator.html

tl;dnr–>the last paragraph is what you really want. I find the whole document to be well written though.

1 Like

Thanks @wreed

I think that would work just fine locally if I launched Genymotion and then got the UDID. But on a CI machine how would you get the UDID of a simulator? specially if it were a cloud-based CI tool :slight_smile:

Btw, would the same also apply to the AVD android Simulator…or was this just for Genymotion?

I could be dead wrong about this (iOS tester here), but does the UDID change on an Android Simulator? On a CI machine I would do my best to set it up so that nothing would change. I really don’t know much about AVD.

I don’t recall if I even ever tried Appium with an Android emulator due to the fact that if I manually launch an Android emulator it takes something like 5+ minutes before the damn thing is up and running VS pretty much instantly on a hardware phone / tablet. I haven’t tried Genymotion and know nothing about it or how it’s different than the supplied Android emulator. Either way, all of the Android stuff should be it’s own thread in the forums as it has nothing to do with IWD which is Apple Instruments specific and not Android related.

Tried to install new machine with :

xcode 7.2.1
appium 1.5.3

all of the above instructions don’t work from some reason, it’s take ages to the element to be found …

Has anyone tried to run it with appium 1.5.3 ?

I tried run on ios 9.3 iPhone 6s simulator with appium 1.5.2/1.5.3 and plist already set but no luck. Insterestingly the first day when I tried the test ran fast like a charm and our test execution time reduced from 55mins to 12mins. Unfortunately the next after I reported the amazing experiment result to my boss, I failed to make it work on our Jenkins tests. When I went back to run tests on my local machine, the magic also gone. I retried several hours like recheck plist config, reinstall appium, reboot xcode or machine. it still doesn’t get back. I still haven’t figured out what’s wrong.