Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Deserialization succeeds but 0 anchors in batch

Discussion in 'VR' started by sebrk_hiq, Oct 3, 2017.

  1. sebrk_hiq

    sebrk_hiq

    Joined:
    Jul 10, 2017
    Posts:
    23
    So I've been transferring a serialized anchor using TCP. I have been debugging this issue and I know the received bytes are exactly the same as on the sender.

    However, when I import the data and the subsequent OnDeseralizationComplete handler is called it says it has succeeded BUT looking at the deserialized batch, it contains 0 anchors.

    It worked once I think but that is about it. How should I proceed with debugging? I can't think of anything else than this being a bug somewhere in Unity? How can it succeed but still contain 0 anchors?

    I'm using 2017.1.1.f1
     
    Last edited: Oct 3, 2017
  2. unity_andrewc

    unity_andrewc

    Unity Technologies

    Joined:
    Dec 14, 2015
    Posts:
    228
    Not sure what you mean by succeeding but containing zero anchors in terms of what exact APIs you're calling, as I haven't played around with that part of the API much. Feel free to leave more detail so I can double-check or look into this more, but I would assume that success with zero anchors means that you haven't actually placed any anchors for it to send in the first place. Keep in mind that anchors only persist in the same app, so if you started a new project, or even if you're in the same project but placing anchors when remoting and transferring them in a built app (or vis versa), those are actually different apps, so they don't share anchors.
     
  3. sebrk_hiq

    sebrk_hiq

    Joined:
    Jul 10, 2017
    Posts:
    23
    Thanks for you answer @unity_andrewc . Let me explain a bit more:

    The API call I'm doing is:

    Code (CSharp):
    1. WorldAnchorTransferBatch.ImportAsync(data, OnDeserializationComplete);

    According to documentation that calls the OnDeserializationComplete when it finishes. My method for this looks like so:

    Code (CSharp):
    1. private static void OnDeserializationComplete(SerializationCompletionReason completionreason,
    2.             WorldAnchorTransferBatch deserializedtransferbatch)
    3.         {
    4.             if (completionreason != SerializationCompletionReason.Succeeded)
    5.             {
    6.                 // Failed
    7.                 if (_retryCount > 0)
    8.                 {
    9.                     _retryCount--;
    10.                     WorldAnchorTransferBatch.ImportAsync(_exportedDataBuf, OnDeserializationComplete);
    11.                 }
    12.             }
    13.  
    14.             print("[Client]: Deserialization completed with: " + completionreason + " Number of anchors: " + deserializedtransferbatch.anchorCount);
    15.             if (deserializedtransferbatch.anchorCount > 0)
    16.             {
    17.                 AnchorImportedHandler(deserializedtransferbatch);
    18.                 HololensClient.Instance.SendToServer(TMsgType.Error, new TMessage() { Description = completionreason + ": " + deserializedtransferbatch.anchorCount});
    19.             }
    20.         }

    The print call here gives me this line in console:
    [Client]: Deserialization completed with: Succeeded Number of anchors: 0

    I cannot understand how the deserialization can succeed if there are no anchors included. I should say that the sender lists the batch with 1 anchor correctly berfore sending it using TCP. I have even printed out the last 200 bytes from the sender and the receiver and they match exactly. Any clues?

    This is all in the same app and should happen in runtime. I'm using UNET for messaging and a custom TCP client/server to do the hauling. Note that this is before actually placing/locking anything. In order to do that I need a reference to the actual anchor :)

    Testing is done on two Hololenses. No remoting.

    Edit: how do I format code?


     
    Last edited: Oct 4, 2017
  4. unity_andrewc

    unity_andrewc

    Unity Technologies

    Joined:
    Dec 14, 2015
    Posts:
    228
    That sounds like it's probably a bug. Before asking you to file one for us to investigate, though, would you mind double-checking this one thing for me: if you place more WorldAnchors using the HoloLens that's sending the batch before you send them (instead of just the one WorldAnchor), does the number of bytes you send to the other HoloLens increase? It might be that you need aren't serializing them correctly in the first place. Like I said, I personally haven't dabbled much with this particular bit of the API we provide, but I do remember the number of bytes to send across the wire can increase pretty dramatically with more anchors.

    (Re: formatting code: Click the "Insert" button, there's a "Code" selection in the drop-down there to do the tags for you.)
     
  5. sebrk_hiq

    sebrk_hiq

    Joined:
    Jul 10, 2017
    Posts:
    23
    That is not really how it works though. The spatial information is constantly adding up in the internals of the Hololens. Thus the more you actually use it, i.e. scan the room, the bigger the achors tend to get. It is never a static size if that is what you mean? More anchors would probably size it up quite a bit, especially if the placement is not in the same room but in a completely different place. But even using only one anchor I've seen anything from 300k to 12 MB. The "trick" is to reset the space, which can be done in Hololens settings. I've verified this with Hololens Forums.

    Should I still try this or should I file a bug? Not sure if that is actually going to add anything.
     
    Last edited: Oct 4, 2017
  6. unity_andrewc

    unity_andrewc

    Unity Technologies

    Joined:
    Dec 14, 2015
    Posts:
    228
    What you said is correct - sorry, didn't mean to just place them all in the same square foot or so. Take some time, scan more of the room or even another room, and place the anchors relatively far apart. I just want to double-check that the transfer batch you're sending isn't just a payload of a header plus some other data that's useless without any actual anchors around, and adding more anchors before attempting to transfer and checking for changes in data size is a good way to check for that / whether the serialization was done correctly.
     
  7. sebrk_hiq

    sebrk_hiq

    Joined:
    Jul 10, 2017
    Posts:
    23
    I doubt it is. First I'm getting a successful export and then a successful import (but no anchors). Important to note is that the export does indeed list one anchor with the correct id and everything (and the data seems to be the same on both ends comparing binaries)
     
    Last edited: Oct 3, 2017
  8. unity_andrewc

    unity_andrewc

    Unity Technologies

    Joined:
    Dec 14, 2015
    Posts:
    228
    Then yeah, that sounds like a bug to me. Mind filing a bug then? Prefixing the title with "[HoloLens]" will help ensure it goes through the system and gets to our team as quickly as possible.
     
  9. sebrk_hiq

    sebrk_hiq

    Joined:
    Jul 10, 2017
    Posts:
    23
    OK will do
     
  10. sebrk_hiq

    sebrk_hiq

    Joined:
    Jul 10, 2017
    Posts:
    23
    OK @unity_andrewc I filed the report on friday. If you have any questions about the implementation feel free to reach out to me.