check_video_start.sh 1.7 KB

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env bash
  2. # Regression check for the video wallpaper start: reading the video size from mpv synchronously stalled the render thread
  3. # ~200 ms while it set up the decoder, so the first frame sat there before playback began. Renders a video wallpaper
  4. # headlessly on the GPU (headless_render.sh) and requires the worst gap between frames in the first LWE_FRAME_STATS window
  5. # to stay under MAX_GAP_MS (251 ms before the fix, 51 ms after).
  6. # Usage: tools/check_video_start.sh <engine binary> [assets dir] [workshop content dir]
  7. # Exit code 0 when the gap is small. Set VIDEO_ID to use another video wallpaper.
  8. set -euo pipefail
  9. HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  10. BINARY=${1:?engine binary}
  11. ASSETS=${2:-/workspace/SteamLibrary/steamapps/common/wallpaper_engine/assets}
  12. CONTENT=${3:-/workspace/SteamLibrary/steamapps/workshop/content/431960}
  13. VIDEO_ID=${VIDEO_ID:-1367456719}
  14. MAX_GAP_MS=${MAX_GAP_MS:-120}
  15. [ -d "$CONTENT/$VIDEO_ID" ] || { echo "SKIP: wallpaper $VIDEO_ID not in $CONTENT"; exit 0; }
  16. work=$(mktemp -d /tmp/lwe-video-start.XXXXXX)
  17. trap 'rm -rf "$work"' EXIT
  18. LWE_FRAME_STATS=1 HEADLESS_RENDER_DELAY=150 "$HERE/headless_render.sh" "$BINARY" "$work/shot.png" \
  19. --assets-dir "$ASSETS" --fps 60 --silent "$CONTENT/$VIDEO_ID" > "$work/run.log" 2>&1 || { cat "$work/run.log"; exit 1; }
  20. gap=$(grep -m1 '^FRAME-STATS' "$work/run.log" | sed -n 's/.*worst gap \([0-9.]*\)ms.*/\1/p')
  21. [ -n "$gap" ] || { echo "FAIL: no FRAME-STATS line"; cat "$work/run.log"; exit 1; }
  22. if awk -v g="$gap" -v m="$MAX_GAP_MS" 'BEGIN { exit !(g > m) }'; then
  23. echo "FAIL: the render thread stalled for ${gap}ms while the video started (limit ${MAX_GAP_MS}ms)"
  24. exit 1
  25. fi
  26. echo "PASS: worst frame gap while the video started ${gap}ms (limit ${MAX_GAP_MS}ms)"