From 12e269b9f091aea99035fa1fc12732e6f76bb4a3 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 c9a37f847b..c75cfb88da 100644 --- a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java +++ b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java @@ -62,8 +62,9 @@ public void streamScreen(Device device, FileDescriptor fd) throws IOException { 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();