I am running this ARKit example project https://developer.apple.com/documentation/arkit/creating_a_collaborative_session. Everything works perfectly, except that the ARParticipantAnchor
's transform is always NaN (all 16 numbers in the transform matrix are NaN). Other ARAnchor
s all have a valid transform value but ARParticipantAnchor
doesn't.
From my understanding of ARKit, after a peer iPhone joined the collaboration session, an ARParticipantAnchor
is added through the delegate function session:didAddAnchors:
to represent the location and orientation of that peer. After that, ARKit keeps updating that ARParticipantAnchor
's transform through the delegate function session:didUpdateAnchors:
to minor the real-time location and orientation of that peer's iPhone.
I have run this sample project several months ago and it went perfectly. So I am pretty confident that I am not missing any detail. But from yesterday, I could not make it work. An ARParticipantAnchor
was successfully added after a peer had joined the collaboration session, and the delegate function session:didUpdateAnchors:
was called every frame, but the ARParticipantAnchor
's transform in session:didUpdateAnchors:
was always NaN!
I also tried the Unity ARFoundation samples in this repo https://github.com/Unity-Technologies/arfoundation-samples/tree/main/Assets/Scenes/ARKit/ARCollaborationData, and it doesn't work either! I have used this repo several months ago and I am pretty sure it worked.
So, if both native ARKit and Unity have this problem, I suspect that probably there is a bug in ARParticipantAnchor
after a recent ARKit update? After all, if ARParticipantAnchor
's transform is always NaN, what is the point to update it every frame and share that data through the network? Could anyone tell me how to make it work? Thanks!
Ok, I have found the answer. It was because of the iOS version.
I was using iOS 15.1 previously. After upgrading all my devices to iOS Beta 15.2, they worked perfectly. I even didn't rebuild the app, all I did was upgrading the iOS version.
The interesting thing is that, when I was mixing these two iOS versions together (say device A was iOS 15.1 and device B was iOS 15.2), I could see device B's ARParticipantAnchor
in device A's screen but I could not see device A's ARParticipantAnchor
in device B's screen. The problem seems to be that ARKit under iOS 15.1 could not output ARCollaborationData
with proper ARParticpantAnchor
transform information, so the receiver device could not interpret that data correctly.