子游戏跳转链路修复 + H5 音频统一可用

修复后子游戏 SwitchOverGameData 跳转完全可用,行为对齐 daoqi msext:

【zip URL 解析】H5 字段 gamedownloadurl 实为 gameid(msext gameController.m:544
注释"游戏ID")。RemoteConfigClient 新增 lastParsed 缓存 + current() getter;
SubGameViewController.resolveBoot 做两次 VersionResolver.resolve:
  - lobby 视角(gameId=bc.gameId)→ ResolvedVersion 传 AppDataWriter 算
    app_appversion 审核标志(msext result_state 等价)
  - sub-game 视角(gameId=H5 传的 gameid)→ 真实 game_zip 下载 URL

之前 SubGameDownloader 直接把 token 当 URL 用,URLSession 报 -1002
unsupported URL;AppDataWriter resolvedVersion 始终 nil 导致子游戏 app_appversion
永远 0、丢失审核切换能力。

【push 前停大厅背景音】AppCoordinator.showSubGame 节流通过后、push 前调
AudioPlayer.stopAllBackground(msext NewRootVC.m:549-552 等价)。

【H5 音频】
- AVAudioSession.setCategory(.playback) 在 AppDelegate 启动期设置,让原生
  + WKWebView 内 <audio> 都不受静音键影响(msext RootVC.m:1302 等多处等价)
- WKWebViewConfiguration.mediaTypesRequiringUserActionForPlayback = [],子游戏
  push 后立即 loadFileURL 自播背景音不再被 WebKit 静默拦截
- LocalAudioHandler.register 增 assetsRoot 参数,srcIsloop 按容器各自的 H5
  根目录拼 assets/wav/{src}(msext gameController.m:364 等价,大厅 / 子游戏
  音频文件在各自 zip 内不重叠)。修前所有路径都指向大厅根,子游戏读不到自己的
  音频文件,AVAudioPlayer 报 OSStatus 2003334207 (wht?
  kAudioFileUnsupportedFileTypeError)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
joywayer
2026-06-23 21:33:46 +08:00
co-authored by Claude Opus 4.7
parent 053232ed26
commit e50dfb75af
7 changed files with 118 additions and 20 deletions
@@ -176,6 +176,11 @@ public actor RemoteConfigClient {
private let urlBuilder: @Sendable () -> URL?
private let maxRetries: Int
/// `.parsed(...)` SubGameViewController
/// H5 gameid VersionResolver zip URL
/// `.shortText` ""
private var lastParsed: RemoteConfig?
public init(
session: URLSession = RemoteConfigClient.defaultSession,
urlBuilder: @escaping @Sendable () -> URL? = RemoteConfigClient.defaultURLBuilder,
@@ -186,6 +191,11 @@ public actor RemoteConfigClient {
self.maxRetries = maxRetries
}
/// fetch RemoteConfignil
public func current() -> RemoteConfig? {
lastParsed
}
/// URLSession 10 s
nonisolated public static var defaultSession: URLSession {
let cfg = URLSessionConfiguration.default
@@ -258,6 +268,7 @@ public actor RemoteConfigClient {
decoder.keyDecodingStrategy = .convertFromSnakeCase
do {
let parsed = try decoder.decode(RemoteConfig.self, from: data)
lastParsed = parsed
return .parsed(parsed)
} catch {
throw RemoteConfigError.decodingFailed(error)