Search Unity

Social.LoadUsers causes consistent crash when building to iOS

Discussion in 'Scripting' started by unity_BUIockkbCwDQ9w, Sep 18, 2020.

  1. unity_BUIockkbCwDQ9w

    unity_BUIockkbCwDQ9w

    Joined:
    Oct 29, 2019
    Posts:
    13
    I get a list of Game Center user IDs using LoadScores, but unfortunately these only contain user IDs ("G:" followed by a string of digits). Now, previously we have used Social.LoadUsers on a string array of these IDs to retrieve user names, but I am seeing a consistent crash every time I do anything to access LoadUsers, e.g.:

    Code (CSharp):
    1.  
    2. [INDENT][INDENT]List<string> userIDs = new List<string>();[/INDENT][/INDENT]
    3.                foreach ((string, int) leader in allTimeTreasureLeaders)
    4.                {
    5.                    userIDs.Add(leader.Item1);
    6.                }
    7.  
    8.                string[] userIDArray = userIDs.ToArray();
    9.  
    10.                Social.LoadUsers(userIDArray, users =>
    11.                {
    12.                    foreach (IUserProfile user in users)
    13.                    {
    14.                        Debug.Log(user.userName);
    15.                    }
    16.                });
    What is strange is I can see the print out of the names here, but then I get an EXC_BAD_ACCESS anyway. EVEN IF I REMOVE THE DEBUG STATEMENT IT STILL CRASHES. Note that I'm not doing anything with these user names as the moment--it seems to just be the call to LoadUsers that causes the crash.

    A couple of other comments to elaborate: this is in a static class, and allTimeTreasureLeaders is a List<(string, int)> that is populated in this class separately by a call to LoadScores. At the moment it contains 3 entries (our team).

    Does anyone see an issue with what I'm doing or had this issue with LoadUsers before?

    EDIT: Stack trace in attached image. Crashes on Liveness State::AddProcessObject, which occurs during the scene transition.
     

    Attached Files:

    Last edited: Sep 22, 2020
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,727
    Seeing an EXC_BAD_ACCESS makes it sound like an actual bug outside of the code above. If you try this:

    Code (csharp):
    1. Social.LoadUsers(userIDArray, (users) => { return; });
    and it still crashes, then you know it isn't the delegate you're giving it.

    Check over the API and make sure you're doing everything that Social expects you to do to set it up.

    Keep in mind some of that setup might involve permissions / entitlements from Apple.

    If you are, make a fresh project, put the code in and test it... if it still blows up, file a bug with Unity. They're really good about fixing specific crashes like this.
     
    pandolfini likes this.
  3. pandolfini

    pandolfini

    Joined:
    Feb 5, 2020
    Posts:
    17
    thanks, Kurt. We are seeing this crash even when I leave it empty in the callback in our project. The crash doesn’t occur until a scene change. Without the empty call to LoadUsers the project works fine.

    I will attempt with an empty project and then file a big report. I suspect this is related to the changes made by Apple over the summer to their leaderboards.
     
  4. unity_BUIockkbCwDQ9w

    unity_BUIockkbCwDQ9w

    Joined:
    Oct 29, 2019
    Posts:
    13
    So I tested this in a blank project with one classic and one recurring leaderboard and I do not see the crash. So the issue is within our project itself. I added the stack trace above. It looks like there is some issue with scene garbage collection that causes this crash (?).
     
  5. erikhallgren

    erikhallgren

    Joined:
    Feb 2, 2015
    Posts:
    9
    We are seeing this issue as well, have you found what the issue is? Also only appearing on scene change
     
  6. pandolfini

    pandolfini

    Joined:
    Feb 5, 2020
    Posts:
    17
    The Unity wrapper for Game Center is unquestionably broken. LoadUsers is not viable anymore. I would guess this is related to updates to Apple’s leaderboard system from this summer. We downloaded Prime31’s Game Center package on the suggestion of another thread discussing this same issue and it works properly.