diff --git a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java index 22eb6a54..71f5ab10 100644 --- a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java +++ b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java @@ -71,8 +71,9 @@ public class ScreenEncoder implements Device.RotationListener { codec.start(); try { alive = encode(codec, fd); - } finally { + // do not call stop() on exception, it would trigger an IllegalStateException codec.stop(); + } finally { destroyDisplay(display); codec.release(); surface.release();