fix: 游戏已运行时 -t 无界面启动应对设备就绪做轮询等待#57
Merged
ok-oldking merged 1 commit intoMay 18, 2026
Merged
Conversation
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
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



问题描述
修复 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 > 0走OK.start()→run_onetime_task()→do_start()无界面路径,不再经 GUIMainWindow.showEvent,该缺陷被稳定暴露。修复方案
抽取
_wait_until_device_ready(),在「游戏已连接」与「冷启动后等待」两条路径共用同一套轮询逻辑(直至start_timeout),与冷启动行为一致。测试建议
ok-ww.exe -t 1(或-t 1 -e)→ 应出现waiting for game to start error后成功进入任务,而非秒退ok-ww.exe -t 1→ 冷启动 + 轮询后任务正常