Skip to content

ADB protocol desync errors during concurrent operations #175

@nandor23

Description

@nandor23

Hello,

I'm experiencing ADB protocol-level errors that suggest the TCP stream gets out of sync:

* respones used 2561394801 for our local_id instead of 90260985
* got CLSE in respone instead of OKAY
* got WRTE in respone instead of OKAY

I'm running ADB commands simultaneously on multiple Android emulators, where each ADBTcpDevice instance connects to exactly one emulator. Once these errors occur, retrying commands on the same connection continues to fail with similar protocol mismatches.

Example code:

fn capture_framebuffer(device: &Arc<Mutex<ADBTcpDevice>>) -> ImageBuffer<Rgba<u8>, Vec<u8>> {
    loop {
        match device.lock().unwrap().framebuffer_inner() {
            Ok(framebuffer) => return framebuffer,
            Err(e) => {
                error!("Failed to capture framebuffer: {}. Retrying...", e);
                sleep(Duration::from_millis(500));
            }
        }
    }
}

After the first error, all retries fail with errors mentioned above. Each device has its own Arc<Mutex<ADBTcpDevice>> with only one thread using it, so this isn't a concurrency issue on my end.

Question:

What's the best way to handle this? Should the library recover automatically, or do I need to recreate the device connection when these errors occur? There doesn't seem to be a way to reset the session state on an existing connection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions