fix(meta_quest): auto-discover Mac IP before viewer Connect click - #16
Merged
Conversation
…empty On-device diagnosis against a live Quest session showed two reasons the viewer sat empty even though the Unity sender app was running and the adapters were "connected": 1. Quest sender wasn't reaching the Mac's UDP :14043 at all. The Quest app ships with a hardcoded default target IP of ``172.30.1.51`` (a dev LAN from the original project template) and relies on auto-discovery to find the recorder at runtime. MetaQuestHandStream never responded to those discovery probes, so the Quest kept firing UDP into the void while the viewer cheerfully said "connected" (one stale packet from an old session had set the heartbeat). Add a background UDP :14044 responder that replies to the ``SYNCFIELD_DISCOVER_RECORDER_V1`` broadcasts Unity's UDPTrackingSender already emits every 2 s. Reply shape matches the ``RecorderDiscoveryResponse`` parser in the Unity client. We pick the "right" local IP per responder by opening a scratch UDP socket toward the Quest's address and reading getsockname — no packets sent, but the kernel chooses the correct outbound interface, which is the interface the Quest should target. Single-process multi-Quest setups would fight over :14044, so a bind failure silently falls back to "manual IP only" with a log hint. Normal single-Quest use now auto-resolves. 2. MetaQuestCameraStream declared ``kind="video"`` but exposed only ``latest_frame_left`` / ``latest_frame_right``, not the ``latest_frame`` attribute the viewer's StreamSnapshot polls for every video stream. Result: the camera card rendered black even while MjpegPreviewConsumer was happily decoding JPEGs into the per-eye slots. Add a ``latest_frame`` property that returns the left eye (falling back to right) so the existing video panel lights up without any viewer-side changes. Phase-1 caveat still applies: both eyes get the primary-camera view until Meta XR 2.4 exposes per-eye acquisition cleanly (spec §9 Q1). Once that lands ``latest_frame`` can switch to a side-by-side composite. Co-Authored-By: Claude Opus 4.6 <[email protected]>
The Quest companion app broadcasts discovery probes on UDP :14044 from the moment it launches. Previously the responder was only started inside connect(), which SessionOrchestrator fires when the user clicks "Connect" in the viewer — so until that click, every probe went unanswered and the Quest HUD kept showing its stale default IP. Move the responder startup into __init__ so it runs as soon as the adapter is instantiated (i.e., at session.add() time). Guard the starter with an is_alive() check so connect()'s existing call becomes a safe no-op on the hot path but still restarts discovery after a disconnect/reconnect cycle. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…efore-connect # Conflicts: # src/syncfield/adapters/meta_quest.py
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.
Summary
__init__instead ofconnect()_start_discovery_responder()with anis_alive()check so the existingconnect()call is a safe no-op on the hot path but still restarts after adisconnect()Why
The Quest companion app starts broadcasting
SYNCFIELD_DISCOVER_RECORDER_V1probes the moment it launches. Before this fix, the responder was gated behindSessionOrchestrator.connect()— which only fires when the user clicks Connect in the viewer. That meant every probe before the click went unanswered, and the Quest HUD kept showing its stale default IP. Users had to manually edit the IP on-device.Now the responder lives for the full lifetime of the adapter (from
session.add(...)onward), so Quest locks onto the Mac automatically with no extra clicks.Test Plan
pytest tests/unit/adapters/test_meta_quest.py)MetaQuestHandStream(...)instantiation — responder answers within milliseconds,disconnect()tears down cleanlyexamples/meta_quest/record.pyon Mac, open Quest app, confirm HUD flips from default IP to Mac IP within a few seconds without clicking viewer Connect🤖 Generated with Claude Code