#!/usr/bin/env bash # Drive into the black-screen hang and ask what the guest is still doing. # # Three questions, three cheap probes, all taken WHILE the screen is black: # * is it still presenting frames? -> F10 arms the UI draw capture, whose # header records the frame numbers it covered and how many draws it saw # * is it still doing file I/O? -> count ResolvePath lines before/after # * is it still running at all? -> the emulator's own MEM-WATCH/thread log set -u export HOME=/sylph-home/re SDL_AUDIODRIVER=dummy DISPLAY=:98 SD="$(cd "$(dirname "$0")" && pwd)" OUT="${1:-/sylph-home/re/blackprobe}" mkdir -p "$OUT"; rm -f "$OUT"/xenia_re_ui_draws_*.log shot(){ screenshot "$1" >/dev/null 2>&1; } screen(){ shot /tmp/bp.png; python3 "$SD/screen_id.py" /tmp/bp.png | awk '{print $1}'; } alive(){ ps -o pid=,stat= -C xenia_canary 2>/dev/null | awk '$2 !~ /^Z/ {print $1}'; } resolves(){ grep -c "ResolvePath" "$OUT/canary.stdout" 2>/dev/null || echo 0; } for attempt in $(seq 1 "${ATTEMPTS:-3}"); do echo "=== attempt $attempt" pkill -9 -x xenia_canary 2>/dev/null; sleep 3 ( cd "$OUT" && nohup run-canary --mem_watch=false \ --ui_draw_capture_frames=8 --ui_draw_capture_max=4000 \ --logged_profile_slot_0_xuid=B13EBABEBABEBABE >"$OUT/canary.stdout" 2>&1 & ) sleep 8 until xdotool search --name "Xenia-canary" >/dev/null 2>&1; do [ -n "$(alive)" ] || { echo "EMULATOR GONE"; exit 4; }; sleep 1 done win="$(xdotool search --name "Xenia-canary" | tail -1)" s=""; deadline=$(( SECONDS + 420 )) while [ $SECONDS -lt $deadline ]; do s="$(screen)"; [ "$s" = "title" ] && break; sleep 2; done [ "$s" = "title" ] || { echo "NO TITLE"; continue; } python3 "$SD/pad.py" tap A 0.3 for _ in 1 2 3 4 5 6 7 8; do sleep 3; s="$(screen)"; [ "$s" = "menu" ] && break; done [ "$s" = "menu" ] || { echo "(A) refused; rebooting"; continue; } echo "menu -> A (NEW GAME) -> A (difficulty)" python3 "$SD/pad.py" tap A 0.3; sleep 10 python3 "$SD/pad.py" tap A 0.3 # wait for black for i in $(seq 1 20); do sleep 6; s="$(screen)" mean=$(identify -format "%[fx:mean]" /tmp/bp.png 2>/dev/null) echo " t+$((i*6))s $s mean=$mean" case "$mean" in 0|0.0*) break ;; esac done shot "$OUT/black.png" echo "--- probing the black screen" r1=$(resolves); sleep 20; r2=$(resolves) echo "ResolvePath lines: $r1 -> $r2 (delta $((r2-r1)))" xdotool windowactivate --sync "$win"; sleep 1 xdotool key F10; sleep 4; xdotool mousemove 900 400 click 1; sleep 3 grep -i "UI-CAP" "$OUT/canary.stdout" | tail -3 head -2 "$OUT"/xenia_re_ui_draws_*.log 2>/dev/null echo "log lines now: $(wc -l < "$OUT/canary.stdout")" sleep 20 echo "log lines +20s: $(wc -l < "$OUT/canary.stdout")" echo "BLACK PROBE DONE" exit 0 done echo "GAVE UP"