Search Unity

Bug Playername managment BETA - Deserialization failed on Android.

Discussion in 'Authentication' started by MidnightGameDeveloper, Apr 20, 2023.

  1. MidnightGameDeveloper

    MidnightGameDeveloper

    Joined:
    Apr 26, 2014
    Posts:
    122
    Hello,
    on my Android device I get the following exception most of the time when trying to receive the playername with "await AuthenticationService.Instance.GetPlayerNameAsync()":

    Deserialization of type 'Unity.Services.Authentication.Generated.Model.Player' failed.

    I also get an exception when trying to change the name. When testing in editor this never happened, it all worked fine. I have no Idea what is causing this, any help is appreciated.

    Error when trying to change the name:
    {"code":55,"detail":"request failed validation","details":[{"errorType":"OpenAPI spec validation","message":"request body has an error: doesn't match the schema: Error at \"/name\": property \"name\" is missing"}],"status":400,"title":"Bad Request"}

    Get name full log:
    Code (CSharp):
    1. <GetOrCreateServicePlayerName>d__4:MoveNext()
    2. System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
    3. System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)
    4. System.Runtime.CompilerServices.MoveNextRunner:Run()
    5. System.Threading.Tasks.AwaitTaskContinuation:RunCallback(ContextCallback, Object, Task&)
    6. System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run(Task, Boolean)
    7. System.Threading.Tasks.Task:FinishContinuations()
    8. System.Threading.Tasks.Task:TrySetException(Object)
    9. System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetException(Exception)
    10. Unity.Services.Authentication.<GetPlayerNameAsync>d__117:MoveNext()
    11. System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
    12. System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)
    13. System.Runtime.CompilerServices.MoveNextRunner:Run()
    14. System.Threading.Tasks.AwaitTaskContinuation:RunCallback(ContextCallback, Object, Task&)
    15. System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run(Task, Boolean)
    16. System.Threading.Tasks.Task:FinishContinuations()
    17. System.Threading.Tasks.Task:TrySetException(Object)
    18. System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetException(Exception)
    19. Unity.Services.Authentication.Generated.Api.<GetNameAsync>d__9:MoveNext()
    20. System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
    21. System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)
    22. System.Runtime.CompilerServices.MoveNextRunner:Run()
    23. System.Threading.Tasks.AwaitTaskContinuation:RunCallback(ContextCallback, Object, Task&)
    24. System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run(Task, Boolean)
    25. System.Threading.Tasks.Task:FinishContinuations()
    26. System.Threading.Tasks.Task:TrySetException(Object)
    27. System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetException(Exception)
    28. Unity.Services.Authentication.<SendAsync>d__19`1:MoveNext()
    29. System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
    30. System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)
    31. System.Runtime.CompilerServices.MoveNextRunner:Run()
    32. System.Threading.Tasks.AwaitTaskContinuation:RunCallback(ContextCallback, Object, Task&)
    33. System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run(Task, Boolean)
    34. System.Threading.Tasks.Task:FinishContinuations()
    35. System.Threading.Tasks.Task:TrySetException(Object)
    36. System.Threading.Tasks.TaskCompletionSource`1:TrySetException(Exception)
    37. System.Threading.Tasks.TaskCompletionSource`1:SetException(Exception)
    38. UnityEngine.AsyncOperation:InvokeCompletionEvent()
     
    Last edited: Apr 20, 2023
  2. Shack_Man

    Shack_Man

    Joined:
    Jun 7, 2017
    Posts:
    372
    I have the same issue, works perfectly in the editor but not on Android... I'm using
    [2.5.0-pre.3]
     
  3. MidnightGameDeveloper

    MidnightGameDeveloper

    Joined:
    Apr 26, 2014
    Posts:
    122
    Good to know I am not the only one.
     
  4. erickb_unity

    erickb_unity

    Unity Technologies

    Joined:
    Sep 1, 2021
    Posts:
    92
    Hello

    Thanks for reporting this issue

    We've identified the issue related to high stripping.
    We will be fixing this for our next release.

    If you need a local fix for the time being, you can add a link.xml to your project to provide stripping rules:
    https://docs.unity3d.com/Manual/ManagedCodeStripping.html#LinkXMLAnnotation

    <linker>
    <assembly fullname="Unity.Services.Authentication" preserve="all" />
    </linker>
     
    blacksun666 likes this.
  5. MidnightGameDeveloper

    MidnightGameDeveloper

    Joined:
    Apr 26, 2014
    Posts:
    122
    Hello,
    thank you for the answer and providing a local fix.
     
  6. jawnwee

    jawnwee

    Joined:
    Nov 4, 2019
    Posts:
    33
    Is there a fix that could be done remotely if our app is already in production?

    Also, does the LinkXML annotation fix apply to iOS as well @erickb_unity?

    Thanks for the heads up!
     
  7. erickb_unity

    erickb_unity

    Unity Technologies

    Joined:
    Sep 1, 2021
    Posts:
    92
    It cannot be done remotely, essentially it is code that was stripped by unity during compilation.

    The link xml solution also works for iOS
     
  8. jawnwee

    jawnwee

    Joined:
    Nov 4, 2019
    Posts:
    33
    @erickb_unity I added the preserve line to my link.xml, but still end up with the 400s.

    For some reason, I don't get this issue when I build to my device locally, but get the 400s in production.
    Any help would be much appreciated!
     
  9. erickb_unity

    erickb_unity

    Unity Technologies

    Joined:
    Sep 1, 2021
    Posts:
    92
    It's hard to tell without knowing more about how your project builds your production build.

    Are you sure the link.xml is present and preserved for that build pipeline?
    Are the 400s showing the same error?
     
  10. jawnwee

    jawnwee

    Joined:
    Nov 4, 2019
    Posts:
    33
    @erickb_unity
    Yep, seeing the exact same 400s errors as op on both get / update names -- our game is only iOS.
    I was hoping there was a way to determine if the stripping patch actually was applied to our iOS build.

    My link.xml is sitting under the Assets folder as so:
    Code (CSharp):
    1.  
    2. <linker>
    3.     <assembly fullname="Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" preserve="all">
    4.     <type fullname="UnityEngine.ResourceManagement.ResourceProviders.LegacyResourcesProvider" preserve="all" />
    5.     <type fullname="UnityEngine.ResourceManagement.ResourceProviders.AssetBundleProvider" preserve="all" />
    6.     <type fullname="UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider" preserve="all" />
    7.     <type fullname="UnityEngine.ResourceManagement.ResourceProviders.InstanceProvider" preserve="all" />
    8.     <type fullname="UnityEngine.ResourceManagement.ResourceManager" preserve="all" />
    9.     <type fullname="UnityEngine.ResourceManagement.AsyncOperations" preserve="all" />
    10.     </assembly>
    11.     <assembly fullname="Unity.Addressables, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" preserve="all">
    12.     <type fullname="UnityEngine.AddressableAssets.Addressables" preserve="all" />
    13.     <!-- TODO REMOVE THIS WHEN AUTH FIX IS IN -->
    14.     <assembly fullname="Unity.Services.Authentication" preserve="all" />
    15.     </assembly>
    16. </linker>
    17.  
     
  11. MidnightGameDeveloper

    MidnightGameDeveloper

    Joined:
    Apr 26, 2014
    Posts:
    122
    My guess would be that the problem is that you have multiple assembly tags in your file or that you need to move line 14. one line down, because you declared an assembly tag in another assembly tag.
     
    Last edited: May 15, 2023
  12. erickb_unity

    erickb_unity

    Unity Technologies

    Joined:
    Sep 1, 2021
    Posts:
    92
    That looks problematic, I'm not sure if Unity sends any warning in case of malformed xml for this.

    Make sure the authentication assembly tag is withing the linker scope and let us know if that fixes your issue!
     
  13. jawnwee

    jawnwee

    Joined:
    Nov 4, 2019
    Posts:
    33
    Ah ‍♂️ thank you for the catch -- glad it was something trivial!
    Haven't checked if a warning was thrown, but if serious, then maybe should be a larger issue,

    Our production build works fine though
     
  14. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    487
    jawnwee likes this.