I used the older version (scrcpy-win64-v1.2) and it works, but when I use the most recent version (scrcpy-win64-v1.4), it display error.

I am using Microsoft Windows 10 Pro (Version 10.0.17134 Build 17134), I have disabled some services but the older version work so I think its not services fault.
I used the older version (scrcpy-win64-v1.2) and it works, but when I use the most recent version (scrcpy-win64-v1.4), it display error.
Is it reproducible? I mean, if you switch back to v1.2, it always works, and if you switch to v1.4, it always fail? What about v1.3?
Are there any error messages in the result of adb logcat when this happens?
Is it reproducible? I mean, if you switch back to v1.2, it always works, and if you switch to v1.4, it always fail? What about v1.3?
Its reproducible, v1.3 always works, v1.4 always fail.
Are there any error messages in the result of adb logcat when this happens?
This is the output after it calm down.... (v1.4)
D/AndroidRuntime(18759): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime(18759): CheckJNI is OFF
W/ActivityManager( 2218): getRunningAppProcesses: caller 10480 does not hold REAL_GET_TASKS; limiting output
I/art (18759): cache_oat_file/data/dalvik-cache/arm64/data@local@[email protected]@classes.dex==nullptr
W/AudioSystem(18759): setErrorCallback, gAudioNotifyCallback:0
D/AndroidRuntime(18759): Calling main entry com.genymobile.scrcpy.Server
D/AndroidRuntime(18759): Shutting down VM
Its reproducible, v1.3 always works, v1.4 always fail.
OK, v1.3 used FFmpeg 4.0.0, v1.4 uses FFmpeg 4.0.2.
What if you just copy avcodec-58.dll, avformat-58.dll, avutil-56.dll and swresample-3.dll from your v1.3 directory to your v1.4 directory?
What if you just copy
avcodec-58.dll,avformat-58.dll,avutil-56.dllandswresample-3.dllfrom your v1.3 directory to your v1.4 directory?
Still not working.... Here is the log
D/AndroidRuntime(24087): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime(24087): CheckJNI is OFF
I/art (24087): cache_oat_file/data/dalvik-cache/arm64/data@local@[email protected]@classes.dex==nullptr
W/AudioSystem(24087): setErrorCallback, gAudioNotifyCallback:0
D/AndroidRuntime(24087): Calling main entry com.genymobile.scrcpy.Server
I/ActivityManager( 2218): Process com.bbk.updater (pid 24060) has died
D/ActivityManager( 2218): cleanUpApplicationRecord -- 24060
D/AndroidRuntime(24087): Shutting down VM
I have a suggestion, when you unlock screen, it disconnected, can you not make that happened??
Still not working....
Weird, I don't see any other change between v1.3 and v1.4 which could explain this.
Here is the log
OK, thanks, but it seems there is nothing relevant on the device side. Or maybe earlier in the logs?
It seems that FFmpeg just fails to open the video stream on the client side.
I have a suggestion, when you unlock screen, it disconnected, can you not make that happened??
It should not. See https://github.com/Genymobile/scrcpy/issues/283. Check with another cable, and check the result of adb devices regularly when this happens.
Still not working....
Weird, I don't see any other change between v1.3 and v1.4 which could explain this.
Here is the log
OK, thanks, but it seems there is nothing relevant on the device side. Or maybe earlier in the logs?
It seems that FFmpeg just fails to open the video stream on the client side.
I think I found where is the error located in, I moved the v1.4 exe to v1.3 and it works, but when I copy scrcpy-server.jar to v1.3, it produced the error (When just only copying that to v1.3, it output the same things but without Press any key to continue...) (I replaced everything except scrcpy-server.jar and it still works)
It should not. See #283. Check with another cable, and check the result of adb devices regularly when this happens.
Okey, that just happened randomly once (Not reproducible, disconnected in adb logcat)
I think I found where is the error located in, I moved the v1.4 exe to v1.3 and it works, but when I copy scrcpy-server.jar to v1.3, it produced the error
OK, it works because it happens that server 1.3 is compatible with client 1.4 and vice-versa.
The problem comes from server v1.4 on your device. So the guilty commit is 66def38b734829170654647086bd76f99efdec70.
I'm interested in your fill server logs, then.
Could you clean them before running v1.4 (adb logcat -c), then start scrcpy once, then get the logs (adb logcat -d > logcat.txt), please?
Could you clean them before running v1.4 (
adb logcat -c), then start scrcpy once, then get the logs (adb logcat -d > logcat.txt), please?
Here is it, do adb logcat -c, run scrcpy.exe once, then do adb logcat -d > logcat.txt
logcat.txt
--------- beginning of main
D/DataFormatter( 7131): Special bytes : 0
I/art ( 4794): Explicit concurrent mark sweep GC freed 16(736B) AllocSpace objects, 0(0B) LOS objects, 79% free, 267KB/1291KB, paused 885us total 38.169ms
D/DataFormatter( 7131): Special bytes : 45
D/DataFormatter( 7131): Special bytes : 0
I/art (28113): Explicit concurrent mark sweep GC freed 279(12KB) AllocSpace objects, 0(0B) LOS objects, 47% free, 1130KB/2MB, paused 769us total 44.633ms
D/DataFormatter( 7131): Special bytes : 0
I/art ( 7131): Explicit concurrent mark sweep GC freed 4142(185KB) AllocSpace objects, 0(0B) LOS objects, 48% free, 1098KB/2MB, paused 890us total 43.541ms
D/DataFormatter( 7131): Special bytes : 0
D/DataFormatter( 7131): Special bytes : 0
I/art (15203): Explicit concurrent mark sweep GC freed 683(26KB) AllocSpace objects, 0(0B) LOS objects, 24% free, 6MB/8MB, paused 1.016ms total 109.223ms
D/AndroidRuntime(13892):
D/AndroidRuntime(13892): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime(13892): CheckJNI is OFF
I/art (13892): cache_oat_file/data/dalvik-cache/arm64/data@local@[email protected]@classes.dex==nullptr
W/AudioSystem(13892): setErrorCallback, gAudioNotifyCallback:0
D/AndroidRuntime(13892): Calling main entry com.genymobile.scrcpy.Server
D/DataFormatter( 7131): Special bytes : 0
D/AndroidRuntime(13892): Shutting down VM
D/DataFormatter( 7131): Special bytes : 0
I/art (28092): Explicit concurrent mark sweep GC freed 1962(80KB) AllocSpace objects, 1(68KB) LOS objects, 39% free, 5MB/9MB, paused 1.504ms total 90.408ms
I think my phone is just outdated....

Thank you, but unfortunately your device does not log anything interesting. Which device is it?
So, let's do everything manually, if you manage to do it.
scrcpy-server.jar exactly): adb push scrcpy-server.jar /data/local/tmp/scrcpy-server.jaradb reverse localabstract:scrcpy tcp:27183netcat -l -p 27183 (you'll need a Windows version of netcat if you're on Windows).adb shell "CLASSPATH=/data/local/tmp/scrcpy-server.jar app_process / com.genymobile.scrcpy.Server 0 8000000 false ''"Does it print something interesting? Is the netcat terminal "flooded"?
Tons of vivo Y35 something....

More clearer version

WAT, it looks like a bug introduced by 66def38b734829170654647086bd76f99efdec70.
Cool you apply this patch and try again, to get more information in the other terminal, please?
diff --git a/server/src/main/java/com/genymobile/scrcpy/IO.java b/server/src/main/java/com/genymobile/scrcpy/IO.java
index bfd48be..289ab23 100644
--- a/server/src/main/java/com/genymobile/scrcpy/IO.java
+++ b/server/src/main/java/com/genymobile/scrcpy/IO.java
@@ -16,8 +16,10 @@ public class IO {
public static void writeFully(FileDescriptor fd, ByteBuffer from) throws IOException {
while (from.hasRemaining()) {
try {
+ Ln.d("from.remaining() == " + from.remaining());
Os.write(fd, from);
} catch (ErrnoException e) {
+ Ln.e(e.getMessage(), e);
if (e.errno != OsConstants.EINTR) {
throw new IOException(e);
}
Umm....How to apply this patch??
scrcpy-server.jar
_SHA256: dae04ce36d73ceb8c1115ef86184d0f523b07e7449b5f92d24372bc14564bef1_
Here is it, the netcat one stopped (It outputing sometimes), but the adb one still going

Thank you. One more, then, please:
scrcpy-server-test2.jar
_SHA256: f39a4e2553dd9bc33290310846b2e786e1b3ca8fee8bb0a1f457659350c832fc_

DEBUG: from.remaining() == 68
DEBUG: written = 68
DEBUG: from.remaining() == 68
DEBUG: written = 68
DEBUG: from.remaining() == 68
DEBUG: written = 68
DEBUG: from.remaining() == 68
DEBUG: written = 68
Wow, that's unexpected.
One more, please :)
scrcpy-server-test3.jar
_SHA256: 5e7c77ef8f775b263a7e16bbe971c969c52ef14af50a640ea95fff71a01bbc6c_

I am sleeping....
DEBUG: from.remaining() == 68
DEBUG: written = 68
DEBUG: after write: from.remaining() == 68
This is not expected. After a write, the remaining should be 0.
This seems a bug in the implementation of Os.write() on your device.
On Oreo, it is implemented correctly: https://android.googlesource.com/platform/libcore/+/oreo-release/luni/src/main/java/libcore/io/Linux.java#281
However, on Jelly Bean, it is not (the byte buffer position is not updated):
https://android.googlesource.com/platform/libcore/+/jb-release/luni/src/main/java/libcore/io/Posix.java#173
https://android.googlesource.com/platform/libcore/+/jb-release/luni/src/main/native/libcore_io_Posix.cpp#1222
Since _scrcpy_ is supposed to support Android >= 5, this is a bug.
Thank you for your help. I'll fix it soon (I will just not rely on the byte buffer remaining).
Could you confirm that this fixes the issue, please?
scrcpy-server-test4.jar
_SHA256: 044fb2140773492a0262daf22edb7bd1649b5b2516b57fd5dfc6932b2407a541_
Thank you.

Does it work with scrcpy directly?
Does it work with scrcpy directly?
Yes!!

Most helpful comment
Yes!!