From 7e936fa879d9ee37608d9d0ce36f66ea06a6317d Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Thu, 13 Jul 2023 21:43:52 +0200 Subject: [PATCH] Fix meizu deadlock Some devices (Meizu) assume that the video encoding thread has a Looper. By moving video encoding to a separate thread, commit feab87053abcceded41342d9d856763dedc09187 broke this assumption. Call Looper.prepare() from this thread to fix the problem. Fixes #4143 --- .../src/main/java/com/genymobile/scrcpy/ScreenEncoder.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java index db15d5f3..5a9db10d 100644 --- a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java +++ b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java @@ -8,6 +8,7 @@ import android.media.MediaCodecInfo; import android.media.MediaFormat; import android.os.Build; import android.os.IBinder; +import android.os.Looper; import android.os.SystemClock; import android.view.Surface; @@ -285,6 +286,10 @@ public class ScreenEncoder implements Device.RotationListener, Device.FoldListen @Override public void start(TerminationListener listener) { thread = new Thread(() -> { + // Some devices (Meizu) deadlock if the video encoding thread has no Looper + // + Looper.prepare(); + try { streamScreen(); } catch (ConfigurationException e) {