Skip to content

fix: production hardening — bugs, perf, and offline support - #14

Merged
johnoct merged 1 commit into
mainfrom
fix/production-hardening
Feb 6, 2026
Merged

fix: production hardening — bugs, perf, and offline support#14
johnoct merged 1 commit into
mainfrom
fix/production-hardening

Conversation

@johnoct

@johnoct johnoct commented Feb 6, 2026

Copy link
Copy Markdown
Owner

Summary

Comprehensive audit and fixes across the codebase for production readiness.

Bug fixes:

  • Fix camera handle leak in try_open_camera — first VideoCapture was never released when falling back to AVFoundation
  • Fix socket leak in get_local_ip — socket now properly closed via try/finally instead of only on success path
  • Fix shell injection risk in send_notification — escape backslashes and double quotes in osascript strings

Performance optimizations:

  • Cache CLAHE object at module level instead of recreating every frame (~10 allocations/sec saved)
  • Lower JPEG stream quality from 95% to 75% — visually identical for baby monitor, ~2-3x bandwidth reduction
  • Eliminate double apply_night_mode call when snapshots + night mode are both enabled (reuse display frame)
  • Match MJPEG stream sleep interval to --fps setting instead of hardcoded 30fps polling

Production hardening:

  • Remove Google Fonts dependency (Comfortaa, Nunito) for fully offline LAN operation
  • Use system font stack (-apple-system, SF Pro) — no external network requests on page load

Test plan

  • All 73 tests passing
  • Manual: verify stream quality acceptable at 75% JPEG
  • Manual: verify web UI fonts render correctly without Google Fonts
  • Manual: verify camera reconnect cycle doesn't leak handles

- Fix camera handle leak in try_open_camera (release before fallback)
- Fix socket leak in get_local_ip (try/finally)
- Fix shell injection in send_notification (escape quotes)
- Cache CLAHE object instead of recreating per frame
- Lower JPEG quality from 95% to 75% for reduced CPU/bandwidth
- Eliminate double night-mode processing on snapshot frames
- Match stream sleep interval to --fps setting
- Remove Google Fonts dependency for fully offline LAN usage
@johnoct
johnoct merged commit a4bf5f9 into main Feb 6, 2026
1 check passed
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