How iOS 12 Shares AR World Maps Between Devices

In iOS 12, Apple introduced collaborative augmented reality (AR) by allowing devices to synchronize spatial tracking through ARKit 2 and the MultipeerConnectivity framework. This system enables one device to serialize its mapped physical environment into a portable data object called an ARWorldMap, transmit it across a local peer-to-peer connection, and allow a recipient device to relocalize against the identical spatial coordinate system.

Capturing the Environment with ARWorldMap

An iOS device running an ARSession continuously analyzes camera feeds and device motion through Visual Inertial Odometry (VIO). Over time, the device builds a reference library of the environment consisting of feature point clouds, extent data, and known spatial anchors.

When a user initiates sharing, the host device queries its session using the getCurrentWorldMap(completionHandler:) method. ARKit freezes the current state of spatial understanding and packages it into an ARWorldMap object. This object contains:

  • A 3D point cloud of detected physical feature points.
  • A collection of all added ARAnchor objects (virtual content placement markers).
  • Raw feature descriptors that uniquely identify physical landmarks in the space.

Data Serialization

Because ARWorldMap conforms to the NSSecureCoding protocol, it can be converted into a binary format suitable for network transfer. The host device uses NSKeyedArchiver to serialize the ARWorldMap instance into raw Data.

let data = try NSKeyedArchiver.archivedData(withRootObject: worldMap, requiringSecureCoding: true)

Depending on the complexity and scale of the mapped space, this data payload typically ranges from a few hundred kilobytes to several megabytes.

Peer-to-Peer Transmission via MultipeerConnectivity

To share this data without requiring an external internet server, iOS 12 utilizes the MultipeerConnectivity framework. This framework automatically determines the optimal physical transport layer—such as peer-to-peer Wi-Fi, shared Wi-Fi networks, or Bluetooth—to connect nearby devices.

  1. Discovery and Handshake: The host advertises its presence using MCNearbyServiceAdvertiser, while guest devices look for sessions using MCNearbyServiceBrowser.
  2. Session Establishment: Once paired, the devices join an MCSession.
  3. Payload Transfer: The host sends the serialized map data to connected peers using the reliable delivery mode (MCSessionSendDataMode.reliable), ensuring no packets are dropped during transmission.

Deserialization and Relocalization

Upon receiving the binary payload via the MCSessionDelegate, the peer device deserializes the data back into an ARWorldMap instance using NSKeyedUnarchiver:

let worldMap = try NSKeyedUnarchiver.unarchivedObject(ofClass: ARWorldMap.self, from: data)

The guest device then updates its tracking settings by creating a new ARWorldTrackingConfiguration, assigning the received map to the initialWorldMap property, and resetting its local ARSession:

let configuration = ARWorldTrackingConfiguration()
configuration.initialWorldMap = worldMap
sceneView.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])

Once the configuration runs, the guest device enters a relocalizing tracking state. The user points the camera around the room so ARKit can match the incoming camera feed's visual features against the descriptors embedded inside the received ARWorldMap. As soon as a sufficient number of matching landmarks are recognized, ARKit aligns the local device's coordinate space with the host’s coordinate space, enabling both users to view and interact with virtual content at the exact same physical coordinates.