Conversation
One-time tasks could block in next_frame when a foreground interaction backend reported that the target window was not active. Prepare the interaction backend before requesting the first frame so task.run() can execute normally. Add regression coverage for one-time and trigger-task preparation, including the execution order.
|
Owner
|
哪里会用到 |
Author
|
@ok-oldking 这个修改用于一次性任务的启动流程。任务被执行器取出后,会在第一次调用 对于 原因是标准的 持续执行的 |
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.



Summary
Related to #94
Context
This was found while developing and repeatedly debugging
FishingOnceTaskin ok-how-to-fish, an application created from theok-scriptapplication template. The task uses the normalBaseTaskAPI, and the GUI Run action uses the framework's normalStartController.start(task)entry point.Root cause
TaskExecutor.execute()requested the first frame before calling a one-time task'srun(). With foreground interaction backends such asPynputorPyDirect,should_capture()returns false while the target window is not foreground. A task-levelensure_in_front()insiderun()therefore cannot prepare the window before that first capture request.The result is that a one-time task can be queued and taken by the executor but remain in the pre-run capture path for an avoidable and potentially long delay before entering
run(). The exact delay depends on the capture backend, window focus, and related frame checks; this is not a deliberate task-level wait and can look like the task is stuck.The GUI task start path eventually uses
StartController._mark_task_enabled(), which directly marks the task enabled and queues it instead of callingBaseTask.enable(). This means the existinginteraction.on_run()call inBaseTask.enable()does not cover this framework entry path. The same controller path is also used by command-line/headless and Web/API starts.This is a framework lifecycle/order issue, not an incorrect
ok-how-to-fishtask API call or an incorrect GUI debug action.Fix
Call
interaction.on_run()before requesting the first frame for one-time tasks. This lets foreground-dependent interaction backends prepare the target window before capture begins.Trigger tasks retain their existing behavior and are not forcibly foregrounded by this change.
Validation
python -m unittest discover -s tests -p "test_task_executor_queue.py" -vpy_compilepassed for the changed Python files