-
-
Notifications
You must be signed in to change notification settings - Fork 201
fix: Explicitly wait for the server shutdown before killing it forcefully #873
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
Conversation
@@ -438,11 +426,35 @@ class UiAutomator2Server { | |||
await this.adb.killProcessesByName('uiautomator'); | |||
} catch {} | |||
} | |||
await waitStop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I could remember is this random process end delay could occur after the adb.forceStop
also because according to the device's adb log, the process kill related log itself delayed after sending a kill command. I still think we need to ensure the uia2 server has ended in cleanupAutomationLeftovers
as the method's purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me search my past logs if the this.adb.processExists
was reliable on such env. Maybe I have some research comment somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find a good log if this.adb.processExists
is reliable, but I think it should be ok.
So far, I observed the process kill delay in adb logcat before, so we need to assume this.adb.forceStop
itself could have delay to kill the process on the OS internal level. But I assume this.adb.processExists
itself should be ok instead of /status
endpoint check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for checking it.
Basically, this is what I figured out so far by analyzing the server code:
after receiving the shutdown request (which is sent as part of the DELETE session request) the server will asynchronously:
- shutdown http listener and other side servers, like mjpeg broadcaster
- exit the main Junit runner entry point
- exit the server process, which would also stop the instrumentation monitoring
The previous check (GET /status) was only verifying the first stage completion, while we actually need to wait for the last one. On my test phone the time difference between the first and the last stage completion is about 400ms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, this PR idea looks good. Let me see HS's device pool, which could be good for this testing purpose. The original issue was Samsung Android 13+, so probably I could find a device
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lg
I couldn't find the original issue's device but did 100+ loop to start/terminate appium sessions with multiple Samsung Android13+ devices. They didn't have any weird delay issue, so probably good with this
## [4.1.4](v4.1.3...v4.1.4) (2025-03-20) ### Bug Fixes * Explicitly wait for the server shutdown before killing it forcefully ([#873](#873)) ([d3f50ef](d3f50ef))
🎉 This PR is included in version 4.1.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
No description provided.