Search Unity

Third Party Mirror on Android OnSerialize failed

Discussion in 'Multiplayer' started by iGoA, Nov 11, 2021.

  1. iGoA

    iGoA

    Joined:
    Aug 23, 2020
    Posts:
    22
    I've made a multiplayer game with Mirror which works well on windows. Now I've built it for android and tried to run it on my smartphone, but it didn't work. The app starts, the menu shows up, I can start a game (local), but nothing spawns (no player character, no monsters). LogCat is shows many of these errors:

    11-11 19:37:40.644: E/Unity(15273): OnSerialize failed for: object=PlayerInfo(Clone) component=PlayerInfo sceneId=0
    11-11 19:37:40.644: E/Unity(15273): System.NullReferenceException: Object reference not set to an instance of an object
    11-11 19:37:40.644: E/Unity(15273): at Mirror.NetworkWriter.WriteBlittable[T] (T value) [0x00027] in <cbf6389b52654f31bb9df7969869197b>:0
    11-11 19:37:40.644: E/Unity(15273): at Mirror.NetworkWriterExtensions.WriteSingle (Mirror.NetworkWriter writer, System.Single value) [0x00000] in <cbf6389b52654f31bb9df7969869197b>:0
    11-11 19:37:40.644: E/Unity(15273): at PlayerInfo.SerializeSyncVars (Mirror.NetworkWriter writer, System.Boolean forceAll) [0x0019b] in <c91994f92e39415a912610fec1a5b0ad>:0
    11-11 19:37:40.644: E/Unity(15273): at Mirror.NetworkBehaviour.OnSerialize (Mirror.NetworkWriter writer, System.Boolean initialState) [0x00017] in <cbf6389b52654f31bb9df7969869197b>:0
    11-11 19:37:40.644: E/Unity(15273): at Mirror.NetworkIdentity.OnSerializeSafely (Mirror.NetworkBehaviour comp, Mirror.NetworkWriter writer, System.Boolean initialState) [0x00017] in <cbf6389b52654f31bb9df7969869197b>:0


    PlayerInfo is the player prefab assigned to the NetworkManager.
    It also shows these error after trying to spawn the character:

    11-11 19:37:43.932: E/Unity(15273): OnSerialize failed for: object=Player(Clone) component=PlayerController sceneId=0
    11-11 19:37:43.932: E/Unity(15273): System.NullReferenceException: Object reference not set to an instance of an object
    11-11 19:37:43.932: E/Unity(15273): at Mirror.NetworkWriter.WriteBlittable[T] (T value) [0x00027] in <cbf6389b52654f31bb9df7969869197b>:0
    11-11 19:37:43.932: E/Unity(15273): at Mirror.NetworkWriterExtensions.WriteSingle (Mirror.NetworkWriter writer, System.Single value) [0x00000] in <cbf6389b52654f31bb9df7969869197b>:0
    11-11 19:37:43.932: E/Unity(15273): at PlayerController.SerializeSyncVars (Mirror.NetworkWriter writer, System.Boolean forceAll) [0x0000f] in <c91994f92e39415a912610fec1a5b0ad>:0
    11-11 19:37:43.932: E/Unity(15273): at Mirror.NetworkBehaviour.OnSerialize (Mirror.NetworkWriter writer, System.Boolean initialState) [0x00017] in <cbf6389b52654f31bb9df7969869197b>:0
    11-11 19:37:43.932: E/Unity(15273): at Mirror.NetworkIdentity.OnSerializeSafely (Mirror.NetworkBehaviour comp, Mirror.NetworkWriter writer, System.Boolean initialState) [0x00017] in <cbf6389b52654f31bb9df7969869197b>:0

    The character never shows up.
    I've no idea, where to start looking for this bug. I've tested different transports, It happens with Telepathy Transport and Ignorance Transport.
    Does anybody have an idea?
     
    Last edited: Nov 18, 2021
    theforgot3n1 likes this.
  2. theforgot3n1

    theforgot3n1

    Joined:
    Sep 26, 2018
    Posts:
    208
    I have the same error, although my player prefabs do show up. I am using SimpleWebTransport.
     
  3. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Try latest Mirror from Github, we fixed it :)
    On some rare android devices, readers/writers had a problem if memory was unaligned.
    Let me know if the fix works for you or not.
     
    theforgot3n1 likes this.
  4. theforgot3n1

    theforgot3n1

    Joined:
    Sep 26, 2018
    Posts:
    208
    You are correct, the latest release worked for me. :) Thank you for your work vis2k
     
    mischa2k likes this.
  5. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    That was a team effort, I don't even have an android phone :)
     
  6. iGoA

    iGoA

    Joined:
    Aug 23, 2020
    Posts:
    22
    Hi! Thanks for your replies and your work on fiixing it. Sorry for my late reply. I will test it this week.
     
  7. iGoA

    iGoA

    Joined:
    Aug 23, 2020
    Posts:
    22
    Hi vis2k! I've just tried the latest version from github and I get the following compiler error at my script:

    The code there is
    Code (CSharp):
    1. [Command(ignoreAuthority = true)]
    2. public void CmdSetGunCooldownTime(float t)
    3. {
    4.         RpcSetGunCooldownTime(t);
    5. }
    I need the ignoreAuthority attribute at a few places. Can you say, why this attribute isn't recognised anymore?
     
  8. iGoA

    iGoA

    Joined:
    Aug 23, 2020
    Posts:
    22
    Aside the ignoreAuthority, I can confirm that the top post from above are gone and objects seem to spawn correctly again. Thank you very much for fixing this!
     
  9. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    it was renamed to requireAuthority, this avoids the double negative.
    We couldn't add an obsolete path for that unfortunately
     
  10. iGoA

    iGoA

    Joined:
    Aug 23, 2020
    Posts:
    22
    Ah, ok, cool. Thanks again!