Skip to content

fix: 游戏已运行时 -t 无界面启动应对设备就绪做轮询等待#57

Merged
ok-oldking merged 1 commit into
ok-oldking:masterfrom
1w1w11w1:fix/headless-start-when-game-running
May 18, 2026
Merged

fix: 游戏已运行时 -t 无界面启动应对设备就绪做轮询等待#57
ok-oldking merged 1 commit into
ok-oldking:masterfrom
1w1w11w1:fix/headless-start-when-game-running

Conversation

@1w1w11w1
Copy link
Copy Markdown
Contributor

@1w1w11w1 1w1w11w1 commented May 18, 2026

问题描述

修复 ok-oldking/ok-wuthering-waves#1293

使用 ok-ww.exe -t N(无界面直跑一次性任务)时,若鸣潮已由外部预先启动,进程常在约 0.3–1s 内退出,日志出现 RuntimeError: Start task failed,任务从未进入队列;若由 ok-ww 冷启动游戏,则因存在轮询等待而正常。

根因

StartController.start_device()device['connected'] == True 时仅调用一次 check_device_error()。此时 WGC/窗口捕获常尚未就绪,会立即返回「未连接」类错误。

connected == False(冷启动)分支在 starting game 后会进入 while + sleep(2) 轮询,故能成功。

v3.3.29 起,-t > 0OK.start()run_onetime_task()do_start() 无界面路径,不再经 GUI MainWindow.showEvent,该缺陷被稳定暴露。

修复方案

抽取 _wait_until_device_ready(),在「游戏已连接」与「冷启动后等待」两条路径共用同一套轮询逻辑(直至 start_timeout),与冷启动行为一致。

测试建议

  • 路径 A(原失败):先手动启动鸣潮 → 执行 ok-ww.exe -t 1(或 -t 1 -e)→ 应出现 waiting for game to start error 后成功进入任务,而非秒退
  • 路径 B(回归):结束鸣潮 → ok-ww.exe -t 1 → 冷启动 + 轮询后任务正常
  • GUI:手动点「开始」行为与修复前一致

Headless -t startup failed when the game was already open because start_device only called check_device_error once for connected devices. Reuse the same wait loop as cold start.

Fixes ok-oldking/ok-wuthering-waves#1293
@sonarqubecloud
Copy link
Copy Markdown

@1w1w11w1 1w1w11w1 changed the title fix: poll device readiness when game already running (-t headless) fix: 游戏已运行时 -t 无界面启动应对设备就绪做轮询等待 May 18, 2026
@ok-oldking ok-oldking merged commit 9eebff8 into ok-oldking:master May 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants