Skip to content

Rewrite iOS BLE relay uploads to loopback for the local photo receiver - #3615

Open
PhilippeFerreiraDeSousa wants to merge 1 commit into
devfrom
pferreira/os-1796-ios-loopback-parity
Open

Rewrite iOS BLE relay uploads to loopback for the local photo receiver#3615
PhilippeFerreiraDeSousa wants to merge 1 commit into
devfrom
pferreira/os-1796-ios-loopback-parity

Conversation

@PhilippeFerreiraDeSousa

@PhilippeFerreiraDeSousa PhilippeFerreiraDeSousa commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Scope

Part 1 of OS-1796 (plan: agents/os-1796-ble-photo-phone-delivery-plan.md on 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 LocalPhotoUploadServer to 127.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.uploadToWebhook posted to the literal LAN URL, which fails whenever the phone isn't reachable at that address.

  • New ios/Source/LocalPhotoReceiverRegistry.swift, a 1:1 port of the Java registry semantics (http/https + /upload path match on scheme/host/effective-port/query/fragment, host rewritten to 127.0.0.1). Placed in Source/ because BlePhotoUploadService compiles in both SDK build shapes, while the receiver module is expo-adapter-only.
  • MentraPhotoReceiverModule registers the upload URL at both receiver-start return points and unregisters on stop/OnDestroy, matching the Android module.
  • uploadToWebhook resolves the effective URL through the registry and logs when the rewrite fires, mirroring the Android relay.

Notes

  • MentraPhotoReceiverModule.swift picked up a whole-file swiftformat pass (repo .swiftformat config; the file predated it) — the functional change there is only the three registry calls.
  • Test evidence: swiftc -parse on 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 via 127.0.0.1 instead of a stale Wi‑Fi address.

Adds LocalPhotoReceiverRegistry (Swift port of the Java registry): register/unregister active /upload URLs, and loopbackUploadUrl(for:) to rewrite matching webhook URLs to loopback while preserving port/path/query.

MentraPhotoReceiverModule registers the upload URL when the receiver starts (both code paths) and unregisters on stop/OnDestroy.

MentraLive.uploadToWebhook resolves the effective URL through the registry before POSTing and logs when a loopback rewrite is used.

MentraPhotoReceiverModule.swift also 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.

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.
@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

📋 PR Review Helper

📱 Mobile App Build

Ready to test! (commit 2c82769)

📥 Download APK

🕶️ ASG Client Build

Waiting for build...


🔀 Test Locally

gh pr checkout 3615

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