diff --git a/.gitignore b/.gitignore index de89a55..8dffd55 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,11 @@ npm-debug.log* yarn-debug.log* yarn-error.log* dev-debug.log + +# Debug frame dump artifacts +android-frame-dumps/ +wzp-frame-dumps.tar + # Dependency directories node_modules/ # Environment variables diff --git a/desktop/src/main.ts b/desktop/src/main.ts index 7d0cea0..8889c4e 100644 --- a/desktop/src/main.ts +++ b/desktop/src/main.ts @@ -739,6 +739,10 @@ let remoteFrameSerial = 0; let remoteDrawInFlight = false; let remotePendingFrame: { serial: number; width: number; height: number; jpeg_b64: string } | null = null; +function nextAnimationFrame() { + return new Promise(resolve => requestAnimationFrame(() => resolve())); +} + async function drawRemoteFrame(frame: { serial: number; width: number; height: number; jpeg_b64: string }) { const img = new Image(); img.src = `data:image/jpeg;base64,${frame.jpeg_b64}`; @@ -751,6 +755,8 @@ async function drawRemoteFrame(frame: { serial: number; width: number; height: n }); } + if (frame.serial !== remoteFrameSerial) return; + await nextAnimationFrame(); if (frame.serial !== remoteFrameSerial) return; if (vdRemoteVideo.width !== frame.width) vdRemoteVideo.width = frame.width; if (vdRemoteVideo.height !== frame.height) vdRemoteVideo.height = frame.height; diff --git a/scripts/pull-android-frame-dumps.sh b/scripts/pull-android-frame-dumps.sh index 18ba595..4697795 100755 --- a/scripts/pull-android-frame-dumps.sh +++ b/scripts/pull-android-frame-dumps.sh @@ -3,9 +3,9 @@ set -euo pipefail PACKAGE="${1:-com.wzp.desktop}" OUT_DIR="${2:-android-frame-dumps}" -REMOTE_TAR="/sdcard/wzp-frame-dumps.tar" LOCAL_TAR="wzp-frame-dumps.tar" -APP_DUMP_DIR="files/com.wzp.desktop/.wzp" +APP_DUMP_DIR="${WZP_ANDROID_DUMP_ROOT:-.wzp}" +trap 'rm -f "$LOCAL_TAR"' EXIT if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then echo "Usage: $0 [package] [out-dir]" @@ -15,11 +15,7 @@ if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then fi echo ">>> Packaging frame dumps from $PACKAGE..." -adb shell "run-as $PACKAGE tar -C $APP_DUMP_DIR -cf $REMOTE_TAR frame-dumps" - -echo ">>> Pulling $REMOTE_TAR..." -adb pull "$REMOTE_TAR" "$LOCAL_TAR" -adb shell "rm -f $REMOTE_TAR" >/dev/null 2>&1 || true +adb exec-out "run-as $PACKAGE tar -C $APP_DUMP_DIR -cf - frame-dumps" > "$LOCAL_TAR" rm -rf "$OUT_DIR" mkdir -p "$OUT_DIR"