Skip to content

Commit

Permalink
Merge branch 'master' into default-true
Browse files Browse the repository at this point in the history
  • Loading branch information
KazuCocoa authored Sep 25, 2023
2 parents 6cb92e3 + 85242e7 commit 7ee53cd
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 9 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [2.29.10](https://github.com/appium/appium-uiautomator2-driver/compare/v2.29.9...v2.29.10) (2023-09-24)


### Bug Fixes

* release package ([#658](https://github.com/appium/appium-uiautomator2-driver/issues/658)) ([ef483e3](https://github.com/appium/appium-uiautomator2-driver/commit/ef483e34ec9a23c3b63ab76d849b25403435a58e))

## [2.29.9](https://github.com/appium/appium-uiautomator2-driver/compare/v2.29.8...v2.29.9) (2023-09-21)


### Bug Fixes

* check if the instrumentation process stops by sending a request ([#655](https://github.com/appium/appium-uiautomator2-driver/issues/655)) ([d42950a](https://github.com/appium/appium-uiautomator2-driver/commit/d42950acb44ad8458932f4617cf110825dab8737))

## [2.29.8](https://github.com/appium/appium-uiautomator2-driver/compare/v2.29.7...v2.29.8) (2023-09-14)


Expand Down
41 changes: 34 additions & 7 deletions lib/uiautomator2.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,37 @@ class UiAutomator2Server {
async cleanupAutomationLeftovers (strictCleanup = false) {
this.log.debug(`Performing ${strictCleanup ? 'strict' : 'shallow'} cleanup of automation leftovers`);

const axiosTimeout = 500;

const waitStop = async () => {
// Wait for the process stop by sending a status request to the port.
// We observed the process stop could be delayed, thus causing unexpected crashes
// in the middle of the session preparation process. It caused an invalid session error response
// by the uia2 server, but that was because the process stop's delay.
const timeout = 3000;
try {
await waitForCondition(async () => {
try {
await axios({
url: `http://${this.host}:${this.systemPort}/status`,
timeout: axiosTimeout,
});
} catch (err) {
return true;
}
}, {
waitMs: timeout,
intervalMs: 100,
});
} catch (err) {
this.log.warn(`The ${SERVER_TEST_PACKAGE_ID} process might fail to stop within ${timeout}ms timeout.`);
}
};

try {
const {value} = (await axios({
url: `http://${this.host}:${this.systemPort}/sessions`,
timeout: 500,
timeout: axiosTimeout,
})).data;
const activeSessionIds = value.map(({id}) => id).filter(Boolean);
if (activeSessionIds.length) {
Expand All @@ -329,13 +356,13 @@ class UiAutomator2Server {
try {
await this.adb.forceStop(SERVER_TEST_PACKAGE_ID);
} catch (ignore) {}
if (!strictCleanup) {
return;
if (strictCleanup) {
// https://github.com/appium/appium/issues/10749
try {
await this.adb.killProcessesByName('uiautomator');
} catch (ignore) {}
}
// https://github.com/appium/appium/issues/10749
try {
await this.adb.killProcessesByName('uiautomator');
} catch (ignore) {}
await waitStop();
}
}

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"automated testing",
"android"
],
"version": "2.29.8",
"version": "2.29.10",
"author": "Appium Contributors",
"license": "Apache-2.0",
"repository": {
Expand Down Expand Up @@ -53,7 +53,9 @@
"build/index.js",
"build/lib",
"scripts",
"CHANGELOG.md"
"CHANGELOG.md",
"LICENSE",
"npm-shrinkwrap.json"
],
"dependencies": {
"@babel/runtime": "^7.0.0",
Expand Down

0 comments on commit 7ee53cd

Please sign in to comment.