-
-
Notifications
You must be signed in to change notification settings - Fork 185
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
fix: check if the instrumentation process stops by sending a request #655
Conversation
lib/uiautomator2.js
Outdated
try { | ||
await waitForCondition(async () => { | ||
try { | ||
await this.jwproxy.command('/status', 'GET'); |
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 assume jwproxy might not exist on this stage
Either perform requests using raw axios like we do it below or simply check the process existence using processExists API.
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 use axios one. thought the process check, but potentially the weird os situation could tell a lie (I don't have the env anymore, so cannot check that though)
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.
Updated.
Latest error case:
[debug] [AndroidUiautomator2Driver@965b (79f6d2c7)] Performing shallow cleanup of automation leftovers
[debug] [AndroidUiautomator2Driver@965b (79f6d2c7)] No obsolete sessions have been detected (socket hang up)
[debug] [ADB] Running '/Users/kazu/Library/Android/sdk/platform-tools/adb -P 5037 -s D0AA002182JC0202126 shell am force-stop io.appium.uiautomator2.server.test'
[AndroidUiautomator2Driver@965b (79f6d2c7)] The instrumentation process might fail to stop within 3000ms timeout.
[debug] [AndroidUiautomator2Driver@965b (79f6d2c7)] Deleting UiAutomator2 session
[debug] [AndroidUiautomator2Driver@965b (79f6d2c7)] Deleting UiAutomator2 server session
[debug] [AndroidUiautomator2Driver@965b (79f6d2c7)] Matched '/' to command name 'deleteSession'
[AndroidUiautomator2Driver@965b (79f6d2c7)] Did not get confirmation UiAutomator2 deleteSession worked; Error was: UnknownError: An unknown server-side error occurred while processing the command. Original error: Trying to proxy a session command without session id
[debug] [ADB] Running '/Users/kazu/Library/Android/sdk/platform-tools/adb -P 5037 -s D0AA002182JC0202126 shell dumpsys activity services io.appium.settings/.recorder.RecorderService'
[debug] [Logcat] Stopping logcat capture
[debug] [ADB] Removing forwarded port socket connection: 8800
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.
maybe something else is needed in addition to force-stop io.appium.uiautomator2.server.test
to fully stop the automation. I expect to not see [AndroidUiautomator2Driver@965b (79f6d2c7)] The instrumentation process might fail to stop within 3000ms timeout.
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.
Perhaps we should just kill all active instrumentation processes using adb.killProcessesByName ?
It is just necessary to check the actual ps output while it is running
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.
Hm... killing all instrumentation process seems too aggressive...?
What I saw was kind of "delay", but it did not have multiple instrumentation processes. so for now, maybe we can see how this will help...?
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.
after thinking a few, probably "waiting for the process might be stopped (no response for the port)" thing is sufficient for my observation at this time.
The session failure would occur in the createSession
, so existing teardown can cover cases. The purpose of this is to make sure the process stop (and if not, let users know possible issue as a warning), thus just printing log is enough
## [2.29.9](v2.29.8...v2.29.9) (2023-09-21) ### Bug Fixes * check if the instrumentation process stops by sending a request ([#655](#655)) ([d42950a](d42950a))
🎉 This PR is included in version 2.29.9 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I observed weird behavior on an Android 13 Samsung device. This was only a specific device so far but potentially could happen on other devices. (I mean I cannot say this does not happen on other devices)
What I saw was in a new session request from uia2 driver to the uia2 server. These are in
createSession
indriver.js
./wd/hub/session
create session -> ok 200/wd/hub/session/0e62d0be-bfb4-403e-8b85-6af9ae40fbfd/appium/device/info
-> ok/wd/hub/session/0e62d0be-bfb4-403e-8b85-6af9ae40fbfd/appium/device/pixel_ratio
-> invalid session id for0e62d0be-bfb4-403e-8b85-6af9ae40fbfd
According to the adb log cat, it seems like the uia2 server process stop in
cleanupAutomationLeftovers
? probably delayed. So activity stop log actually existed before/wd/hub/session
in the above, but the process kill itself conducted AFTER/wd/hub/session/0e62d0be-bfb4-403e-8b85-6af9ae40fbfd/appium/device/info
. Then the instrumentation process started again, maybe by the instrumentation command.So probably that happened on the device was something activity handling by the OS had delayed.
So, in this PR, I'd like to check if the
cleanupAutomationLeftovers
can ensure that the process (the same port is fine to avoid this behavior) actually stops. Then, I expect like the above weird "delay" also can be avoidable.Error example when this check fails: