From d04a3394dee71e26de89f7cc55a4873fc523a2df Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Wed, 26 Aug 2026 04:06:43 -0400 Subject: [PATCH] [Feat] (DeviceBench): launch retry loop (signal-34 JVM flake), session.sh runner, MSYS path-conversion guards --- tools/device_bench/bench.sh | 36 +++++++++------ tools/device_bench/profile.sh | 2 + tools/device_bench/session.sh | 87 +++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 14 deletions(-) create mode 100755 tools/device_bench/session.sh diff --git a/tools/device_bench/bench.sh b/tools/device_bench/bench.sh index 0c9e75aa..886b6a33 100755 --- a/tools/device_bench/bench.sh +++ b/tools/device_bench/bench.sh @@ -133,23 +133,31 @@ log "renderer now: $($ADB shell run-as $PKG grep renderer files/config.json | tr # --- 4. Pin frequencies ------------------------------------------------------- [ "$DO_PIN" = 1 ] && pin_freqs -# --- 5. Launch, wait for world ------------------------------------------------ -$ADB shell am force-stop $PKG +# --- 5. Launch, wait for world (retry: the JVM occasionally dies with +# "exited due to signal 34" right after JLI_Launch on this device) ------------- MCLOG="/storage/emulated/0/FCL/.minecraft/versions/*/logs/latest.log" -$ADB shell "rm -f $MCLOG /sdcard/MG/latest.log" 2>/dev/null -$ADB logcat -c 2>/dev/null -log "launching $ACTIVITY" -$ADB shell am start -n $ACTIVITY >/dev/null WORLD_UP=0 -for i in $(seq 1 $((WORLD_LOAD_TIMEOUT / 5))); do +for attempt in 1 2 3; do + $ADB shell am force-stop $PKG sleep 5 - if ! $ADB shell pidof $PKG >/dev/null; then - # process may legitimately restart once (launcher -> game process) - : - fi - if $ADB shell "grep -l -e 'logged in with entity id' -e 'Preparing spawn area: 100' $MCLOG" >/dev/null 2>&1; then - WORLD_UP=1; break - fi + $ADB shell "rm -f $MCLOG /sdcard/MG/latest.log" 2>/dev/null + $ADB logcat -c 2>/dev/null + log "launching $ACTIVITY (attempt $attempt)" + $ADB shell am start -n $ACTIVITY >/dev/null + for i in $(seq 1 $((WORLD_LOAD_TIMEOUT / 5))); do + sleep 5 + if $ADB shell "grep -l -e 'logged in with entity id' -e 'Preparing spawn area: 100' $MCLOG" >/dev/null 2>&1; then + WORLD_UP=1; break + fi + if ! $ADB shell pidof $PKG >/dev/null; then + sleep 3 + if ! $ADB shell pidof $PKG >/dev/null; then + log "attempt $attempt: game process died; retrying" + break + fi + fi + done + [ "$WORLD_UP" = 1 ] && break done if [ "$WORLD_UP" != 1 ]; then log "world did not load within ${WORLD_LOAD_TIMEOUT}s" diff --git a/tools/device_bench/profile.sh b/tools/device_bench/profile.sh index c457f2a9..dff7a8f3 100755 --- a/tools/device_bench/profile.sh +++ b/tools/device_bench/profile.sh @@ -19,6 +19,8 @@ set -u -o pipefail cd "$(dirname "$0")" +# Git Bash: stop MSYS from rewriting /data/... arguments into C:/Program Files/... +export MSYS_NO_PATHCONV=1 MSYS2_ARG_CONV_EXCL='*' PKG=com.tungsten.fcl.mgdebug.debug DEVICE_ENV="" diff --git a/tools/device_bench/session.sh b/tools/device_bench/session.sh new file mode 100755 index 00000000..4920b240 --- /dev/null +++ b/tools/device_bench/session.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +# Launch the game into the benchmark world and leave it running (for profiling +# or ad-hoc probing). Handles the flaky-launch failure mode seen on Odin Lite: +# the JVM occasionally dies with "exited due to signal 34" right after +# JLI_Launch (~40% of launches, cause unknown) — so launching retries up to +# --retries times before giving up. +# +# Usage: session.sh --device devices/odinlite.env [--backend magma|espryt|mobileglues] +# [--settle 150] [--retries 3] [--no-pin] +# Exits 0 with the game in-world (after settle seconds), 1 otherwise. + +set -u -o pipefail +cd "$(dirname "$0")" +export MSYS_NO_PATHCONV=1 MSYS2_ARG_CONV_EXCL='*' + +PKG=com.tungsten.fcl.mgdebug.debug +ACTIVITY=$PKG/com.tungsten.fcl.activity.SplashActivity +RENDERER_ESPRYT=5e273ee2-baca-4c81-8e48-b63feefb9ba8 +RENDERER_MAGMA=2be0dc10-1eef-4ce2-b512-b266dd33fd9e +RENDERER_MOBILEGLUES=com.fcl.plugin.mobileglues + +DEVICE_ENV="" BACKEND="" SETTLE=150 RETRIES=3 DO_PIN=1 +while [ $# -gt 0 ]; do + case "$1" in + --device) DEVICE_ENV=$2; shift 2 ;; + --backend) BACKEND=$2; shift 2 ;; + --settle) SETTLE=$2; shift 2 ;; + --retries) RETRIES=$2; shift 2 ;; + --no-pin) DO_PIN=0; shift ;; + *) echo "unknown arg: $1" >&2; exit 2 ;; + esac +done +[ -n "$DEVICE_ENV" ] || { echo "need --device" >&2; exit 2; } +# shellcheck disable=SC1090 +. "$DEVICE_ENV" +ADB="adb -s $DEVICE_SERIAL" +log() { echo "[session] $*" >&2; } + +if [ -n "$BACKEND" ]; then + case "$BACKEND" in + espryt) RENDERER=$RENDERER_ESPRYT ;; + magma) RENDERER=$RENDERER_MAGMA ;; + mobileglues) RENDERER=$RENDERER_MOBILEGLUES ;; + *) echo "unknown backend: $BACKEND" >&2; exit 2 ;; + esac + for known in $RENDERER_ESPRYT $RENDERER_MAGMA $RENDERER_MOBILEGLUES; do + [ "$known" = "$RENDERER" ] && continue + $ADB shell run-as $PKG sed -i "s/$known/$RENDERER/g" files/config.json + done +fi + +$ADB shell "input keyevent KEYCODE_WAKEUP; sleep 1; input keyevent 82; svc power stayon true; settings put global fan_mode 3" +if [ "$DO_PIN" = 1 ]; then + $ADB shell "su -c 'echo 1 $CPU_BIG_FREQ > /proc/ppm/policy/hard_userlimit_max_cpu_freq; + echo 1 $CPU_BIG_FREQ > /proc/ppm/policy/hard_userlimit_min_cpu_freq; + echo 0 $CPU_LITTLE_FREQ > /proc/ppm/policy/hard_userlimit_max_cpu_freq; + echo 0 $CPU_LITTLE_FREQ > /proc/ppm/policy/hard_userlimit_min_cpu_freq; + echo $GPU_PIN_KHZ > /proc/gpufreq/gpufreq_opp_freq'" +fi + +MCLOG=/storage/emulated/0/FCL/.minecraft/versions/1.21.4/logs/latest.log +for attempt in $(seq 1 "$RETRIES"); do + $ADB shell am force-stop $PKG + sleep 5 + $ADB shell "rm -f $MCLOG" + $ADB shell am start -n $ACTIVITY >/dev/null + log "attempt $attempt: launched" + DEADLINE=$((SECONDS + 300)) + while [ $SECONDS -lt $DEADLINE ]; do + sleep 5 + if $ADB shell "grep -q 'joined the game' $MCLOG" 2>/dev/null; then + log "world up (attempt $attempt); settling ${SETTLE}s" + sleep "$SETTLE" + exit 0 + fi + if ! $ADB shell pidof $PKG >/dev/null; then + # process may still be between splash and JVM start briefly; confirm twice + sleep 3 + if ! $ADB shell pidof $PKG >/dev/null; then + log "attempt $attempt: process died (signal-34 flake?); retrying" + break + fi + fi + done +done +log "no world after $RETRIES attempts" +exit 1