[Web Driver Agent] Issues with WDA startup time

As I see from the logs of java-client last build - build(deps): Bump actions/setup-java from 3 to 4 (#2081) · appium/java-client@5cd439a · GitHub

There is exactly the same thing happened -

appium driver run xcuitest build-wda

command build the WDA for the firstly selected simulator (iPhone 8) in this case

info iOSSim Constructing iOS simulator for Xcode version 14.2 with udid 'F55B010D-0DF2-43EE-B39D-C8BD58D020FF'
[16](https://github.com/appium/java-client/actions/runs/7086392810/job/19284567350#step:11:17)[12:15:46] Building WDA for iPhone 8 16.2 Simulator...

When later in the next steps the iPhone 12 is being prepared during the E2E run it still builds the WDA separately for this iPhone 12:

[XCUITestDriver@1805 (921ee00f)] Starting WebDriverAgent initialization with the synchronization key ‘XCUITestDriver’

114 [WD Proxy] Matched ‘/status’ to command name ‘getStatus’

115 [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8100/status] with no body

116 [WD Proxy] connect ECONNREFUSED 127.0.0.1:8100

117 [XCUITestDriver@1805 (921ee00f)] WDA is not listening at ‘http://127.0.0.1:8100/

118 [XCUITestDriver@1805 (921ee00f)] WDA is currently not running. There is nothing to cache

119 [XCUITestDriver@1805 (921ee00f)] Trying to start WebDriverAgent 2 times with 10000ms interval

120 [XCUITestDriver@1805 (921ee00f)] These values can be customized by changing wdaStartupRetries/wdaStartupRetryInterval capabilities

121 [XCUITestDriver@1805 (921ee00f)] Event ‘wdaStartAttempted’ logged at 1701692549269 (12:22:29 GMT+0000 (Coordinated Universal Time))

122 [XCUITestDriver@1805 (921ee00f)] Launching WebDriverAgent on the device

123 [XCUITestDriver@1805 (921ee00f)] There is no need to perform the project cleanup. A fresh install has been detected

124 [WebDriverAgent] Killing running processes ‘xcodebuild.*A02193D4-2839-41BE-91E3-8DA6B9151965, A02193D4-2839-41BE-91E3-8DA6B9151965.*XCTRunner, xctest.*A02193D4-2839-41BE-91E3-8DA6B9151965’ for the device A02193D4-2839-41BE-91E3-8DA6B9151965…

125 [WebDriverAgent] ‘pgrep -if xcodebuild.*A02193D4-2839-41BE-91E3-8DA6B9151965’ didn’t detect any matching processes. Return code: 1

126 [WebDriverAgent] ‘pgrep -if xctest.*A02193D4-2839-41BE-91E3-8DA6B9151965’ didn’t detect any matching processes. Return code: 1

127 [WebDriverAgent] ‘pgrep -if A02193D4-2839-41BE-91E3-8DA6B9151965.*XCTRunner’ didn’t detect any matching processes. Return code: 1

128 [XCUITestDriver@1805 (921ee00f)] Beginning test with command ‘xcodebuild build-for-testing test-without-building -project /Users/runner/.appium/node_modules/appium-xcuitest-driver/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=A02193D4-2839-41BE-91E3-8DA6B9151965 IPHONEOS_DEPLOYMENT_TARGET=16.2 GCC_TREAT_WARNINGS_AS_ERRORS=0 COMPILER_INDEX_STORE_ENABLE=NO’ in directory ‘/Users/runner/.appium/node_modules/appium-xcuitest-driver/node_modules/appium-webdriveragent’

129 [XCUITestDriver@1805 (921ee00f)] Output from xcodebuild will only be logged if any errors are present there. To change this, use ‘showXcodeLog’ desired capability

130 [XCUITestDriver@1805 (921ee00f)] Waiting up to 240000ms for WebDriverAgent to start

131 [XCUITestDriver@1805 (921ee00f)] Matched ‘/status’ to command name ‘getStatus’

132 [XCUITestDriver@1805 (921ee00f)] Proxying [GET /status] to [GET http://127.0.0.1:8100/status] with no body

133 [XCUITestDriver@1805 (921ee00f)] connect ECONNREFUSED 127.0.0.1:8100

134 [XCUITestDriver@1805 (921ee00f)] Matched ‘/status’ to command name ‘getStatus’

135 [XCUITestDriver@1805 (921ee00f)] Proxying [GET /status] to [GET http://127.0.0.1:8100/status] with no body

136 [XCUITestDriver@1805 (921ee00f)] connect ECONNREFUSED 127.0.0.1:8100

137 [XCUITestDriver@1805 (921ee00f)] Matched ‘/status’ to command name ‘getStatus’

138 [XCUITestDriver@1805 (921ee00f)] Proxying [GET /status] to [GET http://127.0.0.1:8100/status] with no body

139 [XCUITestDriver@1805 (921ee00f)] connect ECONNREFUSED 127.0.0.1:8100

140 [XCUITestDriver@1805 (921ee00f)] Matched ‘/status’ to command name ‘getStatus’

141 [XCUITestDriver@1805 (921ee00f)] Proxying [GET /status] to [GET http://127.0.0.1:8100/status] with no body

142 [XCUITestDriver@1805 (921ee00f)] connect ECONNREFUSED 127.0.0.1:8100

143 [XCUITestDriver@1805 (921ee00f)] Parsed BUILD_DIR configuration value: ‘/Users/runner/Library/Developer/Xcode/DerivedData/WebDriverAgent-dtmoeonrefnxsncuficthanbldlc/Build/Products’

144 [XCUITestDriver@1805 (921ee00f)] Got derived data root: ‘/Users/runner/Library/Developer/Xcode/DerivedData/WebDriverAgent-dtmoeonrefnxsncuficthanbldlc’

145 [XCUITestDriver@1805 (921ee00f)] Matched ‘/status’ to command name ‘getStatus’

146 [XCUITestDriver@1805 (921ee00f)] Proxying [GET /status] to [GET http://127.0.0.1:8100/status] with no body

147 [XCUITestDriver@1805 (921ee00f)] connect ECONNREFUSED 127.0.0.1:8100

148 [XCUITestDriver@1805 (921ee00f)] Matched ‘/status’ to command name ‘getStatus’

149 [XCUITestDriver@1805 (921ee00f)] Proxying [GET /status] to [GET http://127.0.0.1:8100/status] with no body

150 [XCUITestDriver@1805 (921ee00f)] connect ECONNREFUSED 127.0.0.1:8100

151 [XCUITestDriver@1805 (921ee00f)] Matched ‘/status’ to command name ‘getStatus’

152 [XCUITestDriver@1805 (921ee00f)] Proxying [GET /status] to [GET http://127.0.0.1:8100/status] with no body

153 [XCUITestDriver@1805 (921ee00f)] connect ECONNREFUSED 127.0.0.1:8100

154 [XCUITestDriver@1805 (921ee00f)] Matched ‘/status’ to command name ‘getStatus’

155 [XCUITestDriver@1805 (921ee00f)] Proxying [GET /status] to [GET http://127.0.0.1:8100/status] with no body

156 [XCUITestDriver@1805 (921ee00f)] connect ECONNREFUSED 127.0.0.1:8100

157 [XCUITestDriver@1805 (921ee00f)] Matched ‘/status’ to command name ‘getStatus’

158 [XCUITestDriver@1805 (921ee00f)] Proxying [GET /status] to [GET http://127.0.0.1:8100/status] with no body

It seems to me that the prebuild-driver step is totally unnecessary in this case, because the WDA build still takes place during e2e test’s actual run

I am gonna try the following:

  - run:
      name: Prebuild driver
      command: |
        UDID=$(xcrun simctl list devices available | grep "$iPhone 14 Pro Max (" | cut -d "(" -f2 | cut -d ")" -f1)
        xcodebuild build-for-testing -project /Users/distiller/.appium/node_modules/appium-xcuitest-driver/node_modules/appium-webdriveragent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner  -derivedDataPath /Users/distiller/Library/Developer/Xcode/DerivedData/WebDriverAgentData -destination id=$UDID IPHONEOS_DEPLOYMENT_TARGET=16.2 GCC_TREAT_WARNINGS_AS_ERRORS=0 COMPILER_INDEX_STORE_ENABLE=NO

and use those caps from Run Prebuilt WebDriverAgentRunner - Appium XCUITest Driver

capabilities.setCapability(“appium:useXctestrunFile”, true);
capabilities.setCapability(“appium:bootstrapPath”, “/Users/distiller/Library/Developer/Xcode/DerivedData/WebDriverAgentData/Build/Products”);