Skip to content

armgit / soju

Public Imported from GitHub
0

Play Windows games on Apple Silicon Macs. Free, open-source app that installs the official Battle.net, Steam, Epic and GOG launchers and lists your games in one library.

Keep steam.exe off Core Audio so Steam reaches its login window (#56)

Mikek537e5b838d4e
diff --git a/README.ko.md b/README.ko.md
index ed158102cfe..87d7510f897 100644
--- a/README.ko.md
+++ b/README.ko.md
@@ -176,6 +176,7 @@ GPTK 안의 `libd3dshared.dylib`는 그래픽만이 아닙니다. **D2R 로더(
- **게임 종료 후(또는 실행이 죽은 뒤) 배틀넷이 "업데이트"(초기화 중)에 멈추고 플레이 버튼이 사라짐**: 게임 프로세스가 끝날 때마다 런처가 설치를 다시 점검합니다. 업데이트를 일시정지했다가 재개하면 플레이 버튼이 돌아오고 정상 실행됩니다. 설치 후 첫 플레이가 1분 안에 죽으면 플레이를 한 번 더 누르세요: 한 번 보고된 사례에서 두 번째 실행은 정상이었습니다. 일시정지 버튼이 아예 반응하지 않으면 클라이언트 자체가 멈춘 것입니다(일주일 넘게 켜 둔 뒤 Battle.net.exe가 CPU를 다 쓰며 돌던 사례): 독에서 배틀넷을 종료하고 다시 열면 플레이 버튼이 돌아옵니다.
- **플레이스테이션 패드(듀얼쇼크 4, 듀얼센스)를 페어링해서 macOS는 인식하는데 게임이 무시함** (블루투스 듀얼쇼크 4 + D2R, #42): `soju controllers`를 열면 DirectInput에만 보이고 XInput 슬롯은 전부 비어 있습니다. Wine은 소니 패드를 기본으로 raw HID 백엔드로 붙이는데, macOS에서는 그 백엔드가 패드를 XInput으로 내놓지 않고, 블리자드 게임은 XInput만 봅니다. 이제 `soju battlenet`이 소니 패드만 SDL 경로로 돌립니다(제조사 단위 레지스트리 항목이라 raw HID가 필요한 휠·스틱은 그대로). 그러면 Xbox 패드처럼 동작합니다. 이 설정은 보틀이 뜰 때 한 번 읽으므로, 배틀넷이 이미 켜져 있었다면 `soju kill`로 완전히 내렸다가(창만 닫으면 보틀이 한동안 살아 있을 수 있습니다) 다시 여세요. `soju controllers`의 "Disable hidraw"를 켜면 모든 장치에 같은 효과입니다. 소니 패드에 raw HID를 되돌리려면 `HKLM\System\CurrentControlSet\Services\WineBus\Devices\054C`의 `Hidraw`를 1로 두면 됩니다.
+- **Steam 로그인 창이 끝내 뜨지 않음** (`steam.exe`와 `steamwebhelper`가 CPU 0%로 멈춰 있고, `dumps/`에 `BMainLoop appears to have stalled`가 담긴 `assert_steam.exe_*.dmp`가 생김, #55): Steam용 Wine 11.0은 Steam 메인 루프에서 Mac의 모든 오디오 장치를 포맷 하나씩 확인하는데, 일부 Mac에서는 이 과정이 Steam이 허용하는 시간보다 오래 걸립니다. 이제 `soju steam`은 Steam 클라이언트 프로세스만 Core Audio에 접근하지 않게 해서 다음 실행부터 해결됩니다(멈춰 있다면 먼저 `soju steam-kill`). 게임과 상점 영상 소리는 그대로이고, 음성 채팅 같은 클라이언트 자체 오디오만 꺼집니다. 다시 켜려면 Steam 보틀의 `HKCU\Software\Wine\AppDefaults\steam.exe\DllOverrides`에서 `winecoreaudio.drv`를 `builtin`으로 바꾸세요.
- **BLZBNTBNA00000005** → `play.sh`가 서명된 exe를 자동으로 넣어 줍니다.
## 라이선스
diff --git a/README.md b/README.md
index 2b48c621819..1ca4416bea2 100644
--- a/README.md
+++ b/README.md
@@ -195,6 +195,7 @@ Start with `soju doctor`: it checks most of the items below and tells you which
- **Epic: "your account has too many active logins"** and logging out everywhere or resetting the password does not help. The account service is really answering `too_many_sessions` (18048), a limit on how many sessions were *issued*, not how many are held, so retrying makes it worse. Older engines hit this within a handful of launches because Wine could not keep the launcher's device key: see `patches/ncrypt-persisted-keys.patch`. Stop the bottle (`soju epic-kill`), leave it alone for a few hours so the counter clears, then start it once.
- **Battle.net shows "Update" (stuck at Initializing) and the Play button is gone** after a game exits, or after a launch that died: the launcher re-checks the install every time a game process ends. Pause the update and resume it; Play comes back and the game starts normally. If the very first Play after an install dies within a minute, press Play again: seen once, the second launch went through. If the pause button does not react at all, the client itself has hung (seen after a week of uptime, with Battle.net.exe spinning at full CPU): quit Battle.net from the Dock and open it again, and Play is back.
- **A PlayStation pad (DualShock 4, DualSense) is paired and macOS sees it, but the game ignores it** (DualShock 4 over Bluetooth with D2R, #42): `soju controllers` lists it under DirectInput only, with every XInput slot empty. Wine attaches Sony pads through its raw HID backend by default, and on macOS that backend never presents them as XInput pads, which is all Blizzard's games look for. `soju battlenet` now routes Sony pads through SDL instead (a per-vendor registry entry, so wheels and sticks that need raw HID keep it), and the pad works as an Xbox-style controller. Wine reads this once when the bottle starts: if Battle.net was already open, stop it with `soju kill` (just closing the window can leave the bottle running for a while) and start it again. Ticking "Disable hidraw" in `soju controllers` does the same for every device. To give Sony pads raw HID again, set `Hidraw` to 1 under `HKLM\System\CurrentControlSet\Services\WineBus\Devices\054C`.
+- **Steam never shows its login window** (`steam.exe` and `steamwebhelper` sit at 0% CPU, and `dumps/` gets an `assert_steam.exe_*.dmp` saying `BMainLoop appears to have stalled`; #55): Steam's Wine 11.0 probes every Mac audio device one format at a time from Steam's main loop, and on some Macs that takes longer than Steam allows. `soju steam` now keeps the Steam client process itself off Core Audio, which fixes it from the next launch (`soju steam-kill` first if it is frozen). Games and store videos keep their sound; only the client's own audio (such as voice chat) is off. To turn it back on, set `winecoreaudio.drv` to `builtin` under `HKCU\Software\Wine\AppDefaults\steam.exe\DllOverrides` in the Steam bottle.
- **BLZBNTBNA00000005** -> `play.sh` seeds the signed exe automatically; make sure you launch through it.
### Leftover Wine processes
diff --git a/README.zh.md b/README.zh.md
index b6a1b5304ec..e463abe6f1b 100644
--- a/README.zh.md
+++ b/README.zh.md
@@ -180,6 +180,7 @@ scripts/play.sh steam-kill # 停止 Steam bottle
- **Epic 提示 "your account has too many active logins"**,而且在所有设备退出登录、甚至重置密码后依旧如此。账号服务实际返回的是 `too_many_sessions`(18048),限制的是*已发放*的会话数量而非当前持有的数量,所以反复重试只会更糟。旧引擎上启动几次就会触发,因为 Wine 无法保存登录器的设备密钥,详见 `patches/ncrypt-persisted-keys.patch`。先停掉 bottle(`soju epic-kill`),放置几个小时等计数器清零,然后只启动一次。
- **游戏退出后(或启动失败后)Battle.net 停在"更新"(正在初始化),Play 按钮消失**:每当游戏进程结束,启动器都会重新检查安装。暂停更新再恢复,Play 按钮就会回来,游戏正常启动。如果安装后第一次 Play 在一分钟内退出,再按一次 Play:目前报告过一次,第二次启动正常。如果暂停按钮完全没有反应,说明客户端本身已经卡死(见于连续运行一周后,Battle.net.exe 占满 CPU):从 Dock 退出 Battle.net 再重新打开,Play 按钮就会回来。
- **PlayStation 手柄(DualShock 4、DualSense)已配对,macOS 能识别,但游戏没有反应**(蓝牙 DualShock 4 + D2R,#42):打开 `soju controllers`,手柄只出现在 DirectInput 下,XInput 槽位全空。Wine 默认通过 raw HID 后端接入索尼手柄,而在 macOS 上这个后端不会把它们呈现为 XInput 手柄,暴雪的游戏只认 XInput。现在 `soju battlenet` 会把索尼手柄改走 SDL 路径(按厂商 ID 写的注册表项,需要 raw HID 的方向盘和摇杆不受影响),手柄就以 Xbox 手柄的形式工作。这个设置在 bottle 启动时只读一次:如果 Battle.net 已经开着,先用 `soju kill` 彻底停掉(只关窗口可能让 bottle 继续运行一阵)再重新打开。在 `soju controllers` 里勾选 "Disable hidraw" 对所有设备都有同样效果。要让索尼手柄恢复 raw HID,把 `HKLM\System\CurrentControlSet\Services\WineBus\Devices\054C` 下的 `Hidraw` 设为 1。
+- **Steam 始终不显示登录窗口**(`steam.exe` 和 `steamwebhelper` 停在 0% CPU,`dumps/` 里出现内容为 `BMainLoop appears to have stalled` 的 `assert_steam.exe_*.dmp`;#55):Steam 使用的 Wine 11.0 会在 Steam 主循环里逐个格式探测 Mac 的所有音频设备,在部分 Mac 上耗时超过 Steam 允许的上限。现在 `soju steam` 只让 Steam 客户端进程本身不接触 Core Audio,下次启动即可解决(若已卡住,先执行 `soju steam-kill`)。游戏和商店视频仍有声音,只有客户端自己的音频(如语音聊天)被关闭。要恢复,在 Steam 容器的 `HKCU\Software\Wine\AppDefaults\steam.exe\DllOverrides` 下把 `winecoreaudio.drv` 设为 `builtin`。
- **BLZBNTBNA00000005** -> `play.sh` 会自动播种签名 exe;请确认是通过它启动的。
### 残留的 Wine 进程
diff --git a/docs/STEAM-GAMES.md b/docs/STEAM-GAMES.md
index 21fcddb93df..5dc4507d0f6 100644
--- a/docs/STEAM-GAMES.md
+++ b/docs/STEAM-GAMES.md
@@ -53,6 +53,18 @@ Hard-won facts, in the order they burned us:
`WINE_NO_DOCK_ICON="steam.exe;steamservice.exe"`, matching the basename of
the first two argv entries (NSProcessInfo sees pre-rewrite argv; scanning all
args would also hide the helper via its `-steampath=` argument).
+11. **steam.exe gets no audio driver** (#55). Wine 11.0's winmm fills in
+ device capabilities by asking each device about 20 PCM formats, and every
+ ask opens a Core Audio unit on it (removed in Wine 11.5, c3a1bc8613).
+ Steam calls `mixerOpen` from its main loop, so a slow device freezes the
+ client before its login window (`CSteamEngine::BMainLoop appears to have
+ stalled`, stack `steamclient64 → winmm → mmdevapi` inside
+ `IsFormatSupported`). Measured: 0.1 s with two outputs, 0.7–1.7 s with
+ microphones; one report went past 15 s. play.sh adds
+ `AppDefaults\steam.exe\DllOverrides\winecoreaudio.drv=disabled` when the
+ value is absent. Games and the webhelper keep their sound; set the value to
+ `builtin` to give steam.exe audio back. `Drivers\Audio=""` also cures it,
+ but silences every game in the bottle.
## Automatic setup
diff --git a/scripts/play.sh b/scripts/play.sh
index db1eef46676..d71fa967b2a 100755
--- a/scripts/play.sh
+++ b/scripts/play.sh
@@ -280,7 +280,20 @@ case "$MODE" in
# prefix. Steam re-adds it on update, so scrub it every launch.
"${STEAM_ENV[@]}" "$WINESTABLE" reg delete 'HKCU\Software\Microsoft\Windows\CurrentVersion\Run' \
/v Steam /f >/dev/null 2>&1 || true
- # 5) Virtual desktop: this macdrv (gcenx wine 11) ignores virtual desktops,
+ # 5) Keep steam.exe away from Core Audio (#55). Wine 11.0's winmm builds its
+ # device list by asking every device about 20 PCM formats, and each ask
+ # opens a Core Audio unit on that device. Steam does this from its main
+ # loop (mixerOpen), so a slow device stalls the client before its login
+ # window: 0.1 s with two outputs, 0.7-1.7 s once microphones are present,
+ # and past Steam's 15 s stall check on one reported Mac. Wine 11.5 dropped
+ # the probe (c3a1bc8613). Only steam.exe is affected: games, and the
+ # webhelper that plays store videos, keep their sound. Added only when
+ # absent, so setting the value to "builtin" gives Steam its audio back.
+ STEAM_AUDIO_KEY='HKCU\Software\Wine\AppDefaults\steam.exe\DllOverrides'
+ "${STEAM_ENV[@]}" "$WINESTABLE" reg query "$STEAM_AUDIO_KEY" /v winecoreaudio.drv >/dev/null 2>&1 ||
+ "${STEAM_ENV[@]}" "$WINESTABLE" reg add "$STEAM_AUDIO_KEY" /v winecoreaudio.drv /t REG_SZ /d disabled /f \
+ >/dev/null 2>&1 || true
+ # 6) Virtual desktop: this macdrv (gcenx wine 11) ignores virtual desktops,
# so it is off by default. The single Dock icon is handled by
# WINE_NO_DOCK_ICON (winemac patch) instead.
# To enable anyway: WINE_VIRTUAL_DESKTOP=auto (or a resolution like 1600x900).
@@ -293,7 +306,7 @@ case "$MODE" in
VD="1728x1080"
fi
fi
- # 6) Launch: plain wine-stable environment, without the CX engine env
+ # 7) Launch: plain wine-stable environment, without the CX engine env
STEAM_CMD=("C:\\Program Files (x86)\\Steam\\steam.exe" -no-cef-sandbox -cef-single-process)
# SteamSetup only contains the bootstrapper: let first launch download the
# client, otherwise Steam fails with "Failed to load steamui.dll".
diff --git a/tests/test_regressions.py b/tests/test_regressions.py
index 2532981ead9..9f57334c2ab 100644
--- a/tests/test_regressions.py
+++ b/tests/test_regressions.py
@@ -189,9 +189,10 @@ class UninstallTests(unittest.TestCase):
if answers is not None:
answer_file = d / "answers"
answer_file.write_text(answers)
- # Keep one descriptor open so consecutive read calls advance.
+ # Keep one pipe open so consecutive read calls advance. A plain
+ # file would not: Linux reopens /dev/fd/N of a file at offset 0.
src = src.replace("TTY=/dev/tty",
- "exec 9<" + shlex.quote(str(answer_file)) + "\nTTY=/dev/fd/9")
+ "exec 9< <(cat " + shlex.quote(str(answer_file)) + ")\nTTY=/dev/fd/9")
script = d / "scripts/uninstall.sh"
script.parent.mkdir()
for helper in ("steam-runtime.sh", "steam-session.py"):
diff --git a/tests/test_steam_lifecycle.py b/tests/test_steam_lifecycle.py
index 90d02463ad7..4cc2a7166ff 100644
--- a/tests/test_steam_lifecycle.py
+++ b/tests/test_steam_lifecycle.py
@@ -175,7 +175,7 @@ if [ "$1" = -w ]; then echo final > "$WINEPREFIX/shutdown-write"; fi
answer_file = d / "answers"; answer_file.write_text(answers)
p = project / "scripts/uninstall.sh"
p.write_text(p.read_text().replace("TTY=/dev/tty",
- "exec 9<" + shlex.quote(str(answer_file)) + "\nTTY=/dev/fd/9"))
+ "exec 9< <(cat " + shlex.quote(str(answer_file)) + ")\nTTY=/dev/fd/9"))
args = []
env = {k: v for k, v in os.environ.items() if k not in ("SOJU_STEAM_WINE", "ENGINE", "WINEPREFIX")}
env.update(SOJU_BASE=str(base), SOJU_TEST=str(d), SOJU_TEST_FAILURE=failure,
diff --git a/tests/test_steam_wine.py b/tests/test_steam_wine.py
index 798fe455e2f..125476945b9 100644
--- a/tests/test_steam_wine.py
+++ b/tests/test_steam_wine.py
@@ -142,6 +142,47 @@ class SteamFirstLaunchTests(unittest.TestCase):
self.assertEqual("-noverifyfiles" in args, installed)
self.assertIn("-cef-single-process", args)
+ def test_steam_client_audio_is_disabled_once_and_user_choice_is_kept(self):
+ key = "HKCU\\Software\\Wine\\AppDefaults\\steam.exe\\DllOverrides"
+ for present in (False, True):
+ with self.subTest(present=present), tempfile.TemporaryDirectory() as tmp:
+ base = Path(tmp)
+ prefix = base / "steam-bottle"
+ steam = prefix / "drive_c/Program Files (x86)/Steam"
+ steam.mkdir(parents=True)
+ (steam / "steam.exe").touch()
+ runtime = base / "wine"
+ (runtime / "bin").mkdir(parents=True)
+ log = base / "calls"
+ binary = runtime / "bin/wine"
+ # reg query fails while the value is absent, as reg.exe does.
+ binary.write_text('#!/bin/bash\necho "$*" >> "$SOJU_TEST_ARGS"\n'
+ '[ "$1 $2" = "reg query" ] && [ "$SOJU_TEST_PRESENT" != 1 ] && exit 1\nexit 0\n')
+ binary.chmod(0o755)
+ stubs = base / "stubs"
+ stubs.mkdir()
+ for name in ("python3", "pgrep"):
+ script = stubs / name
+ script.write_text("#!/bin/bash\nexit 0\n")
+ script.chmod(0o755)
+ env = {**os.environ, "SOJU_BASE": str(base), "WINEPREFIX": str(prefix),
+ "SOJU_STEAM_WINE": str(runtime), "SOJU_TEST_ARGS": str(log),
+ "SOJU_TEST_PRESENT": "1" if present else "0",
+ "WINE_VIRTUAL_DESKTOP": "", "SOJU_KEYLOG": "0",
+ "PATH": str(stubs) + ":/usr/bin:/bin"}
+ result = subprocess.run(["/bin/bash", str(ROOT / "scripts/play.sh"), "steam"],
+ env=env, capture_output=True, text=True)
+ self.assertEqual(result.returncode, 0, result.stderr)
+ calls = log.read_text().splitlines()
+ adds = [c for c in calls if c.startswith("reg add " + key)]
+ self.assertIn("reg query " + key + " /v winecoreaudio.drv", calls)
+ if present:
+ self.assertEqual(adds, [])
+ else:
+ self.assertEqual(adds, ["reg add " + key + " /v winecoreaudio.drv /t REG_SZ /d disabled /f"])
+ launch = [i for i, c in enumerate(calls) if "steam.exe -no-cef-sandbox" in c]
+ self.assertTrue(launch and all(calls.index(a) < launch[0] for a in adds))
+
spec_bootstrap = importlib.util.spec_from_file_location("steam_bootstrap", ROOT / "scripts/bootstrap-steam.py")
bootstrap = importlib.util.module_from_spec(spec_bootstrap)
spec_bootstrap.loader.exec_module(bootstrap)