Harnesses run offscreen on a Linux without vscreen

Without vscreen, save_roundtrip, world_reopen and spawn_loot stopped on
FileNotFoundError, and lan_e2e's games opened windows on the real
desktop: unfocused, the host paused before its world loaded and waited
at "Connecting to the server..." until wait-ready gave up. They now run
offscreen there, as on macOS, and lan_e2e's games also skip the pause
(as HORIZON_E2E_HEADLESS does).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
asowneryt
2026-10-28 09:47:06 +13:00
parent f21e09510e
commit c309d331ad
3 changed files with 12 additions and 8 deletions
+7 -5
View File
@@ -274,8 +274,8 @@ both sides go to --out (host-*.png, guest-*.png).
python3 tools/lan_e2e.py --check chest --check tab
python3 tools/lan_e2e.py --server-thread --check portals # the host's world on its server thread
Needs the prepared resources in .local/horizon-client and, on Linux, vscreen (the desktop); on
macOS both games render offscreen. Games started here have no audio (HORIZON_NO_AUDIO=1).
Needs the prepared resources in .local/horizon-client. On Linux the games run on vscreen (the
desktop), or headless (offscreen, no pause) where there is none; on macOS both games render offscreen. Games started here have no audio (HORIZON_NO_AUDIO=1).
"""
import argparse
import json
@@ -4989,9 +4989,11 @@ def run(ctl, out, resources, checks):
host, guest = Game('host', ctl, resources), Game('guest', ctl, resources)
# Either way explicitly: the game's default is the server thread.
host.d.env['HORIZON_SERVER_THREAD'] = '1' if SERVER_THREAD else '0'
# A headless run (HORIZON_E2E_HEADLESS) has no focused window to draw in: the games render
# offscreen and never pause on the focus loss, or the world would stand still.
headless = bool(os.environ.get('HORIZON_E2E_HEADLESS'))
# A headless run (HORIZON_E2E_HEADLESS, or a Linux without vscreen) has no focused window to draw
# in: the games render offscreen and never pause on the focus loss, or the world would stand still
# (a host paused before its world loads waits at "Connecting to the server..." for ever).
headless = bool(os.environ.get('HORIZON_E2E_HEADLESS')) or (
sys.platform.startswith('linux') and not shutil.which('vscreen'))
launch = ['launch']
if headless or sys.platform == 'darwin':
launch.append('--offscreen')
+2 -1
View File
@@ -347,7 +347,8 @@ def horizon_resave(source, destination, bin_dir):
socket = Path(tempfile.mkdtemp(prefix='hzrt')) / 'control.sock' # sockets need short paths
ctl = [str(bin_dir / 'horizon-ctl'), '--socket', str(socket)]
extra = []
if sys.platform == 'darwin':
# Offscreen on macOS, and on a Linux without vscreen (never a window on a real monitor).
if sys.platform == 'darwin' or not shutil.which('vscreen'):
env = lab.game_env()
extra = ['--offscreen']
else:
+3 -2
View File
@@ -34,9 +34,10 @@ CYCLES = 3
def game_env():
"""macOS renders offscreen; Linux uses the virtual screen (as test_save_roundtrip_parity)."""
"""macOS renders offscreen; Linux uses the virtual screen (as test_save_roundtrip_parity), or renders
offscreen too where there is no vscreen."""
env = lab.game_env()
if sys.platform == 'darwin':
if sys.platform == 'darwin' or not shutil.which('vscreen'):
return env, ['--offscreen']
subprocess.run(['vscreen', 'up'], check=False, capture_output=True)
text = subprocess.run(['vscreen', 'env'], capture_output=True, text=True, check=True).stdout