Skip to content

Comments

feat: conditional window capture + recording profiling with auto-wormhole#12

Open
abrichr wants to merge 11 commits intomainfrom
feat/profiling-and-window-conditional
Open

feat: conditional window capture + recording profiling with auto-wormhole#12
abrichr wants to merge 11 commits intomainfrom
feat/profiling-and-window-conditional

Conversation

@abrichr
Copy link
Member

@abrichr abrichr commented Feb 17, 2026

Summary

  • Make window reader/writer threads conditional on RECORD_WINDOW_DATA (defaults to False), eliminating an unnecessary thread + process + expensive platform API calls during recording
  • Add sleep throttle to read_window_events (0.1s) and memory_writer (1s) tight loops
  • Add profiling summary at end of record() — saves profiling.json to capture dir with duration, event counts/rates, config flags, whether running on main thread, and thread count
  • Auto-send profiling.json via Magic Wormhole after recording stops for easy remote debugging

Context

Investigating why record_waa_demos.py is noticeably laggier than python -m openadapt_capture.cli record on Windows. This PR adds instrumentation to compare both paths — after each recording, profiling data is automatically wormhole-sent for analysis.

Test plan

  • All 129 tests pass
  • Lint clean
  • Run CLI recording on Windows, receive profiling via wormhole
  • Run record_waa_demos.py on Windows, receive profiling via wormhole
  • Compare profiles to identify root cause of lag difference

🤖 Generated with Claude Code

abrichr and others added 11 commits February 17, 2026 11:56
… auto-wormhole

- Make window reader/writer conditional on RECORD_WINDOW_DATA (defaults to False),
  eliminating unnecessary thread + process + expensive platform API calls
- Add throttle to read_window_events (0.1s) and memory_writer (1s) loops
- Add profiling summary at end of record() with duration, event counts/rates,
  config flags, main thread check, and thread count
- Auto-send profiling.json via Magic Wormhole after recording stops

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…evel to WARNING

- When window capture is disabled, skip the window timestamp requirement
  in process_events instead of discarding all action events
- Set loguru log level to WARNING by default (was DEBUG) to reduce noise
  during recording

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
video_post_callback crashes with KeyError 'last_frame' when recording
stops before any action triggers a video frame write. Guard against
missing state keys and close the container gracefully.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…e compat

- Second reference to prev_window_event in process_events was unguarded,
  causing AttributeError when RECORD_WINDOW_DATA=False
- PyAV pict_type="I" raises TypeError on newer versions; fall back to
  integer constant

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use av.video.frame.PictureType.I instead of string "I" which is
  unsupported in current PyAV versions
- Add test_video.py with tests for frame writing, key frames, and
  PictureType enum compatibility

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Set matplotlib to non-interactive Agg backend so plotting works from
  background threads (fixes RuntimeError when Recorder runs record()
  in a non-main thread)
- Improve wormhole-not-found message with install instructions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When the stop sequence was fully matched, the index wasn't reset.
Extra keypresses after the match would index past the end of the
sequence list, causing IndexError.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…Error

- Track screenshot duration (avg/max/min ms) and total iteration duration
  per screen reader loop iteration in profiling.json
- Reset stop sequence index after match to prevent IndexError on extra
  keypresses

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…r dep

Profiling data is no longer auto-sent via wormhole after every recording.
Use --send_profile flag to opt in. Also promotes magic-wormhole from
optional [share] extra to a regular dependency since sharing is core
functionality.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
HTML visualizer referenced these attributes which didn't exist on
CaptureSession. Added properties with safe fallbacks and updated
html.py to use getattr with defaults.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant