Skip to content

feat: resilient camera reconnection with exponential backoff - #11

Merged
johnoct merged 1 commit into
mainfrom
feat/camera-reconnect
Feb 6, 2026
Merged

feat: resilient camera reconnection with exponential backoff#11
johnoct merged 1 commit into
mainfrom
feat/camera-reconnect

Conversation

@johnoct

@johnoct johnoct commented Feb 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Tolerate 30 dropped frames (~3s at 10 FPS) before treating camera as lost, instead of the old 3-frame instant teardown
  • Add try_open_camera() that returns None instead of sys.exit(1) on failure
  • Add reconnect_camera() with exponential backoff (2s, 4s, 8s... capped at 60s, up to 10 attempts)
  • Send macOS notifications on camera disconnect/reconnect so the user knows what's happening
  • Graceful exit if all reconnect attempts exhausted

Test plan

  • TestTryOpenCamera: returns cap when available, returns None when unavailable, tries AVFoundation fallback
  • TestReconnectCamera: succeeds on first try, retries with backoff, returns None after max attempts, backoff timing verified, 60s cap verified
  • All 60 tests pass (52 babyping + 8 web), zero regressions
  • Manual: test with iPhone Continuity Camera at distance to verify reconnection works

Replace the aggressive 3-frame disconnect that called sys.exit with a
tolerant reconnection strategy for Continuity Camera over WiFi:

- Tolerate 30 dropped frames (~3s) before considering camera lost
- try_open_camera returns None instead of killing the app
- reconnect_camera retries up to 10 times with exponential backoff
  (2s, 4s, 8s... capped at 60s)
- macOS notifications on disconnect/reconnect
- Graceful exit if all reconnect attempts fail
@johnoct
johnoct merged commit cc0281f 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