Search Unity

User Reporting not working from mobile

Discussion in 'Unity Cloud Diagnostics' started by JasdeepDCG, May 31, 2021.

  1. JasdeepDCG

    JasdeepDCG

    Joined:
    Jan 29, 2014
    Posts:
    8
    Hi,
    I'm getting 'UnityUserReportingPlatform.Post: 500 HTTP/1.1 500 Internal Server Error' error on mobile(android). I can send reports from the editor just fine.
     
  2. JasdeepDCG

    JasdeepDCG

    Joined:
    Jan 29, 2014
    Posts:
    8
    Do I need to provide any additional info on this? Can someone from unity respond?
     
  3. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    I don't think they will get back to you, the package hasn't been updated in years, it's probably dead
     
  4. ValeryNikulina

    ValeryNikulina

    Unity Technologies

    Joined:
    Oct 26, 2020
    Posts:
    138
    Hi, guys!

    Sorry for the delay in response! I'm Valery from the Cloud Services Support team, and I'm going to be your friendly neighbourhood support (I just need to update my avatar here) :)

    For 500 HTTP error, I've seen it once before with User Reporting, and it was because of the project's Managed Code Stripping. As soon as it was set to Low or Disabled - it was sending the reports as intended. I know it's been almost two months, but please let me know if this is of any use and if you are using the stripping feature at all.

    As for the package and the service itself, we've got a team working on the service, making it better (faster, stronger), so the updates will be coming soon!
     
    Francesco-FL likes this.
  5. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Maybe I misunderstood, you say there is a team working on Unity user reporting? It hasn't been updated for two years, have they started working on it again?
     
  6. ValeryNikulina

    ValeryNikulina

    Unity Technologies

    Joined:
    Oct 26, 2020
    Posts:
    138
    Hi,

    Yes, that's correct. The service for in maintenance mode for a while, but now there's a core team assembled and started working on improvements.
     
  7. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Wow that's great, thanks for the info!
     
    ValeryNikulina likes this.
  8. ValeryNikulina

    ValeryNikulina

    Unity Technologies

    Joined:
    Oct 26, 2020
    Posts:
    138
    No problem! I'm always happy to bring good news! :)
     
  9. luizbeneton

    luizbeneton

    Joined:
    Apr 8, 2013
    Posts:
    20
    Hello Valery! I'm facing the same Error 500. It only happens on device, currently testing on Android.
    And it only happens when I add an attachment. If I just submit with Summary, Description, even with a Screenshot, it all works, but an attachment, no way.
    I'm trying to add a json attachment by the way, and everything works just fine in the Editor.

    Any updates here?
     
    ValeryNikulina likes this.
  10. ValeryNikulina

    ValeryNikulina

    Unity Technologies

    Joined:
    Oct 26, 2020
    Posts:
    138
    Hi,

    Sorry for the delay in my response.

    This is hard to say what is causing such a behaviour, but I have to say, it's an interesting case :)
    Do you use Managed Code Stripping in your project?

    I'd suggest to submit a tickets with us, as this way we'll be able to investigate this further in detail.
     
  11. luizbeneton

    luizbeneton

    Joined:
    Apr 8, 2013
    Posts:
    20
    Hi Valery, thanks for getting back to me on this topic.
    I using low for Code Stripping, which is the minimum possible on Unity 2020.3.0f1 and Strip Engine Code is enabled.

    I cannot really create a bug report because my project depends on private packages.
    Unity's User Reporting is not part of the Package Manager, it is an old school git repository with a Unity package file inside. I downloaded this package, cleaned from a lot of things that I don't need and made it my own private package.

    If I send you this private package with the bug report I know the answer will be that I made a mistake on my clean up of the package, because that is the easy and quick answer. But given that more people have the same issue, and also given that the code implementation for Unity's User Reporting is not the most clean that I've seen, I thought is was safe to assume that the bug is on Unity's side. Specially because it is the server that fails, and it only does that we send an attachment.

    Maybe something is off with the SimpleJson used to serialize the report? Why would it work on the Editor but no on Mobile? And why it would break only when an Attachment is added?
     
  12. luizbeneton

    luizbeneton

    Joined:
    Apr 8, 2013
    Posts:
    20
    Alright, right after writting the message above, sorry for the salty tone, I tried to deep dive into the code and found out that in the failure happens when serializing the attachment really.

    On UserReportingClient.cs (from Unity's User Reporting plugin) we have this lines of code on the method SendUserData:

    string json = this.Platform.SerializeJson(userReport);
    byte[] jsonData = Encoding.UTF8.GetBytes(json);
    string endpoint = this.GetEndpoint();
    string url = string.Format(string.Format("{0}/api/userreporting", endpoint));
    this.Platform.Post(url .....


    I logged what 'json' is when I submit from the editor, and what it is when i submit from mobile.
    I cannot past them here as each file is 150kb (which might be a bit excessive) but I can past the very beginning:

    Editor:
    {"Attachments":[{"ContentType":"application/json","DataBase64":"eyBTYXZlIGZpbGUgY29udGVudCEgSSBwcm9taXNlIDspIH0=","DataIdentifier":null,"FileName":"User Reporting_report.json","Name":"player_save_file"}],"ClientMetrics":


    Mobile:
    {"Attachments":[{}],"ClientMetrics"


    Editor without attachment:
    This is what happens if I do not set any attachment:
    {"Attachments":[],"ClientMetrics":



    So yeah, serialization of the Attachment fails and the backend of User Reporting cannot handle the result of a bogus attachment.
     
  13. ValeryNikulina

    ValeryNikulina

    Unity Technologies

    Joined:
    Oct 26, 2020
    Posts:
    138
    Hi,

    I'm very sorry for the delay in my response.

    I'm going to share you findings with the team and will get back to you after we look into this more.
     
    luizbeneton likes this.
  14. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Had the same problem and arrived at the same conclusion. User Reporting completely breaks on IL2CPP platforms if Attachments are used. Without even looking at the code, obviously, the problem is because of managed code stripping. Solution:
    Open
    UserReportAttachment.cs
    , and add the
    [Preserve]
    attribute to each property of the class. Boom, works.

    It took me 20 mins to investigate and come up with a fix. Meanwhile, there's no official solution for half a year. Seems like, "core team assembled and started working on improvements" didn't go far. I'm pretty sure this package is dead, not even in maintenance mode. But hey, at least it works for now, with the fix above, that is.
     
  15. SamiIbrahim

    SamiIbrahim

    Joined:
    Jun 7, 2022
    Posts:
    3
    I tested the UserReportingPrefab provided with the SDK package I've downloaded from the UGS dashboard.

    On Windows, it worked fine when I tried to send a bug report. However, on Android, I had the following error: "The report could not be sent. Please try again later".

    I wasn't sure if it was related to the attachment issue described in this thread but, after setting the "Managed Stripping Level" to "Minimal", the issue was gone on Android.

    I hope my comment can be helpful to anyone having the same issue. Also, I believe the UserReportingPrefab should work out of the box on mobile, without the need of playing with "Managed Stripping Level" to "Minimal" or manually adding "Preserve" attributes.
     
  16. joshuaFS

    joshuaFS

    Joined:
    Jul 23, 2018
    Posts:
    25
    @ValeryNikulina Can we please get the fix as given by ZimM above (Open UserReportAttachment.cs, and add the [Preserve] attribute to each property of the class) actually done in the SDK package itself? This is clearly the fix, it worked for me and many others, and it seems quite simple to just fix this correctly in the source so we don't have to hack it in ourselves after running into this problem and wasting so much time trying to fix it.
     
    JJunior and HeyJimRaid like this.
  17. JJunior

    JJunior

    Joined:
    May 22, 2019
    Posts:
    53
    I am having a similar issue, but I am not using the User Report SDK, I am just using the build-in crash and exceptions report. I don't know why, but its not logging crashes and exceptions on Android. Its working fine on Editor. WebGL and iOS builds also work. Is it somehow related with the issue described on this thread? Any help?
     
  18. fben

    fben

    Joined:
    Oct 24, 2015
    Posts:
    9
    Having the same issue with crash/exception reports from Android devices not appearing on the Cloud Diagnostics console.