Skip to content

Display and control your Android device

Log non-EPIPE I/O exceptions

Romain Vimontf4e7085c349f
diff --git a/server/src/main/java/com/genymobile/scrcpy/IO.java b/server/src/main/java/com/genymobile/scrcpy/IO.java
index 6eaf0d6a..4a55c152 100644
--- a/server/src/main/java/com/genymobile/scrcpy/IO.java
+++ b/server/src/main/java/com/genymobile/scrcpy/IO.java
@@ -48,4 +48,9 @@ public final class IO {
}
return builder.toString();
}
+
+ public static boolean isBrokenPipe(IOException e) {
+ Throwable cause = e.getCause();
+ return cause instanceof ErrnoException && ((ErrnoException) cause).errno == OsConstants.EPIPE;
+ }
}
diff --git a/server/src/main/java/com/genymobile/scrcpy/Server.java b/server/src/main/java/com/genymobile/scrcpy/Server.java
index d7a99576..0aff79bc 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Server.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Server.java
@@ -110,7 +110,10 @@ public final class Server {
}
screenEncoder.streamScreen(device, videoStreamer);
} catch (IOException e) {
- // this is expected on close
+ // Broken pipe is expected on close, because the socket is closed by the client
+ if (!IO.isBrokenPipe(e)) {
+ Ln.e("Video encoding error", e);
+ }
} finally {
Ln.d("Screen streaming stopped");
initThread.interrupt();