How ARKit 2 Enables Shared AR on iOS 12

ARKit 2 introduced multi-user augmented reality capabilities to iOS 12, allowing multiple devices to view and interact with the same virtual content simultaneously. This article explains the underlying architecture that powers these shared experiences, focusing on spatial mapping, data serialization with ARWorldMap, relocalization, and peer-to-peer networking.

World Mapping and the ARWorldMap Object

The foundation of shared AR in ARKit 2 is the ARWorldMap class. During an active AR session, the host device uses visual-inertial odometry (VIO) to detect physical surfaces, feature points, and real-world lighting conditions. ARKit packages this spatial snapshot—including tracked 3D feature points and placed virtual anchors—into an ARWorldMap instance. This object represents the device's understanding of its physical environment at a specific moment in time.

Serialization and Network Transmission

Because ARWorldMap conforms to the NSSecureCoding protocol, it can be serialized into raw binary data using NSKeyedArchiver. Once converted into data, it can be transmitted across a network to other iOS 12 devices.

Developers typically use Apple's MultipeerConnectivity framework for direct, low-latency peer-to-peer Wi-Fi or Bluetooth connections without requiring an external server. However, the data can also be sent over standard web sockets or cloud-based backends for remote or broader multiplayer setups.

Relocalization on Peer Devices

Once a secondary (guest) device receives the serialized ARWorldMap, it deserializes the object and applies it to its own ARWorldTrackingConfiguration as the initialWorldMap.

The guest device then begins a process called "relocalization." The camera on the guest device scans the surrounding room, attempting to match its live visual feature points with the feature points stored in the received world map. Once ARKit detects a sufficient number of matching landmarks, the guest device synchronizes its local coordinate system with the host's coordinate system.

Real-Time Interaction and Anchor Synchronization

Synchronizing the world map establishes a shared origin point (0,0,0) in 3D space, but it does not automatically transmit live updates. To maintain an active multiplayer experience:

  1. Shared Anchors: When a user places or moves an object, the device creates or updates an ARAnchor.
  2. State Updates: Custom network packets carrying the anchor's transformation matrix (position and orientation) or game state data are broadcast to connected peers.
  3. Local Rendering: Receiving devices update their local SceneKit or Metal scene graphs accordingly, ensuring all participants see identical actions occur in the exact same physical locations in real time.