fix(android): workaround multi-device scrcpy initialization failure#2663
Open
jackliuw1983-afk wants to merge 1 commit into
Open
fix(android): workaround multi-device scrcpy initialization failure#2663jackliuw1983-afk wants to merge 1 commit into
jackliuw1983-afk wants to merge 1 commit into
Conversation
When multiple Android devices are connected, scrcpy initialization fails with "more than one device/emulator" due to a bug in @yume-chan/adb's getDeviceFeatures() which uses a two-step ADB protocol that doesn't inherit device context for host-level services. This adds a runtime workaround that catches the specific error and falls back to the one-shot protocol format (host-serial:S:features) which works correctly in all environments. Upstream fix: yume-chan/ya-webadb#849
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix
--useScrcpyfailing with"more than one device/emulator"when multiple Android devices are connected to the host machine.Problem
When 2+ devices are connected, scrcpy initialization fails:
Root Cause
The upstream
@yume-chan/adblibrary'sgetDeviceFeatures()uses a two-step ADB protocol:host:transport-id:N→ OKAY (transport switch)host:features→ FAIL ❌ (ADB server doesn't inherit device context for host services)The correct one-shot format (
host-serial:S:features) works in all environments.Fix
Add a runtime workaround in
ScrcpyDeviceAdapter.ensureManager()that catches the specific"more than one device/emulator"error and retries using the one-shot protocol format. This is a non-invasive try/catch wrapper around the original method — single-device environments are completely unaffected (the original path succeeds without triggering the fallback).Testing
Verified on Ubuntu 22.04 with 2 USB-connected Android devices:
Upstream
The root cause fix has been submitted to
@yume-chan/ya-webadb:yume-chan/ya-webadb#849
This workaround can be removed once the upstream fix is released and the dependency is updated.
Related
Closes #2662