Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.
Options

WorldAnchorTransferBatch.GetAllIds returning nothing

I'm currently saving a world anchor I'm making like this:

//on save request, object is both anchored and located.
WorldAnchorTransferBatch transferBatch = new WorldAnchorTransferBatch();
transferBatch.AddWorldAnchor("GameRootAnchor",worldAnchorObj.GetComponent<WorldAnchor>());
WorldAnchorTransferBatch.ExportAsync(transferBatch, OnExportDataAvailable, OnExportComplete);

I take all the packets from OnExportDataAvailable and stitch them together into a single array. Then, later on, I try and import the packets like this:

importAnchorAttemptCount = 10;
WorldAnchorTransferBatch.ImportAsync(receivedAnchorData, OnImportComplete);

When OnImportComplete is called shortly after I get a successful completionReason, but when I call GetAllIds to try and pull the single world anchor out, there's nothing there. GetAllIds has no items in the array, despite being the same data I just exported and definitely containing a world anchor (or at least, it should).

Basically my two questions are - why am I getting a successful import if it wasn't successful, and if it was successful why is there no ids in my deserialized batch?? As a final note, I guess it's not all that harmful because it's over a local network but the vast majority of all the bytes in my exported data appear to be 0s (about ~2MB is actual data). It could be that my data is getting corrupted somehow, but the amount of bytes matches exactly between send and receive and the batch is saying it was successful

Tagged:

Best Answer

  • Options
    ElspinElspin
    Answer ✓

    Alright, so I found out why it didn't work, but no clue why it told me it did work. Basically, the error wasn't in the network code that was transporting the data, but the original code that stitched together the fragments that slowly stream in from serializing the packet.

Answers

  • Options

    @Elspin, does this happen every time or occasionally? Export/import procedure is known to be somewhat unreliable (hence the retries) but it should work at least in some cases.

    This discussion may be helpful:
    https://forums.hololens.com/discussion/comment/12974#Comment_12974

    Building the future of holographic navigation. We're hiring.

  • Options

    @stepan_stulov said:
    @Elspin, does this happen every time or occasionally? Export/import procedure is known to be somewhat unreliable (hence the retries) but it should work at least in some cases.

    This discussion may be helpful:
    https://forums.hololens.com/discussion/comment/12974#Comment_12974

    I expected there to be some failures based on the example code, but the problem really isn't that it's failing, but that its saying it succeeded but giving me nothing. It does happen every time. Going to put some checksums in my code as the data is rather large and it's realistically possible that somehow the netcode is bungling some data I guess

  • Options
    stepan_stulovstepan_stulov ✭✭✭
    edited March 2017

    @Elspin, I'm assuming you checked but better safe than sorry, do you switch() over the deserializationCompletionReason that's passed into the callback?

    https://docs.unity3d.com/ScriptReference/VR.WSA.Sharing.SerializationCompletionReason.html

    If it reports Success and yet contains no world anchors that you're sure to have put there then it's indeed strange to say the least. I assume an extra safety mechanism would be to always put one guaranteed world anchors on top of you normal in-app anchors and check if it's there on import. If not, the best option you have left is retrying again really...

    Please keep us updated.

    Building the future of holographic navigation. We're hiring.

  • Options
    ElspinElspin
    edited March 2017

    @stepan_stulov said:
    @Elspin, I'm assuming you checked but better safe than sorry, do you switch() over the deserializationCompletionReason that's passed into the callback?

    https://docs.unity3d.com/ScriptReference/VR.WSA.Sharing.SerializationCompletionReason.html

    If it reports Success and yet contains no world anchors that you're sure to have put there then it's indeed strange to say the least. I assume an extra safety mechanism would be to always put one guaranteed world anchors on top of you normal in-app anchors and check if it's there on import. If not, the best option you have left is retrying again really...

    Please keep us updated.

    My code is almost exactly identical to this from the unity docs:

    private void OnImportComplete(SerializationCompletionReason completionReason, WorldAnchorTransferBatch deserializedTransferBatch)
    {
        if (completionReason != SerializationCompletionReason.Succeeded)
        {
            Debug.Log("Failed to import: " + completionReason.ToString());
            if (retryCount > 0)
            {
                retryCount--;
                WorldAnchorTransferBatch.ImportAsync(fileData, OnImportComplete);
            }
            return;
        }
    ​
        string[] ids = deserializedTransferBatch.GetAllIds();
        foreach (string id in ids)
        {
            GameObject gameObject = GetGameObjectFromAnchorId(id);
            if (gameObject != null)
            {
                transferBatch.LockObject(id, gameObject);
            }
            else
            {
                Debug.Log("Failed to find object for anchor id: " + id);
            }
        }
    }
    

    except the foreach is never called despite printing a successful completion reason.

    To add to my earlier comment, I have checked an MD5 hash of the exported and imported data and it's identical, so I suppose it's not that?

  • Options
    ElspinElspin
    Answer ✓

    Alright, so I found out why it didn't work, but no clue why it told me it did work. Basically, the error wasn't in the network code that was transporting the data, but the original code that stitched together the fragments that slowly stream in from serializing the packet.

Sign In or Register to comment.