WGC regressed on exclusive fullscreen since 2.0.8: lock timeout misclassified as failure, invalidates WGC for all Windows consumers
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- computer-vision
Research direction
Start with ok/device/capture_methods/windows_graphics.py and trace how get_frame_lock contention is handled through ok/device/capture_methods/update.py and base.py; also read ok/task/exceptions.py and the WGC probing path. Done means transient BUSY contention keeps WGC selected without poisoning its failure cache or falling back, while the probe respects its deadline and the documented lock-order and resource-safety invariants remain intact.
Written by the indexing model from the issue text.
Description
Summary
WindowsGraphicsCaptureMethod fails to produce any frame on exclusive fullscreen since ok-script 2.0.8. The new timeout-guarded get_frame_lock serialization (added by the commit that split start_or_stop/do_get_frame into _start_or_stop/_do_get_frame) turns ordinary lock contention into a TimeoutError. The capture-method selector then interprets that error as "WGC is broken", closes the instance, and falls back to BitBlt_RenderFull — which cannot capture exclusive fullscreen at all. Net effect: no frames, no recognition.
This affects every downstream consumer whose game runs exclusive fullscreen (ok-wuthering-waves "Enable Boxes" debug overlay draws nothing, tasks stall).
Environment
- ok-script 2.0.8 (file sha
0ea7339), Windows 11 build 29680 - Game: Wuthering Waves, exclusive fullscreen, single monitor 2880x1620 (150% DPI)
- Capture preference:
['WGC', 'BitBlt_RenderFull']
Evidence (logs)
WARNING update: Windows Graphics Capture did not produce a frame within 1.5s
INFO update: use BitBlt_RenderFull capture render_full: True
ERROR bitblt_utils: capture_by_bitblt exception: BitBlt failed
ERROR update_window_size hwnd_window: og.executor.pause pos_invalid: (-32000, -32000, 0, 0)
WARNING overlay really: rect stuck at (0,0,2880x1620), boxes_enabled=True boxes_active=True
After reverting the 2.0.8 lock wrapper locally (raw revert), the same session logs:
INFO RefreshAdb update: use WGC capture
INFO start_controller update:use WGC capture
INFO overlay: Win32 overlay presented: ... boxes_active=True
So WGC itself works; it is the new timeout/error semantics that disqualify it.
Root cause
ok/device/capture_methods/windows_graphics.py (2.0.8):
def do_get_frame(self):
if not self.get_frame_lock.acquire(timeout=WGC_FRAME_WAIT_TIMEOUT):
raise TimeoutError('Windows Graphics Capture is busy, ...')
try:
return self._do_get_frame()
finally:
self.get_frame_lock.release()
_do_get_frame()can holdget_frame_lockfor up toWGC_FRAME_WAIT_TIMEOUT = 4.0swhile waiting for a frame (windows_graphics.pyframe loop).- On exclusive fullscreen the first frame is slower, so a concurrent caller (device refresh via
update.py:50, anotherget_frame(), or anhwnd_windowsetter) contends for the lock. - A second caller times out and raises
TimeoutError. ok/device/capture_methods/update.py_capture_can_produce_frame()treats any exception fromget_frame()as "did not produce a frame" →get_win_graphics_capture()closes the WGC instance and setslast_start_failure_key/last_start_failure_time(5s failure cache) → selector falls through to the next method.- BitBlt is documented as unable to capture exclusive fullscreen (
bitblt.py:21-28), so the fallback also fails.
The 2.0.8 lock itself addresses a real cross-thread lock-order inversion (get_frame_lock -> self.lock vs self.lock -> get_frame_lock via close()), which the fix intends to guard. The bug is that lock contention is modelled as failure instead of a retryable BUSY state.
Additionally update.py's WGC_FIRST_FRAME_TIMEOUT = 1.5 cannot interrupt a single get_frame() call that internally blocks ~4s, so the probe budget is not actually honoured.
Impact
- All ok-script Windows consumers preferring WGC, plus
BrowserWGCwhich inheritsWindowsGraphicsCaptureMethod. - Hard failure (not flaky) on exclusive fullscreen.
- Recovery paths degrade to BitBlt which cannot handle this mode.
Proposed fix (durable)
Introduce a dedicated retryable CaptureBusyException and separate BUSY from genuine failure:
CaptureBusyExceptioninok/task/exceptions.py(subclassException, notCaptureException).windows_graphics.py:start_or_stop()anddo_get_frame()keep uniformget_frame_lock -> self.lockordering, but acquire non-blocking; on contention raiseCaptureBusyException(does not poison failure cache, does notclose()).- Add
get_frame_for_probe(timeout)that honours an absolute caller deadline and propagates BUSY. base.py:get_frame()mapsCaptureBusyException→None(normal consumers just retry next frame).update.py:get_win_graphics_capture()treats BUSY as "keep WGC selected, retry", neverclose()/cache;_capture_can_produce_frame()passes its remaining budget intoget_frame_for_probe().hwnd_windowsetter swallows BUSY (defers target refresh; the lock owner validatescapture_target_signature).
Invariants to preserve:
start_or_stop/do_get_frameacquireget_frame_lockbeforeself.lock.- Only one frame request owns
frame_requested/frame_event/last_frame. close()waits forget_frame_lockbefore freeing D3D/GDI resources.- BUSY never writes the WGC failure cache nor triggers fallback.
- WGC first-frame probing cannot exceed the outer deadline.
Full patch (4 files) is prepared; PR to follow.
Interim workaround used by ok-ww users
Revert the 2.0.8 wrapper locally (remove the acquire(timeout=...) in start_or_stop/do_get_frame), which restores WGC but re-exposes the concurrent-request and close()-vs-composite races the lock guarded against. Not recommended as a durable fix.
Downstream report: ok-oldking/ok-wuthering-waves#1736
- Dominant language
- Python
- Stars
- 876
- Forks
- 254
- Avg merge
- 6h 52m
- Merged PRs (30d)
- 13
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ok-oldking/ok-script
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ok-oldking/ok-script#128 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ok-oldking/ok-script#90 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
ok-oldking/ok-script#120 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
ok-oldking/ok-script#106 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
ok-oldking/ok-script#94 ·
Maintainers usually reply within 1 day
All issues in ok-oldking/ok-script
Similar issues
-
Test: to_hijri() accepts datetime.datetime and uses only the date partPossibly taken A pull request linked to this issue is open or already merged. Opengood first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 · 3 comments ·
Maintainers usually reply within 1 day
-
polish
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresPossibly taken @AshutoshSingh840 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
UKGovernmentBEIS/control-arena#992 ·
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
mvalentsev/awesome-free-ai-coding#70 ·
Maintainers usually reply within 1 day