An unknown server-side error occurred while processing the command. Original error: unknown error: Device is already in use

Hi, I ran the test on HUAWEI P40 lite device. When I try to switch from NATIVE_APP to WEBVIEW context than got the following error on console:

[INFO] 2021.09.13 14:00:52.898: Trying to switch context: ‘WEBVIEW_com.huawei.browser’
[INFO] 2021.09.13 14:00:53.401: Available contexts: [NATIVE_APP, WEBVIEW_xxx.xxxx.xxxx.xx, WEBVIEW_com.huawei.browser]
io.appium.java_client.NoSuchContextException: An unknown server-side error occurred while processing the command. Original error: An unknown server-side error occurred while processing the command. Original error: unknown error: Device EPHUT20B05021359 is already in use

I understand that error occurred due to different android versions. On HUAWEI P40 lite has HUAWEI Browser (Version 11.1.3.310)

I’m using Appium Version 1.15.1 (1.15.1.20191013.2)

Appium log file:
2021-09-13 11:00:53:865 - [debug] [35m[Chromedriver][39m Found 7 executables in ‘/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac’
2021-09-13 11:00:53:937 - [debug] [35m[Chromedriver][39m The following Chromedriver executables were found:
2021-09-13 11:00:53:937 - [debug] [35m[Chromedriver][39m ‘/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver_mac64_v92.0.4515.43’ (version ‘92.0.4515.43’, minimum Chrome version ‘92.0.0’)
2021-09-13 11:00:53:937 - [debug] [35m[Chromedriver][39m ‘/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver_mac64_v89.0.4389.23’ (version ‘89.0.4389.23’, minimum Chrome version ‘89.0.4389’)
2021-09-13 11:00:53:937 - [debug] [35m[Chromedriver][39m ‘/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver_mac64_v88.0.4324.96’ (version ‘88.0.4324.96’, minimum Chrome version ‘88.0.4324’)
2021-09-13 11:00:53:938 - [debug] [35m[Chromedriver][39m ‘/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver_mac64_v88.0.4324.27’ (version ‘88.0.4324.27’, minimum Chrome version ‘88.0.0’)
2021-09-13 11:00:53:938 - [debug] [35m[Chromedriver][39m ‘/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver_mac64_v78.0.3904.105’ (version ‘78.0.3904.105’, minimum Chrome version ‘78.0.3904’)
2021-09-13 11:00:53:938 - [debug] [35m[Chromedriver][39m ‘/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver_mac64_v78.0.3904.70’ (version ‘78.0.3904.70’, minimum Chrome version ‘78.0.3904’)
2021-09-13 11:00:53:938 - [debug] [35m[Chromedriver][39m ‘/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver_mac64_v78.0.3904.11’ (version ‘78.0.3904.11’, minimum Chrome version ‘78.0.3904’)
2021-09-13 11:00:53:938 - [debug] [35m[Chromedriver][39m Browser version in the supplied details: Chrome/88.0.4324.93
2021-09-13 11:00:53:938 - [debug] [35m[Chromedriver][39m Found Chrome bundle ‘undefined’ version ‘88.0.4324’
2021-09-13 11:00:53:938 - [debug] [35m[Chromedriver][39m Found 2 executables capable of automating Chrome ‘88.0.4324’.
2021-09-13 11:00:53:938 - [debug] [35m[Chromedriver][39m Choosing the most recent, ‘/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver_mac64_v88.0.4324.96’.
2021-09-13 11:00:53:938 - [debug] [35m[Chromedriver][39m If a specific version is required, specify it with the chromedriverExecutabledesired capability.
2021-09-13 11:00:53:938 - [35m[Chromedriver][39m Set chromedriver binary as: /usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver_mac64_v88.0.4324.96
2021-09-13 11:00:53:939 - [debug] [35m[Chromedriver][39m Killing any old chromedrivers, running: pkill -15 -f “/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver_mac64_v88.0.4324.96.*–port=4938”
2021-09-13 11:00:53:972 - [35m[Chromedriver][39m No old chromedrivers seem to exist
2021-09-13 11:00:53:973 - [debug] [35m[Chromedriver][39m Cleaning this device’s adb forwarded port socket connections: EPHUT20B05021359
2021-09-13 11:00:53:973 - [debug] [35m[ADB][39m List forwarding ports
2021-09-13 11:00:53:973 - [debug] [35m[ADB][39m Running ‘/Users/automation/Library/Android/sdk/platform-tools/adb -P 5037 -s EPHUT20B05021359 forward --list’
2021-09-13 11:00:53:982 - [debug] [35m[ADB][39m Removing forwarded port socket connection: 60748
2021-09-13 11:00:53:982 - [debug] [35m[ADB][39m Running ‘/Users/automation/Library/Android/sdk/platform-tools/adb -P 5037 -s EPHUT20B05021359 forward --remove tcp:60748’
2021-09-13 11:00:53:992 - [35m[Chromedriver][39m Spawning chromedriver with: /usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver_mac64_v88.0.4324.96 --url-base=wd/hub --port=4938 --adb-port=5037 --verbose
2021-09-13 11:00:54:012 - [debug] [35m[Chromedriver][39m Chromedriver version: ‘88.0.4324.96’
2021-09-13 11:00:54:012 - [debug] [35m[Chromedriver][39m [STDOUT] Starting ChromeDriver 88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/branch-heads/4324@{#1784}) on port 4938
2021-09-13 11:00:54:012 - [debug] [35m[Chromedriver][39m [STDOUT] Only local connections are allowed.
2021-09-13 11:00:54:012 - [debug] [35m[Chromedriver][39m [STDOUT] Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
2021-09-13 11:00:54:013 - [debug] [35m[WD Proxy][39m Matched ‘/status’ to command name ‘getStatus’
2021-09-13 11:00:54:013 - [debug] [35m[WD Proxy][39m Proxying [GET /status] to [GET http://127.0.0.1:4938/wd/hub/status] with no body
2021-09-13 11:00:54:016 - [debug] [35m[WD Proxy][39m Got response with status 200: {“value”:{“build”:{“version”:“78.0.3904.105 (60e2d8774a8151efa6a00b1f358371b1e0e07ee2-refs/branch-heads/3904@{#877})”},“message”:“ChromeDriver ready for new sessions.”,“os”:{“arch”:“x86_64”,“name”:“Mac OS X”,“version”:“10.16.0”},“ready”:true}}
2021-09-13 11:00:54:016 - [35m[Chromedriver][39m Starting W3C Chromedriver session with capabilities: {
2021-09-13 11:00:54:016 - [35m[Chromedriver][39m “capabilities”: {
2021-09-13 11:00:54:016 - [35m[Chromedriver][39m “alwaysMatch”: {
2021-09-13 11:00:54:016 - [35m[Chromedriver][39m “goog:chromeOptions”: {
2021-09-13 11:00:54:016 - [35m[Chromedriver][39m “androidPackage”: “xxx.xxxx.xxxx.xx”,
2021-09-13 11:00:54:016 - [35m[Chromedriver][39m “androidUseRunningApp”: true,
2021-09-13 11:00:54:016 - [35m[Chromedriver][39m “androidDeviceSerial”: “EPHUT20B05021359”,
2021-09-13 11:00:54:016 - [35m[Chromedriver][39m “androidProcess”: “com.huawei.browser”
2021-09-13 11:00:54:016 - [35m[Chromedriver][39m },
2021-09-13 11:00:54:016 - [35m[Chromedriver][39m “goog:loggingPrefs”: {
2021-09-13 11:00:54:016 - [35m[Chromedriver][39m “browser”: “ALL”
2021-09-13 11:00:54:016 - [35m[Chromedriver][39m }
2021-09-13 11:00:54:016 - [35m[Chromedriver][39m }
2021-09-13 11:00:54:016 - [35m[Chromedriver][39m }
2021-09-13 11:00:54:016 - [35m[Chromedriver][39m }

2021-09-13 11:00:54:019 - [35m[Chromedriver][39m [STDERR] [1631530854.018][DEBUG]: Sending adb command: host:devices
2021-09-13 11:00:54:019 - [35m[Chromedriver][39m [STDERR] [1631530854.018][DEBUG]: Received adb response: EPHUT20B05021359 device
2021-09-13 11:00:54:019 - [35m[Chromedriver][39m [STDERR] [1631530854.018][INFO]: [ea77437460d3e3eb306740bd166a1ac6] RESPONSE InitSession ERROR unknown error: Device EPHUT20B05021359 is already in use
2021-09-13 11:00:54:019 - [35m[Chromedriver][39m [STDERR] [1631530854.018][DEBUG]: Log type ‘driver’ lost 0 entries on destruction
2021-09-13 11:00:54:019 - [35m[Chromedriver][39m [STDERR] [1631530854.018][DEBUG]: Log type ‘browser’ lost 0 entries on destruction
2021-09-13 11:00:54:020 - [35m[WD Proxy][39m Got response with status 500: {“value”:{“error”:“unknown error”,“message”:“unknown error: Device EPHUT20B05021359 is already in use”,“stacktrace”:"0 chromedriver_mac64_v78.0.3904.105 0x0000000103664e99 chromedriver_mac64_v78.0.3904.105 + 3747481\n1 chromedriver_mac64_v78.0.3904.105 0x00000001035f94d3 chromedriver_mac64_v78.0.3904.105 + 3306707\n2 chromedriver_mac64_v78.0.3904.105 0x0000000103388fef chromedriver_mac64_v78.0.3904.105 + 749551\n3 chromedriver_mac64_v78.0.3904.105 0x000000010337a2e3 chromedriver_mac64_v78.0.3904.105 + 688867\n4 chromedriver_mac64_v78.0.3904.105 0x00000001032e41b0 chromedriver_mac64_v78.0.3904.105 + 74160\n5 chromedriver_mac64_v78.0.3904.105 0x0000000103314f97 chromedriver_mac64_v78.0.3904.105 + 274327\n6 chromedriver_mac64_v78.0.3904.105 0x0000000103312163 chromedriver_mac64_v78.0.3904.105 + 262499\n7 chromedriver_mac64_v78.0.3904.105 0x00000001032ecb0d chromedriver_mac64_v78.0.3904.105 + 109325\n8 chromedriver_mac64_v78.0.3904.105 0x00000001032edaa5 chromedriver_mac64_v…
2021-09-13 11:00:54:020 - [debug] [35m[W3C][39m Matched W3C error code ‘unknown error’ to UnknownError
2021-09-13 11:00:54:028 - [debug] [35m[Chromedriver][39m UnknownError: An unknown server-side error occurred while processing the command. Original error: unknown error: Device EPHUT20B05021359 is already in use
2021-09-13 11:00:54:029 - [debug] [35m[Chromedriver][39m at errorFromW3CJsonCode (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:780:25)
2021-09-13 11:00:54:029 - [debug] [35m[Chromedriver][39m at ProxyRequestError.getActualError (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:663:14)
2021-09-13 11:00:54:029 - [debug] [35m[Chromedriver][39m at JWProxy.command (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:272:19)
2021-09-13 11:00:54:029 - [debug] [35m[Chromedriver][39m at runMicrotasks ()
2021-09-13 11:00:54:029 - [debug] [35m[Chromedriver][39m at processTicksAndRejections (internal/process/task_queues.js:93:5)
2021-09-13 11:00:54:029 - [debug] [35m[Chromedriver][39m at Chromedriver.startSession (/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/lib/chromedriver.js:589:5)
2021-09-13 11:00:54:029 - [debug] [35m[Chromedriver][39m at Chromedriver.start (/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/lib/chromedriver.js:520:7)
2021-09-13 11:00:54:029 - [debug] [35m[Chromedriver][39m at AndroidUiautomator2Driver.setupNewChromedriver (/usr/local/lib/node_modules/appium/node_modules/appium-android-driver/lib/commands/context.js:440:3)
2021-09-13 11:00:54:029 - [debug] [35m[Chromedriver][39m at AndroidUiautomator2Driver.startChromedriverProxy (/usr/local/lib/node_modules/appium/node_modules/appium-android-driver/lib/commands/context.js:189:10)
2021-09-13 11:00:54:029 - [debug] [35m[Chromedriver][39m at AndroidUiautomator2Driver.switchContext (/usr/local/lib/node_modules/appium/node_modules/appium-android-driver/lib/commands/context.js:125:5)
2021-09-13 11:00:54:029 - [debug] [35m[Chromedriver][39m at AndroidUiautomator2Driver.setContext (/usr/local/lib/node_modules/appium/node_modules/appium-android-driver/lib/commands/context.js:60:3)
2021-09-13 11:00:54:031 - [35m[Chromedriver][39m Chromedriver exited unexpectedly with code null, signal SIGTERM
2021-09-13 11:00:54:031 - [debug] [35m[Chromedriver][39m Changed state to ‘stopped’
2021-09-13 11:00:54:031 - [35m[Chromedriver][39m An unknown server-side error occurred while processing the command. Original error: unknown error: Device EPHUT20B05021359 is already in use
2021-09-13 11:00:54:034 - [debug] [35m[W3C (8204f679)][39m Encountered internal error running command: Error: An unknown server-side error occurred while processing the command. Original error: unknown error: Device EPHUT20B05021359 is already in use