mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix: game debug logs also reach games started by a store client (#2343)
fix: propagate store launcher debug environment
This commit is contained in:
1 parent
a9524ea991
commit
448d296a2b
7 files changed
+138
-54
No files matched your search
@@ -5,6 +5,7 @@ import json
|
||||
import math
|
||||
import os
|
||||
import re
|
||||
import runpy
|
||||
import shutil
|
||||
import signal
|
||||
import subprocess
|
||||
@@ -16,6 +17,7 @@ import urllib.request
|
||||
HOME = os.environ.get("HOME") or "/root"
|
||||
BIN = "/usr/local/bin"
|
||||
PROTON_RUN = os.path.join(BIN, "droiddeck-proton-run")
|
||||
GAME_DEBUG = runpy.run_path(os.path.join(os.path.dirname(os.path.abspath(__file__)), "droiddeck-game-debug"))
|
||||
APP_ID = "2596113170"
|
||||
INSTALLER_URL = "https://downloader.battle.net/download/getInstallerForGame?os=win&gameProgram=BATTLENET_APP&version=Live"
|
||||
CLIENT_DIR = ("Program Files (x86)", "Battle.net")
|
||||
@@ -685,6 +687,7 @@ def steam_running(proc="/proc"):
|
||||
|
||||
def proton_env():
|
||||
env = dict(os.environ)
|
||||
env = GAME_DEBUG["apply_game_debug_logs"](env)
|
||||
if not steam_running():
|
||||
env.setdefault("PROTON_SPOOF_STEAMINPUT_VIDPID", "1")
|
||||
return env
|
||||
|
||||
@@ -24,6 +24,7 @@ import urllib.request
|
||||
HOME = os.environ.get("HOME") or "/root"
|
||||
SELF = os.path.abspath(__file__)
|
||||
BIN_DIR = os.path.dirname(SELF)
|
||||
GAME_DEBUG = runpy.run_path(os.path.join(BIN_DIR, "droiddeck-game-debug"))
|
||||
STATE = os.path.join(HOME, ".local", "share", "droiddeck-epic")
|
||||
CURRENT = os.path.join(STATE, "current.json")
|
||||
APPS = os.path.join(STATE, "app")
|
||||
@@ -1196,6 +1197,7 @@ def run_game(request, session_env, running=None):
|
||||
exe = native_path(request.get("exe") or "")
|
||||
args = request.get("args") or []
|
||||
env = {k: v for k, v in session_env.items() if not k.startswith(("FEX_", "DROIDDECK_EPIC", "EGL_", "WEBKIT_"))}
|
||||
env = GAME_DEBUG["apply_game_debug_logs"](env)
|
||||
preload = env.pop(STEAM_PRELOAD, "")
|
||||
if preload:
|
||||
env["LD_PRELOAD"] = preload
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/python3
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
GAME_DEBUG_CHANNELS = (
|
||||
"timestamp", "pid", "tid", "seh", "unwind", "threadname", "debugstr", "loaddll", "mscoree",
|
||||
)
|
||||
WINE_DEBUG_SELECTOR = re.compile(r"(?:(trace|warn|err|fixme))?([+-])([A-Za-z_][A-Za-z0-9_]*)")
|
||||
|
||||
|
||||
def game_debug_channels(*values):
|
||||
selectors = {}
|
||||
for value in values:
|
||||
if not isinstance(value, str) or "\0" in value or len(value) > 8192:
|
||||
continue
|
||||
for part in value.split(","):
|
||||
part = part.strip()
|
||||
match = WINE_DEBUG_SELECTOR.fullmatch(part)
|
||||
if match is None:
|
||||
continue
|
||||
key = (match[1] or "", match[3])
|
||||
selectors.pop(key, None)
|
||||
selectors[key] = part
|
||||
for channel in GAME_DEBUG_CHANNELS:
|
||||
key = ("", channel)
|
||||
selectors.pop(key, None)
|
||||
selectors[key] = "+" + channel
|
||||
formatted = ",".join(selectors.values())
|
||||
if len(formatted) > 8192:
|
||||
formatted = ",".join("+" + channel for channel in GAME_DEBUG_CHANNELS)
|
||||
return formatted
|
||||
|
||||
|
||||
def load_config():
|
||||
try:
|
||||
path = Path(os.environ.get("HOME") or "/root") / ".config/droiddeck/game-environment.json"
|
||||
with path.open(encoding="utf-8") as source:
|
||||
return json.load(source)
|
||||
except (OSError, ValueError):
|
||||
return None
|
||||
|
||||
|
||||
def session_debug_dir(env):
|
||||
return env.get("BL_DEBUG_DIR", "")
|
||||
|
||||
|
||||
def apply_game_debug_logs(env, config=None, debug_dir=None):
|
||||
if config is None:
|
||||
config = load_config()
|
||||
if not isinstance(config, dict) or config.get("version") != 1 or config.get("gameDebugLogs") is not True:
|
||||
return env
|
||||
if debug_dir is None:
|
||||
debug_dir = session_debug_dir(env)
|
||||
if (not isinstance(debug_dir, str) or "\0" in debug_dir or len(debug_dir) > 8192
|
||||
or not os.path.isabs(debug_dir) or not os.path.isdir(debug_dir)):
|
||||
print("droiddeck-game-env: game debug logs skipped; session log directory unavailable", file=sys.stderr)
|
||||
return env
|
||||
result = dict(env)
|
||||
result.update({
|
||||
"PROTON_LOG": "1",
|
||||
"PROTON_LOG_DIR": debug_dir,
|
||||
"PROTON_CRASH_REPORT_DIR": debug_dir,
|
||||
"DXVK_LOG_PATH": debug_dir,
|
||||
"DXVK_LOG_LEVEL": "debug",
|
||||
"VKD3D_DEBUG": "info",
|
||||
"WINEDEBUG": game_debug_channels(env.get("WINEDEBUG"), env.get("PROTON_LOG")),
|
||||
})
|
||||
return result
|
||||
@@ -17,6 +17,10 @@ D3D9_DEFAULT_MEMORY_MB = 4096
|
||||
SYNC_KEYS = ("BL_SYNC", "BL_SYNC_FALLBACK", "BL_FSYNC_FIRST", "BL_SYNC_MIN_NOFILE", "PROTON_NO_ESYNC", "PROTON_NO_FSYNC", "PROTON_NO_NTSYNC", "WINEESYNC")
|
||||
SEED_REDISTS = "/usr/local/bin/droiddeck-seed-redists"
|
||||
PACK_KEYS = ("WINESERVER", "BL_SYNC_PACK", "WINEESYNC", "PROTON_NO_ESYNC", "PROTON_NO_FSYNC")
|
||||
GAME_DEBUG = runpy.run_path(str(Path(__file__).with_name("droiddeck-game-debug")))
|
||||
game_debug_channels = GAME_DEBUG["game_debug_channels"]
|
||||
apply_game_debug_logs = GAME_DEBUG["apply_game_debug_logs"]
|
||||
session_debug_dir = GAME_DEBUG["session_debug_dir"]
|
||||
|
||||
|
||||
# Prefixes several games share; the game itself is the Steam app being launched.
|
||||
@@ -661,55 +665,6 @@ def bridge_feature_level(env):
|
||||
return "Mali bridge: VKD3D_FEATURE_LEVEL %s capped at 12_0 (no ray tracing or mesh shaders)" % was
|
||||
|
||||
|
||||
GAME_DEBUG_CHANNELS = (
|
||||
"timestamp", "pid", "tid", "seh", "unwind", "threadname", "debugstr", "loaddll", "mscoree",
|
||||
)
|
||||
WINE_DEBUG_SELECTOR = re.compile(r"(?:(trace|warn|err|fixme))?([+-])([A-Za-z_][A-Za-z0-9_]*)")
|
||||
|
||||
|
||||
def game_debug_channels(*values):
|
||||
selectors = {}
|
||||
for value in values:
|
||||
if not isinstance(value, str) or "\0" in value or len(value) > 8192:
|
||||
continue
|
||||
for part in value.split(","):
|
||||
part = part.strip()
|
||||
match = WINE_DEBUG_SELECTOR.fullmatch(part)
|
||||
if match is None:
|
||||
continue
|
||||
key = (match[1] or "", match[3])
|
||||
selectors.pop(key, None)
|
||||
selectors[key] = part
|
||||
for channel in GAME_DEBUG_CHANNELS:
|
||||
key = ("", channel)
|
||||
selectors.pop(key, None)
|
||||
selectors[key] = "+" + channel
|
||||
formatted = ",".join(selectors.values())
|
||||
if len(formatted) > 8192:
|
||||
formatted = ",".join("+" + channel for channel in GAME_DEBUG_CHANNELS)
|
||||
return formatted
|
||||
|
||||
|
||||
def apply_game_debug_logs(env, config, debug_dir):
|
||||
if not isinstance(config, dict) or config.get("version") != 1 or config.get("gameDebugLogs") is not True:
|
||||
return env
|
||||
if (not isinstance(debug_dir, str) or "\0" in debug_dir or len(debug_dir) > 8192
|
||||
or not os.path.isabs(debug_dir) or not os.path.isdir(debug_dir)):
|
||||
print("droiddeck-game-env: game debug logs skipped; session log directory unavailable", file=sys.stderr)
|
||||
return env
|
||||
result = dict(env)
|
||||
result.update({
|
||||
"PROTON_LOG": "1",
|
||||
"PROTON_LOG_DIR": debug_dir,
|
||||
"PROTON_CRASH_REPORT_DIR": debug_dir,
|
||||
"DXVK_LOG_PATH": debug_dir,
|
||||
"DXVK_LOG_LEVEL": "debug",
|
||||
"VKD3D_DEBUG": "info",
|
||||
"WINEDEBUG": game_debug_channels(env.get("WINEDEBUG"), env.get("PROTON_LOG")),
|
||||
})
|
||||
return result
|
||||
|
||||
|
||||
def sync_config(config, app_id):
|
||||
games = config.get("games", {})
|
||||
return {
|
||||
@@ -1333,7 +1288,7 @@ def main():
|
||||
return 2
|
||||
env = game_gpu(os.environ.copy())
|
||||
mic_enabled = env.get("BL_MIC_ENABLED")
|
||||
debug_dir = env.get("BL_DEBUG_DIR", "")
|
||||
debug_dir = session_debug_dir(env)
|
||||
prefix_path = env.get("STEAM_COMPAT_DATA_PATH", "").rstrip("/")
|
||||
app_id = game_id(env)
|
||||
components = ""
|
||||
|
||||
Reference in new issue
Block a user