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

Example project not working #8

Closed s2mr closed 4 years ago

s2mr commented 4 years ago

Hi! Thanks great some repository, and articles always.

I tried this project's example with two real devices. But not working. Of course, Can you work it yourselves? Specifically, Entity can not synchronization.

This is my situation.

- Two devices is connected each other. (Turned on Bluetooth and Wi-fi both of them)
- I tap screen on Device1, and put red box on surface, But in Device2 not appeared the box.

Device info
- Device1: iOS 13.3.1, iPhone Xs Max
- Device2: iOS14.0 beta, iPhoneX

This is log of Device2 (Receiver of red box)

2020-06-29 22:52:13.521758+0900 MultipeerHelper+Example[67559:1883010] Metal GPU Frame Capture Enabled
2020-06-29 22:52:13.521980+0900 MultipeerHelper+Example[67559:1883010] Metal API Validation Enabled
2020-06-29 22:52:14.414965+0900 MultipeerHelper+Example[67559:1883010] Compiler failed to build request
2020-06-29 22:52:14.415091+0900 MultipeerHelper+Example[67559:1883010] [Graphics] makeRenderPipelineState failed [output of type ushort is not compatible with a MTLPixelFormatR16Float color attachement.].
2020-06-29 22:52:14.415117+0900 MultipeerHelper+Example[67559:1883010] [Graphics] makeRenderPipelineState failed.
2020-06-29 22:52:14.555203+0900 MultipeerHelper+Example[67559:1883365] [Technique] World tracking performance is being affected by resource constraints [3]
2020-06-29 22:52:14.555255+0900 MultipeerHelper+Example[67559:1883365] [Technique] VIO error callback: 222737.830150, 3, Frame time stamps are either out of order or repeating
BrowserDelegate <MCPeerID: 0x280db4350 DisplayName = Kazumasa>
2020-06-29 22:52:14.869577+0900 MultipeerHelper+Example[67559:1883365] [Technique] VIO error callback: 222738.129133, 3, Frame time stamps are either out of order or repeating
2020-06-29 22:52:15.007852+0900 MultipeerHelper+Example[67559:1883365] libMobileGestalt MobileGestalt.c:5777: Taking legacy CameraOffset_2D path
2020-06-29 22:52:15.008189+0900 MultipeerHelper+Example[67559:1883365] libMobileGestalt MobileGestalt.c:5777: Taking legacy CameraOffset_2D path
2020-06-29 22:52:15.734233+0900 MultipeerHelper+Example[67559:1883263] [] nw_resolver_start_query_timer_block_invoke [C1.3] Query fired: did not receive both families in time for 35780577-a78c-49fa-a6f0-d94f50ecb914.local.:64971@awdl0
new peer has joined: Kazumasa
㶒峍ꏝ犢」潭⹡灰汥⹲敫楴⹨敬汯
2020-06-29 22:52:16.245227+0900 MultipeerHelper+Example[67559:1883010] [Network] Mismatched protocol, received 0x6 expecting 0x5
2020-06-29 22:52:16.245310+0900 MultipeerHelper+Example[67559:1883010] [Network] Received corrupt message from 'YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMSAAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGkCwwTFFUkbnVsbNMNDg8QERJUbmFtZVJpZFYkY2xhc3OAAhOQzGr4j2RaRYADWEthenVtYXNh0hUWFxhaJGNsYXNzbmFtZVgkY2xhc3Nlc1hNQ1BlZXJJRKIXGVhOU09iamVjdAgRGiQpMjdJTFFTWF5lam10dn+Bio+ao6yvAAAAAAAAAQEAAAAAAAAAGgAAAAAAAAAAAAAAAAAAALg='. Disconnecting.
2020-06-29 22:52:16.245374+0900 MultipeerHelper+Example[67559:1883010] [Network] Attempt to receive data from connection 'YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMSAAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGkCwwTFFUkbnVsbNMNDg8QERJUbmFtZVJpZFYkY2xhc3OAAhOQzGr4j2RaRYADWEthenVtYXNh0hUWFxhaJGNsYXNzbmFtZVgkY2xhc3Nlc1hNQ1BlZXJJRKIXGVhOU09iamVjdAgRGiQpMjdJTFFTWF5lam10dn+Bio+ao6yvAAAAAAAAAQEAAAAAAAAAGgAAAAAAAAAAAAAAAAAAALg=' that is disconnected
2020-06-29 22:52:25.803059+0900 MultipeerHelper+Example[67559:1883304] [GCKSession] Not in connected state, so giving up for participant [0F645A45] on channel [0].
2020-06-29 22:52:25.812846+0900 MultipeerHelper+Example[67559:1883304] [GCKSession] Not in connected state, so giving up for participant [0F645A45] on channel [1].
2020-06-29 22:52:25.822362+0900 MultipeerHelper+Example[67559:1883304] [GCKSession] Not in connected state, so giving up for participant [0F645A45] on channel [2].
2020-06-29 22:52:25.833197+0900 MultipeerHelper+Example[67559:1883304] [GCKSession] Not in connected state, so giving up for participant [0F645A45] on channel [5].
2020-06-29 22:52:25.840927+0900 MultipeerHelper+Example[67559:1883304] [GCKSession] Not in connected state, so giving up for participant [0F645A45] on channel [6].
hello! from Kazumasa
hello! from Kazumasa
hello! from Kazumasa
2020-06-29 22:52:45.765924+0900 MultipeerHelper+Example[67559:1883285] [Graphics] Failed to find reflection for buffer clusterIndexTable

Can you solve this problem?

maxxfrazer commented 4 years ago

Thanks for the issue! I'll check this out; I haven't yet tried out this package on iOS 14.0, but have had issues previously when the device name (gathered from UIDevice.current.name) contains chars that do not conform to the allowed peerID, found here: https://developer.apple.com/documentation/multipeerconnectivity/mcpeerid/1407089-init

Summarised with: The maximum allowable length is 63 bytes in UTF-8 encoding.

s2mr commented 4 years ago

Thanks for your rapidly information. By your word, I read your library codes, found UIDevice.current.name in argument peerName. So I rewrite peerName instead of implicit nil, "\(Int(Date().timeIntervalSince1970))" and run.

Before

    multipeerHelp = MultipeerHelper(
      serviceName: "helper-test",
      sessionType: .both,
      delegate: self
    )

After

    multipeerHelp = MultipeerHelper(
      serviceName: "helper-test",
      sessionType: .both,
      peerName: "\(Int(Date().timeIntervalSince1970))",
      delegate: self
    )

The log is changed from previous it. It's worth noting that the illegal string 㶒峍ꏝ犢」潭⹡灰汥⹲敫楴⹨敬汯 I mentioned earlier has been removed。 But not working yet. 🤔

2020-06-29 23:56:12.089548+0900 MultipeerHelper+Example[12568:1844649] Metal GPU Frame Capture Enabled
2020-06-29 23:56:12.091231+0900 MultipeerHelper+Example[12568:1844649] Metal API Validation Enabled
Json Parse Error line 22: Json Deserialization; unknown member 'EnableGuidedFilterOcclusion' - skipping.
2020-06-29 23:56:14.781917+0900 MultipeerHelper+Example[12568:1844744] libMobileGestalt MobileGestalt.c:6131: Taking legacy CameraOffset_2D path
2020-06-29 23:56:14.782874+0900 MultipeerHelper+Example[12568:1844744] libMobileGestalt MobileGestalt.c:6131: Taking legacy CameraOffset_2D path
BrowserDelegate <MCPeerID: 0x28318c2b0 DisplayName = 1593442575>
new peer has joined: 1593442575
2020-06-29 23:56:16.350787+0900 MultipeerHelper+Example[12568:1844649] [Network] Mismatched protocol, received 0x5 expecting 0x6
2020-06-29 23:56:16.351009+0900 MultipeerHelper+Example[12568:1844649] [Network] Received corrupt message from 'YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMSAAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGkCwwTFFUkbnVsbNMNDg8QERJUbmFtZVJpZFYkY2xhc3OAAhON4mbTcRRyRIADWjE1OTM0NDI1NzXSFRYXGFokY2xhc3NuYW1lWCRjbGFzc2VzWE1DUGVlcklEohcZWE5TT2JqZWN0CBEaJCkyN0lMUVNYXmVqbXR2f4GMkZylrrEAAAAAAAABAQAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAug=='. Disconnecting.
2020-06-29 23:56:16.351066+0900 MultipeerHelper+Example[12568:1844649] [Network] Attempt to receive data from connection 'YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMSAAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGkCwwTFFUkbnVsbNMNDg8QERJUbmFtZVJpZFYkY2xhc3OAAhON4mbTcRRyRIADWjE1OTM0NDI1NzXSFRYXGFokY2xhc3NuYW1lWCRjbGFzc2VzWE1DUGVlcklEohcZWE5TT2JqZWN0CBEaJCkyN0lMUVNYXmVqbXR2f4GMkZylrrEAAAAAAAABAQAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAug==' that is disconnected
2020-06-29 23:56:25.963994+0900 MultipeerHelper+Example[12568:1844708] [GCKSession] Not in connected state, so giving up for participant [71147244] on channel [0].
2020-06-29 23:56:25.975565+0900 MultipeerHelper+Example[12568:1844708] [GCKSession] Not in connected state, so giving up for participant [71147244] on channel [1].
2020-06-29 23:56:25.986432+0900 MultipeerHelper+Example[12568:1844708] [GCKSession] Not in connected state, so giving up for participant [71147244] on channel [2].
2020-06-29 23:56:28.796853+0900 MultipeerHelper+Example[12568:1844699] [Graphics] Failed to find reflection for buffer clusterIndexTable
hello! from 1593442575

Sorry for the confusing example, but the other device has a different peer ID, and the other device is properly measure. 1593442572

maxxfrazer commented 4 years ago

Looks like this could be a bigger issue… I've opened a FB item about it after testing that Apple's own Collaborative Session example doesn't work anymore with iOS 14: https://developer.apple.com/documentation/arkit/creating_a_collaborative_session

Will update here if I hear anything or if anything else I try manages to fix it, thanks a lot for flagging this!

s2mr commented 4 years ago

Thanks investigating. Strangely enough, Apple's example is worked with above device combination. (iOS13.5.1, iOS14 beta)

But Apple's example uses ARKit's collaborating implementation not RealityKit such as using Delegate func session(_ session: ARSession, didOutputCollaborationData data: ARSession.CollaborationData). So different to this project structure.

I thought this problem is caused by iOS14 beta by your word. So, I reverted my iPhoneX to iOS13.5.1 and tried. But now, Apple's example and this project's example both not worked. Run apple's example, after shows snack bar A peer wants to join the experience. Hold the phones next to each other., and shows A peer has left the shared experience I don't get it.

I'm going to try different things. Thanks for everything.

maxxfrazer commented 4 years ago

It looks like that Sample I sent you has been edited on June 16th, and the local version I have is older than that!

I'll investigate the changes and hopefully it will be mystery solved 🙌

maxxfrazer commented 4 years ago

@s2mr I found a couple of additional things added to the plist for bonjour services which now allows the two devices to connect - however the scenes do not sync automatically, only messages can manually be sent between devices for now.

Created a pull request for the fix so far: https://github.com/maxxfrazer/MultipeerHelper/pull/9

s2mr commented 4 years ago

Oh, thanks your rapidly support! I'll check it.