Compare commits

..

3 Commits

Author SHA1 Message Date
8c9f66ac06 fix(driver): disable NVIDIA page flipping before launching BA
With page flipping on, BA's fullscreen window never puts a new frame on
screen on nik-gpu and sits frozen on "Initialize Catalog..." until
login.py's timeout kills it. It only worked during a Moonlight session,
because Sunshine's NvFBC capture makes the driver copy frames instead.

The setting resets on reboot or X restart, so launch_game() applies
AllowFlipping=0 before every launch. A failure is reported but not
raised, since login.py already fails the run loudly if the game never
gets past loading. setup.sh now checks for nvidia-settings, and
CLAUDE.md lists it as a runtime dependency.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 21:17:26 +09:00
4a5045f126 Merge branch 'fix/login-fail-loudly'
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 21:14:41 +09:00
9cfc41b384 fix(config): give cron-started Steam the desktop session env
Steam has no autostart on nik-gpu, so after a reboot the first cron run
starts it, and every game Steam launches inherits that environment.
cron sets neither XDG_RUNTIME_DIR nor DBUS_SESSION_BUS_ADDRESS, so the
Pulse socket never got mounted into the Proton container. Persona 3
Reload then fell back to ALSA and crashed on launch in xaudio2_9.

Set both in config.ENV, which launch_game() passes down to Steam.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 21:11:43 +09:00
4 changed files with 40 additions and 3 deletions

View File

@ -291,6 +291,7 @@ Required now:
- `scrot`
- `python3`
- `curl` (confirmed present at `/usr/bin/curl`) -- only used by `ba_cron_run.sh`'s optional Discord alerting, not by any Python task/driver code
- `nvidia-settings` (confirmed present at `/usr/bin/nvidia-settings`) -- `driver.launch_game()` runs `nvidia-settings -a AllowFlipping=0` before every launch. Without it, BA froze on "Initialize Catalog..." on every unattended launch from 2026-10-26 to 10-29, and only worked while a Moonlight session was connected (Sunshine's NvFBC capture stops the driver from flipping). The setting resets on reboot, which is why it's re-applied each launch. See `driver.disable_page_flipping()`.
Required Python packages:

View File

@ -3,7 +3,21 @@ import os
DISPLAY = ":0"
XAUTHORITY = "/run/user/1000/gdm/Xauthority"
ENV = {**os.environ, "DISPLAY": DISPLAY, "XAUTHORITY": XAUTHORITY}
# Steam has no autostart here, so after a reboot it's the first cron run that
# starts it, and every game Steam launches inherits that environment. cron
# sets neither of these. Real incident (2026-11-06): without XDG_RUNTIME_DIR,
# the Pulse socket never got mounted into the Proton container, so Persona 3
# Reload fell back to ALSA and crashed on launch in xaudio2_9 until Steam was
# restarted from the desktop.
XDG_RUNTIME_DIR = "/run/user/1000"
DBUS_SESSION_BUS_ADDRESS = f"unix:path={XDG_RUNTIME_DIR}/bus"
ENV = {
**os.environ,
"DISPLAY": DISPLAY,
"XAUTHORITY": XAUTHORITY,
"XDG_RUNTIME_DIR": XDG_RUNTIME_DIR,
"DBUS_SESSION_BUS_ADDRESS": DBUS_SESSION_BUS_ADDRESS,
}
WINDOW_NAME = "BlueArchive"

View File

@ -170,12 +170,34 @@ def kill_game(force=False):
run_command(["pkill", *signal_args, "-f", config.GAME_PROCESS_NAME], check=False)
def disable_page_flipping():
# Real incident (2026-10-26 to 10-29): with the NVIDIA driver's page
# flipping on, BA's fullscreen window on nik-gpu never puts a new frame
# on screen -- it sits frozen on "Initialize Catalog..." until login.py's
# timeout kills it -- unless a Moonlight session is connected, because
# Sunshine's NvFBC capture makes the driver copy frames instead of flip.
# Confirmed by A/B: frozen on every launch with AllowFlipping=1, title
# screen with no input and home in 47s via login with AllowFlipping=0.
# It's a runtime X setting that a reboot or X restart resets to 1, so
# it's re-applied before every launch instead of set once by hand.
# A failure is reported, not raised: the launch can still work (e.g.
# during a Moonlight session), and login.py fails the run loudly if not.
result = run_command(
["nvidia-settings", "-a", "AllowFlipping=0"],
check=False, capture_output=True, text=True,
)
if result.returncode != 0:
print(f"[driver] warning: couldn't disable NVIDIA page flipping (exit {result.returncode}) -- "
f"BA may freeze on its loading screen: {result.stderr.strip()}")
def launch_game():
# The launch script (see config.GAME_LAUNCH_SCRIPT) blocks until the
# game process exits, by design (it's meant to be run as a foreground
# session launcher) -- Popen + start_new_session=True detaches it so
# this process can keep polling for the window instead of hanging for
# the whole play session.
disable_page_flipping()
subprocess.Popen(
[config.GAME_LAUNCH_SCRIPT],
env=config.ENV,

View File

@ -17,7 +17,7 @@ VENV_DIR="$HOME/.venvs/ba-auto-daily"
echo "== Checking host tools =="
missing=0
for cmd in xdotool scrot; do
for cmd in xdotool scrot nvidia-settings; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "MISSING: $cmd (install with your package manager, e.g. sudo apt install $cmd)"
missing=1
@ -27,7 +27,7 @@ if [ "$missing" = 1 ]; then
echo "Install the missing tool(s) above, then re-run this script."
exit 1
fi
echo "xdotool, scrot: OK"
echo "xdotool, scrot, nvidia-settings: OK"
if ! command -v tesseract >/dev/null 2>&1; then
echo "MISSING: tesseract (OCR engine binary -- e.g. sudo apt install tesseract-ocr)"