Skip to content

Commit 4769803

Browse files
committed
Reconnect Android stream on display resize
1 parent d3151ae commit 4769803

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

client/src/features/stream/useLiveStream.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,21 @@ export function useLiveStream({
299299
return;
300300
}
301301

302+
const display = simulator.privateDisplay;
303+
const displayKey =
304+
simulator.platform === "android-emulator" && display
305+
? [
306+
Math.round(display.displayWidth),
307+
Math.round(display.displayHeight),
308+
display.rotationQuarterTurns ?? 0,
309+
].join("x")
310+
: "";
302311
const targetKey = [
303312
simulator.udid,
304313
simulator.platform ?? "",
305314
remote ? "remote" : "local",
306315
streamTransport,
316+
displayKey,
307317
].join("|");
308318
if (connectedStreamTargetKeyRef.current === targetKey) {
309319
return;
@@ -327,6 +337,9 @@ export function useLiveStream({
327337
canvasElement,
328338
simulator?.isBooted,
329339
simulator?.platform,
340+
simulator?.privateDisplay?.displayHeight,
341+
simulator?.privateDisplay?.displayWidth,
342+
simulator?.privateDisplay?.rotationQuarterTurns,
330343
simulator?.udid,
331344
paused,
332345
remote,

server/src/android.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const ANDROID_GRPC_FRAME_MESSAGE_LIMIT: usize = 64 * 1024 * 1024;
2020
const ANDROID_TOUCH_IDENTIFIER: i32 = 1;
2121
const RUNNING_EMULATOR_CACHE_TTL: Duration = Duration::from_secs(2);
2222
const AVD_GRPC_PORT_CACHE_TTL: Duration = Duration::from_secs(60);
23-
const SCREEN_SIZE_CACHE_TTL: Duration = Duration::from_secs(60);
23+
const SCREEN_SIZE_CACHE_TTL: Duration = Duration::from_secs(1);
2424
const MODIFIER_SHIFT: u32 = 1 << 0;
2525
const MODIFIER_CONTROL: u32 = 1 << 1;
2626
const MODIFIER_OPTION: u32 = 1 << 2;

0 commit comments

Comments
 (0)