fix(task): raise CaptureException when frame capture stalls#72
Open
nagameTW wants to merge 1 commit into
Open
Conversation
When screen capture produces no frames for a while (e.g. Windows lock screen transition, WGC restart), next_frame() times out and the frame property returned None, crashing every downstream consumer with AttributeError: 'NoneType' object has no attribute 'shape' in FeatureSet.check_size and killing the running task. The frame property now keeps retrying next_frame() so transient stalls no longer kill the task, and raises the existing CaptureException (already handled by the executor main loop via capture_error) after frame_stall_timeout seconds (default 60, constructor param) when capture is really gone. Also use the cached _frame in the executor error handler screenshot path so error handling itself can never raise CaptureException. Fixes ok-oldking/ok-wuthering-waves#1466
|
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.



Problem
ok-oldking/ok-wuthering-waves#1466 — a farming task dies with
AttributeError: 'NoneType' object has no attribute 'shape'inFeatureSet.check_sizeafter the user locks the screen / turns off the monitor.From the log attached to that issue: right before the crash the capture layer logs
no frame for 10 sec, try to restarttwice — a transient stall during the lock-screen transition.next_frame(time_out=6)returnsNoneafter its timeout, theframeproperty passes thatNonethrough, and the recognition path crashes. All three tracebacks in the log funnel throughFeatureSet.check_size, so a stall of ~10-20 seconds permanently kills the running task.Fix
TaskExecutor.framenow keeps retryingnext_frame(), so transient capture stalls no longer kill the task — it resumes once frames come back.frame_stall_timeoutseconds (new constructor param, default 60), it raises the existingCaptureException, which the executor main loop already handles (capture_errorsignal + task stopped with a clear message) — instead of the rawAttributeError._frameinstead of theframeproperty, so error handling itself can never raiseCaptureException.Callers that want a nullable frame still have
nullable_frame(); no caller relies on theframeproperty returningNone(they would all crash on it).Tests
tests/test_task_executor_frame.py, following theTaskExecutor.__new__pattern oftest_task_executor_queue.py:CaptureExceptionNote: developed on Linux where the package cannot be imported (win32 deps), so the tests are written but were not executed here — verified via
py_compileand review. Please run them on Windows before merging.