maxxfrazer / MultipeerHelper

A light swift wrapper around the iOS MultipeerConnectivity framework. Including an example project using RealityKit's MultipeerConnectivityService.
https://maxxfrazer.github.io/MultipeerHelper/documentation/multipeerhelper/
MIT License
104 stars 7 forks source link

Socket Connection Error #5

Closed aspdev91 closed 4 years ago

aspdev91 commented 4 years ago

Hi, first off, thanks for making this package as the abstraction substantially decreases the complexity of implementing collaboration in AR.

I'm running into this error on my iPad:

Metal API Validation Enabled
BrowserDelegate <MCPeerID: 0x281b707f0 DisplayName = Michael’s iPhone>
2020-02-22 17:15:55.464060-0500 virtual-estate[2555:367808] Compiler failed to build request
2020-02-22 17:15:55.464205-0500 virtual-estate[2555:367808] [Graphics] makeRenderPipelineState failed [output of type ushort is not compatible with a MTLPixelFormatR16Float color attachement.].
2020-02-22 17:15:55.464234-0500 virtual-estate[2555:367808] [Graphics] makeRenderPipelineState failed.
2020-02-22 17:15:56.626214-0500 virtual-estate[2555:368242] [] nw_resolver_start_query_timer_block_invoke [C2.3] Query fired: did not receive both families in time for 19003cc7-c970-4045-9c49-cf2f96965b4e.local.:50357@awdl0
2020-02-22 17:15:59.469842-0500 virtual-estate[2555:368133] [] nw_socket_handle_socket_event [C1:1] Socket SO_ERROR [54: Connection reset by peer]
2020-02-22 17:15:59.474126-0500 virtual-estate[2555:368133] [MCNearbyServiceAdvertiser] Data from peer [Michael’s iPhone,15600260] received with error Connection closed.
2020-02-22 17:16:00.699231-0500 virtual-estate[2555:367808] [Technique] Error getting pose for participant anchor: CMMapNotAvailable

I'm running the latest versions on my iPhone and iPad (13.3.1). They're both running on the same Wifi network. I also tried running my iPhone as a hotspot and my iPad connecting to it. Below is the code I used:


class ViewController: UIViewController {

    @IBOutlet var arView: ARView!
    let multipeerHelp = MultipeerHelper(
      serviceName: "climate-ar",
      sessionType: .both
    )

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

        let configuration = ARWorldTrackingConfiguration()

        configuration.isCollaborationEnabled = true

        configuration.environmentTexturing = .automatic

        self.arView.scene.synchronizationService = multipeerHelp.syncService

        self.arView.session.run(configuration)

    }

   override func viewDidLoad() {
        super.viewDidLoad()

   let artBookAnchor = try! Experience.loadArtBook()
  arView.scene.anchors.append(artBookAnchor)
   }
}
aspdev91 commented 4 years ago

I just noticed the example you have in the repo. Im going to try it later today and close out this issue if it works. Thanks :)

maxxfrazer commented 4 years ago

Hey, thanks for using the package! 🚀

If I had to guess, I'd say that the MultipeerHelper is being created too soon. Some of those errors (the graphics ones at least), I get every time I use something related to RealityKit or SceneKit. Also by the looks of your project, any device that connects might be adding their own artBookAnchor, which may not be what you want.

Let me know if the example does or doesn't work for you!

aspdev91 commented 4 years ago

Thanks for the feedback! I'll try it out right now and keep you posted on my findings.

aspdev91 commented 4 years ago

I tested the example and leveraged some of the code in my project. It works well!

I think this may be a shortcoming of ARKit itself and not your package, but I noticed the objects are not aligned between the two device. Also, I noticed the image anchors are no longer recognized. Usually, a shape would pop up on the image and that's no longer the case. Do you know if something more is required to get this working in multiuser?

Closing this issue because it was resolved by trying your example. Thanks!

maxxfrazer commented 4 years ago

I haven't actually tested this with image anchors at all. not sure how they work in a multipeer sessions, as it would typically be based on a world tracking configuration, not image tracking. I'd expect any image anchors that are added would need to be added on each device independently…

Send me a message on twitter if you have any more issues though, I'll be happy to help!