appium / appium/java-client

Timeout for unlocking screen seems too short

Open
#1,334 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.3k
Forks
752
Avg merge
6d 21h
Merged PRs (30d)
8

Description

Description

I'm starting an Android emulator which has a lock screen with PIN, so I'm creating the AndroidDriver with these capabilities:
capabilities.setCapability("skipUnlock", false);
capabilities.setCapability("unlockType", "pin");
capabilities.setCapability("unlockKey", "1111");

When the emulator starts it's possible to see the lock screen and the '1111' code been slowly inserted and accepted.

Unfortunately the emulator is somewhat slow after that and I get an error:
«Encountered internal error running command: Error: Screen did not unlock successfully, retrying»

If I start and unlock the screen manually, I can see that it takes some time to the emulator to unlock but it unlocks eventually without any problems, so it seems to me that the timeout for the unlock operation is too short for my situation.

From what I saw on the code, seems that there is a timeout for the verifyUnlock function of 1 second with 2 retries, (so a total of around 2 seconds, which in my case is definitely too quick) and these values seem to be hardcoded.

Do you know a way to get around this problem?

Environment

  • Java client build version: 7.3.0
  • Appium server version: 1.17.0
  • Desktop OS: Windows 10
  • Node.js version: 12.16.1
  • Mobile platform: Android 8.1
  • Emulator

Exception Stacktraces

org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Screen did not unlock successfully, retrying
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: '(...)', ip: '(...)', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_241'
Driver info: driver.version: Driver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Screen did not unlock successfully, retrying
at getResponseForW3CError (C:\Users(...)\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\protocol\errors.js:804:9)
at asyncHandler (C:\Users(...)\AppData\Roaming\npm\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:392:37)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: '(...)', ip: '(...)', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_241'
Driver info: driver.version: Driver

at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:208)
at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:217)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)

(...)

Appium Logs

[debug] [BaseDriver] Event 'newSessionStarted' logged at 1586948668702 (12:04:28 GMT+0100 (GMT+01:00))
[debug] [W3C] Encountered internal error running command: Error: Screen did not unlock successfully, retrying
[debug] [W3C] at C:\Users(...)\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\android-helpers.js:675:13
[debug] [W3C] at wrapped (C:\Users(...)\AppData\Roaming\npm\node_modules\appium\node_modules\asyncbox\lib\asyncbox.js:35:13)
[debug] [W3C] at retry (C:\Users(...)\AppData\Roaming\npm\node_modules\appium\node_modules\asyncbox\lib\asyncbox.js:18:13)
[debug] [W3C] at retryInterval (C:\Users(...)\AppData\Roaming\npm\node_modules\appium\node_modules\asyncbox\lib\asyncbox.js:45:10)
[debug] [W3C] at Object.verifyUnlock (C:\Users(...)\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\android-helpers.js:673:3)
[debug] [W3C] at Object.unlock (C:\Users(...)\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\android-helpers.js:668:5)
[debug] [W3C] at AndroidUiautomator2Driver.startUiAutomator2Session (C:\Users(...)\AppData\Roaming\npm\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\driver.js:373:7)
[debug] [W3C] at AndroidUiautomator2Driver.createSession (C:\Users(...)\AppData\Roaming\npm\node_modules\appium\node_modules\appium-uiautomator2-driver\lib\driver.js:212:7)
[debug] [W3C] at AppiumDriver.createSession (C:\Users(...)\AppData\Roaming\npm\node_modules\appium\lib\appium.js:358:35)
[debug] [W3C] Destroying socket connection
[HTTP] <-- POST /wd/hub/session 500 40822 ms - 659

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported Android driver path in appium-android-driver/lib/android-helpers.js, especially verifyUnlock and unlock, and compare it with the Java client capabilities skipUnlock, unlockType, and unlockKey. Check how the unlock timeout and retries are defined and whether the Java client exposes a configuration path; done means slow emulators can unlock reliably without the reported session-creation error.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java, javascript
Domain
mobile, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.