Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: tune webDriverAgentUrl case by skiping xcodebuild stuff #691

Merged
merged 4 commits into from
May 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions lib/webdriveragent.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class WebDriverAgent {

this.prebuildWDA = args.prebuildWDA;

// this.args.webDriverAgentUrl guiarantees the capabilities acually
// gave 'appium:webDriverAgentUrl' but 'this.webDriverAgentUrl'
// could be used for caching WDA with xcodebuild.
this.webDriverAgentUrl = args.webDriverAgentUrl;

this.started = false;
Expand All @@ -64,10 +67,7 @@ class WebDriverAgent {
this.usePreinstalledWDA = args.usePreinstalledWDA;
this.xctestApiClient = null;

// FIXME: maybe 'this.webDriverAgentUrl' also can ignore
// the xcodebuild instance itself.

this.xcodebuild = this.usePreinstalledWDA
this.xcodebuild = this.canSkipXcodebuild
? null
: new XcodeBuild(this.xcodeVersion, this.device, {
platformVersion: this.platformVersion,
Expand Down Expand Up @@ -96,12 +96,22 @@ class WebDriverAgent {
}, this.log);
}

/**
* Return true if the session does not need xcodebuild.
* @returns {boolean} Whether the session needs/has xcodebuild.
*/
get canSkipXcodebuild () {
// Use this.args.webDriverAgentUrl to guarantee
// the capabilities set gave the `appium:webDriverAgentUrl`.
return this.usePreinstalledWDA || this.args.webDriverAgentUrl;
mykola-mokhnach marked this conversation as resolved.
Show resolved Hide resolved
}

/**
*
* @returns {string} Bundle ID for Xctest.
*/
get bundleIdForXctest () {
return `${this.updatedWDABundleId}.xctrunner` || WDA_RUNNER_BUNDLE_ID_FOR_XCTEST;
return this.updatedWDABundleId ? `${this.updatedWDABundleId}.xctrunner` : WDA_RUNNER_BUNDLE_ID_FOR_XCTEST;
}

setWDAPaths (bootstrapPath, agentPath) {
Expand Down Expand Up @@ -266,7 +276,7 @@ class WebDriverAgent {
return;
}

if (this.usePreinstalledWDA) {
if (this.canSkipXcodebuild) {
return;
}
try {
Expand Down Expand Up @@ -451,10 +461,13 @@ class WebDriverAgent {
this.xctestApiClient.stop();
this.xctestApiClient = null;
}
} else {
} else if (!this.args.webDriverAgentUrl) {
this.log.info('Shutting down sub-processes');
await this.xcodebuild.quit();
await this.xcodebuild.reset();
} else {
this.log.debug('Do not stop xcodebuild nor XCTest session ' +
'since the WDA session is managed by outside this driver.');
}

if (this.jwproxy) {
Expand Down Expand Up @@ -496,7 +509,7 @@ class WebDriverAgent {
}

async retrieveDerivedDataPath () {
if (this.usePreinstalledWDA) {
if (this.canSkipXcodebuild) {
return;
}
return await this.xcodebuild.retrieveDerivedDataPath();
Expand Down