-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
ERROR: Could not list ADB devices ERROR: Server connection failed #3534
Comments
adb devices -l
echo ℅ADB℅ ? |
|
This output parses correctly, so you should not get Are you absolutely sure that your device was detected when you executed |
Yes, because I tried to kill the service and restart it, whether USB debugging is allowed for the mobile phone also appears。
|
Oh, it seems the same as #3386. |
Yes, I also looked at this #3386 question and saw that you said it might be an OS related permissions issue. |
If there is a problem in scrcpy (something that may cause the reading of the output of a process fail on some Windows systems under some conditions), it's in this function: scrcpy/app/src/sys/win/process.c Lines 26 to 216 in 72ba913
|
Sorry, my current programming level is not high enough to understand this. |
Please try this binary (replace the file in your 1.24 release), which prints more logs (based on #3386 (comment) but with additional logs):
diffdiff --git a/app/src/adb/adb.c b/app/src/adb/adb.c
index 344f7fcc..fbb2b8b5 100644
--- a/app/src/adb/adb.c
+++ b/app/src/adb/adb.c
@@ -401,6 +401,7 @@ sc_adb_list_devices(struct sc_intr *intr, unsigned flags,
#define BUFSIZE 65536
char *buf = malloc(BUFSIZE);
if (!buf) {
+ LOG_OOM();
return false;
}
@@ -413,11 +414,13 @@ sc_adb_list_devices(struct sc_intr *intr, unsigned flags,
}
ssize_t r = sc_pipe_read_all_intr(intr, pid, pout, buf, BUFSIZE - 1);
+ LOGI("sc_pipe_read_all_intr() returned %d", (int) r);
sc_pipe_close(pout);
bool ok = process_check_success_intr(intr, pid, "adb devices -l", flags);
if (!ok) {
free(buf);
+ LOGE("'adb devices -l' failed");
return false;
}
@@ -440,6 +443,7 @@ sc_adb_list_devices(struct sc_intr *intr, unsigned flags,
// List all devices to the output list directly
ok = sc_adb_parse_devices(buf, out_vec);
+ LOGI("sc_adb_parse_device() ok? %d", ok);
free(buf);
return ok;
}
diff --git a/app/src/util/process.c b/app/src/util/process.c
index 9c4dcd9f..8aa7c01f 100644
--- a/app/src/util/process.c
+++ b/app/src/util/process.c
@@ -11,10 +11,14 @@ sc_process_execute(const char *const argv[], sc_pid *pid, unsigned flags) {
ssize_t
sc_pipe_read_all(sc_pipe pipe, char *data, size_t len) {
+ char *buf = data;
size_t copied = 0;
while (len > 0) {
ssize_t r = sc_pipe_read(pipe, data, len);
if (r <= 0) {
+ LOGI("sc_pipe_read() returned %d when copied=%d", (int) r, (int) copied);
+ if (copied > 0)
+ LOGI("data===[\n%.*s\n]===", (int) copied, buf);
return copied ? (ssize_t) copied : r;
}
len -= r;
diff --git a/app/src/util/process_intr.c b/app/src/util/process_intr.c
index d37bd5a5..e99aeea3 100644
--- a/app/src/util/process_intr.c
+++ b/app/src/util/process_intr.c
@@ -1,4 +1,5 @@
#include "process_intr.h"
+#include "log.h"
ssize_t
sc_pipe_read_intr(struct sc_intr *intr, sc_pid pid, sc_pipe pipe, char *data,
@@ -22,6 +23,7 @@ sc_pipe_read_all_intr(struct sc_intr *intr, sc_pid pid, sc_pipe pipe,
char *data, size_t len) {
if (intr && !sc_intr_set_process(intr, pid)) {
// Already interrupted
+ LOGI("sc_pipe_read_all_intr() already interrupted");
return false;
}
@@ -31,5 +33,6 @@ sc_pipe_read_all_intr(struct sc_intr *intr, sc_pid pid, sc_pipe pipe,
sc_intr_set_process(intr, SC_PROCESS_NONE);
}
+ LOGI("sc_pipe_read_all() returns %d", (int) ret);
return ret;
} |
|
One more test, please. Here is another binary with an additional log:
diffdiff --git a/app/src/adb/adb.c b/app/src/adb/adb.c
index 344f7fcc..fbb2b8b5 100644
--- a/app/src/adb/adb.c
+++ b/app/src/adb/adb.c
@@ -401,6 +401,7 @@ sc_adb_list_devices(struct sc_intr *intr, unsigned flags,
#define BUFSIZE 65536
char *buf = malloc(BUFSIZE);
if (!buf) {
+ LOG_OOM();
return false;
}
@@ -413,11 +414,13 @@ sc_adb_list_devices(struct sc_intr *intr, unsigned flags,
}
ssize_t r = sc_pipe_read_all_intr(intr, pid, pout, buf, BUFSIZE - 1);
+ LOGI("sc_pipe_read_all_intr() returned %d", (int) r);
sc_pipe_close(pout);
bool ok = process_check_success_intr(intr, pid, "adb devices -l", flags);
if (!ok) {
free(buf);
+ LOGE("'adb devices -l' failed");
return false;
}
@@ -440,6 +443,7 @@ sc_adb_list_devices(struct sc_intr *intr, unsigned flags,
// List all devices to the output list directly
ok = sc_adb_parse_devices(buf, out_vec);
+ LOGI("sc_adb_parse_device() ok? %d", ok);
free(buf);
return ok;
}
diff --git a/app/src/sys/win/process.c b/app/src/sys/win/process.c
index 6e9da09c..5de3b96c 100644
--- a/app/src/sys/win/process.c
+++ b/app/src/sys/win/process.c
@@ -245,6 +245,7 @@ ssize_t
sc_pipe_read(HANDLE pipe, char *data, size_t len) {
DWORD r;
if (!ReadFile(pipe, data, len, &r, NULL)) {
+ LOGE("ReadFile error: %ld", GetLastError());
return -1;
}
return r;
diff --git a/app/src/util/process.c b/app/src/util/process.c
index 9c4dcd9f..8aa7c01f 100644
--- a/app/src/util/process.c
+++ b/app/src/util/process.c
@@ -11,10 +11,14 @@ sc_process_execute(const char *const argv[], sc_pid *pid, unsigned flags) {
ssize_t
sc_pipe_read_all(sc_pipe pipe, char *data, size_t len) {
+ char *buf = data;
size_t copied = 0;
while (len > 0) {
ssize_t r = sc_pipe_read(pipe, data, len);
if (r <= 0) {
+ LOGI("sc_pipe_read() returned %d when copied=%d", (int) r, (int) copied);
+ if (copied > 0)
+ LOGI("data===[\n%.*s\n]===", (int) copied, buf);
return copied ? (ssize_t) copied : r;
}
len -= r;
diff --git a/app/src/util/process_intr.c b/app/src/util/process_intr.c
index d37bd5a5..e99aeea3 100644
--- a/app/src/util/process_intr.c
+++ b/app/src/util/process_intr.c
@@ -1,4 +1,5 @@
#include "process_intr.h"
+#include "log.h"
ssize_t
sc_pipe_read_intr(struct sc_intr *intr, sc_pid pid, sc_pipe pipe, char *data,
@@ -22,6 +23,7 @@ sc_pipe_read_all_intr(struct sc_intr *intr, sc_pid pid, sc_pipe pipe,
char *data, size_t len) {
if (intr && !sc_intr_set_process(intr, pid)) {
// Already interrupted
+ LOGI("sc_pipe_read_all_intr() already interrupted");
return false;
}
@@ -31,5 +33,6 @@ sc_pipe_read_all_intr(struct sc_intr *intr, sc_pid pid, sc_pipe pipe,
sc_intr_set_process(intr, SC_PROCESS_NONE);
}
+ LOGI("sc_pipe_read_all() returns %d", (int) ret);
return ret;
} |
|
OK, thanks, so the pipe is not valid when read:
https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499- To be investigated. |
@npes87184 Maybe you might have any idea about the cause? It happens only on Windows, only on very few machines apparently (this problem which totally prevents scrcpy to work has been reported only twice). |
Sorry for the late reply. I am quite busy recently. I will take a look #2932 and this issue when I have free time (maybe after 10/22 😵). |
I'm seeing same exact issue, on an Android device running 5.1. It's weird because I have ~6 of these devices I've been testing with today, and this issue only occurs on 2 of the 6. And these two came from a specific manufacturing run we did a year or so ago. Not sure what or how to check, but I'm wondering if there is some sort of flag or permission issue that could cause this associated with a manufacturers specific kernel build? |
@CameronBanga This specific issue ("Could not list ADB devices" while Could you reproduce the problem with always the same devices? Or is it random? (in that case, that could be a race condition, e.g. if the |
@rom1v so far with what I have seen, the device is connected and recognized by ADB without issue. Here's a sample output of
Out of the devices that I have, I have 4 that seem to always connect to scrcpy reliably, and 2 that refuse to connect. The devices are all identical (same size, same Android 5.1, same manufacturer), the only distinguishing difference is that the 2 that refuse to connect are from a specific manufacturing run of the tablets. The other 4 that connect are from other manufacturing runs. |
What is the full scrcpy output when you connect one of these devices? And what is the output of |
It is the output of previous comment, so this is what I see: ⇒ adb devices -l
List of devices attached
GS101200400611 device usb:17825792X product:rk3288 model:rk3288 device:rk3288 transport_id:15 And here is what is see from scrcpy 1.24 <https://github.com/Genymobile/scrcpy>
2022-10-14 13:53:35.075 scrcpy[10883:119447] ERROR: Could not find any ADB device
2022-10-14 13:53:35.432 scrcpy[10883:119446] ERROR: Server connection failed If it helps, I'm on macOS 12.6, installed via homebrew. |
Oh, your problem is a different one: the device serial starts with a space, so it is ignored by the parser (or at least is reported with a printed space by Which one works: adb -s GS101200400611 shell echo ok
adb -s ' GS101200400611' shell echo ok ? Just to confirm this is not the same issue, test with this executable and post the logs: #3534 (comment) |
@rom1v Ah, good catch, it is the space:
That executable looks to be an exe. Have a Mac compatible executable I could try? |
OK, could you please open a separate issue for serials containing a space please? I'll fix it before the next release. |
I have the same situation: Here are my log:
run the first debug exe
run the second debug exe
My systeminfo
|
Environment
OS: window11
scrcpy version: 1.24
device model: Redmi K30 Pro Zoom Edition
Android version: 12/13
Describe the bug:
Hello, the author. It was normal to use scrcpy before, but it can't be used normally these days. What's the reason?
scrcpy -d prompts an error
The text was updated successfully, but these errors were encountered: