Uncaught exception when using MultipeerConnectivityService

I'm attempting to use the MultipeerConnectivityService as the synchronizationService for an ARView scene, but when I add a scene loaded from a RealityKit file, the app immediately crashes with an NSInvalidArgumentException:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPlaceholderString initWithString:]: nil argument'

*** First throw call stack:

(0x1b0e5fac4 0x1b0b7b4fc 0x1b116daec 0x1e5f988f8 0x1e5ff60c0 0x1e5f9ffd8 0x1be78f99c 0x1be7878a4 0x1da272dc8 0x1da272e40 0x1be9ffc64 0x1e5f90440 0x1e5f8ed50 0x1e6093814 0x1da273e30 0x1da27400c 0x1da274a3c 0x1da273b44 0x1cbece000 0x1cbc33374 0x1cbc41c9c 0x1cbc6ac88 0x1cbabf3c4 0x1cbac0948 0x1cbe97d94 0x1cbe97ce4 0x1cbe9826c 0x1cbe96b74 0x1cbe97408 0x1b77fcfb8 0x1b78caddc 0x1b0db10bc 0x1b0ddb7b8 0x1b0ddae90 0x1b0dd5aec 0x1b0dd4f64 0x1bb3f1534 0x1b4e78eb8 0x1042bd9f4 0x1b0c56764)

libc++abi.dylib: terminating with uncaught exception of type NSException

The following code is enough to get it to crash, where the `Experience` reality file is the one from the initial AR project code in Xcode:

      // Setup the AR configuration
      let configuration = ARWorldTrackingConfiguration()
      configuration.isCollaborationEnabled = true
      arView.session.run(configuration)

      // Setup the synchronization service
      session = MCSession(peer: myPeerID, securityIdentity: nil, encryptionPreference: .required)
      arView.scene.synchronizationService = try? MultipeerConnectivityService(session: session)

      // Load the "Box" scene from the "Experience" Reality File
      let boxAnchor = try! Experience.loadBox()

      // Add the box anchor to the scene
      arView.scene.anchors.append(boxAnchor)


If I add a simple model loaded from a usdz file, it doesn't crash.


I'm assuming the exception is occuring when the service attempts to serialise the scene/anchor.


Am I missing something that I should be doing or is this a problem with RealityKit?

Answered by loftyb in 372810022

Updating to the latest beta 4 (17A5534f) resolves this crash.

are you able to add some animation usdz to reality composer and compile? i'm having similar issues.

I hadn't got to adding anything complex via reality composer. I was focusing on getting a shared experience working first. I've found that updating to the latest beta (17A5534f) doesn't have this problem.

Accepted Answer

Updating to the latest beta 4 (17A5534f) resolves this crash.

Uncaught exception when using MultipeerConnectivityService
 
 
Q