fix(video): vsync remote canvas draws
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -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
|
||||
|
||||
@@ -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<void>(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;
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user