From ef56cc6ff74862e85c0af4746fa26ef391f6f3a9 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Mon, 24 Feb 2020 21:08:32 +0100 Subject: [PATCH] Retrieve screen info once The method getScreenInfo() is synchronized, and the result may change between calls. Call it once and store the result in a local variable. --- .../src/main/java/com/genymobile/scrcpy/ScreenEncoder.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java index 1c71eabd..7edfacaf 100644 --- a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java +++ b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java @@ -63,8 +63,9 @@ public class ScreenEncoder implements Device.RotationListener { do { MediaCodec codec = createCodec(); IBinder display = createDisplay(); - Rect contentRect = device.getScreenInfo().getContentRect(); - Rect videoRect = device.getScreenInfo().getVideoSize().toRect(); + ScreenInfo screenInfo = device.getScreenInfo(); + Rect contentRect = screenInfo.getContentRect(); + Rect videoRect = screenInfo.getVideoSize().toRect(); setSize(format, videoRect.width(), videoRect.height()); configure(codec, format); Surface surface = codec.createInputSurface();