Rewrite iOS BLE relay uploads to loopback for the local photo receiver - #3615
Open
PhilippeFerreiraDeSousa wants to merge 1 commit into
Open
Rewrite iOS BLE relay uploads to loopback for the local photo receiver#3615PhilippeFerreiraDeSousa wants to merge 1 commit into
PhilippeFerreiraDeSousa wants to merge 1 commit into
Conversation
The Android BLE fallback relay rewrites webhook URLs that target the in-process photo receiver to 127.0.0.1 (LocalPhotoReceiverRegistry), so BLE-relayed photos reach the receiver even when the phone is off Wi-Fi or its LAN address went stale. iOS had no equivalent: the relay posted to the literal LAN URL and failed off-network. Port the registry to Swift (in Source/ so the always-built BlePhotoUploadService can use it in both SDK build shapes), register the receiver's upload URL on start and clear it on stop, and resolve the effective URL before the relay upload. MentraPhotoReceiverModule picked up a whole-file swiftformat pass with the repo config.
Contributor
📋 PR Review Helper📱 Mobile App Build✅ Ready to test! (commit 🕶️ ASG Client Build⏳ Waiting for build... 🔀 Test Locallygh pr checkout 3615 |
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.
Scope
Part 1 of OS-1796 (plan:
agents/os-1796-ble-photo-phone-delivery-plan.mdon the follow-up branches). Standalone bug fix: iOS/Android parity for the photo-receiver loopback rewrite.The Android BLE fallback relay rewrites webhook URLs that target the in-process
LocalPhotoUploadServerto127.0.0.1(LocalPhotoReceiverRegistry.loopbackUploadUrlFor), so BLE-relayed photos reach the app's own receiver even when the phone is off Wi-Fi or its LAN address changed after registration. iOS had no equivalent —BlePhotoUploadService.uploadToWebhookposted to the literal LAN URL, which fails whenever the phone isn't reachable at that address.ios/Source/LocalPhotoReceiverRegistry.swift, a 1:1 port of the Java registry semantics (http/https +/uploadpath match on scheme/host/effective-port/query/fragment, host rewritten to127.0.0.1). Placed inSource/becauseBlePhotoUploadServicecompiles in both SDK build shapes, while the receiver module is expo-adapter-only.MentraPhotoReceiverModuleregisters the upload URL at both receiver-start return points and unregisters on stop/OnDestroy, matching the Android module.uploadToWebhookresolves the effective URL through the registry and logs when the rewrite fires, mirroring the Android relay.Notes
MentraPhotoReceiverModule.swiftpicked up a whole-file swiftformat pass (repo.swiftformatconfig; the file predated it) — the functional change there is only the three registry calls.swiftc -parseon the new file; on-device iOS verification (example app photo receiver, phone off Wi-Fi, BLE relay) still to be run and will be posted before merge.Note
Medium Risk
Touches photo upload routing in the BLE/SGCS path; wrong URL matching could misroute uploads, but scope is narrow and mirrors proven Android behavior.
Overview
Brings iOS in line with Android for BLE fallback photo delivery to the in-app
LocalPhotoUploadServer. Glasses still get a LAN URL, but when the phone relays over BLE it can hit the same receiver via127.0.0.1instead of a stale Wi‑Fi address.Adds
LocalPhotoReceiverRegistry(Swift port of the Java registry): register/unregister active/uploadURLs, andloopbackUploadUrl(for:)to rewrite matching webhook URLs to loopback while preserving port/path/query.MentraPhotoReceiverModuleregisters the upload URL when the receiver starts (both code paths) and unregisters on stop/OnDestroy.MentraLive.uploadToWebhookresolves the effective URL through the registry before POSTing and logs when a loopback rewrite is used.MentraPhotoReceiverModule.swiftalso picked up a whole-file swiftformat pass; the behavioral change there is only the registry register/unregister calls.Reviewed by Cursor Bugbot for commit 2c82769. Bugbot is set up for automated code reviews on this repo. Configure here.