Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug GKLocalPlayer.Local.FetchItems() Error on Unity

Discussion in 'Authentication' started by MousePods, Feb 4, 2023.

  1. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    772
    I setup everything correctly for adding Apple GameCenter so I can use Cloud Save. On device, I successfully login and it shows the banner.

    I get this error when the next line of code is called.

    Code (CSharp):
    1. var fetchItemsResponse = await GKLocalPlayer.Local.FetchItems();
    Code (CSharp):
    1. Thread 1: EXC_BAD_ACCESS (code=257, address=0x2)
    Is there a fix coming soon?

    Thanks
     
  2. clementescoffier

    clementescoffier

    Joined:
    Sep 21, 2020
    Posts:
    6
    I'm having the same problem as you, except no Thread 1: EXC_BAD_ACCESS (code=257, address=0x2) error, it just crashes and cuts connection from the device to XCode
     
    AndreaMar likes this.
  3. clementescoffier

    clementescoffier

    Joined:
    Sep 21, 2020
    Posts:
    6
    nvm, I have the error on another device i tested
     
  4. ted05051997

    ted05051997

    Joined:
    May 7, 2020
    Posts:
    4
    I have the same problem,
    fetchItems()
    OnSuccess()
    Thread 1: EXC_BAD_ACCESS (code=257, address=0x2) error, it just crashes when cuts connection from the device to XCode
    if not cut connection, it will keep stay in this error line in Xcode
    using Unity 2021.3.9f, build on iOS,
    manually modified manifest.json to use unity authentication 2.4.0
    using Apple Game Center plugin for unity
     
  5. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    278
    Hi everyone,
    There is currently an issue with Apple Game Center that we are aware of. We are in contact with Apple to get that resolved.

    I will postback here once we have more information.
     
    qball13z, AndreaMar, Qray5000 and 2 others like this.
  6. TomTheMan59

    TomTheMan59

    Joined:
    Mar 8, 2021
    Posts:
    317
    DeathPro and SebT_Unity like this.
  7. unity_DD36632923EDB25EB366

    unity_DD36632923EDB25EB366

    Joined:
    Feb 7, 2023
    Posts:
    2
    He said he fixed the pointer thing in that branch but the callback still not working actually
     
  8. unity_DD36632923EDB25EB366

    unity_DD36632923EDB25EB366

    Joined:
    Feb 7, 2023
    Posts:
    2
    Stuck in this problem for 2 weeks already, thanks for finally someone related try to handle it
     
    SebT_Unity likes this.
  9. TomTheMan59

    TomTheMan59

    Joined:
    Mar 8, 2021
    Posts:
    317
    It works for me
     
    SebT_Unity likes this.
  10. TheEugeneL

    TheEugeneL

    Joined:
    Dec 7, 2017
    Posts:
    41
    I also have the same error and so I could not use the apple plugin.

    I found another path.
    First I used Social.localUser.Authenticate();
    Social.localUser.id - is TeamPlayerID;

    then I used code from this link https://gist.github.com/BastianBlokland/bbc02a407b05beaf3f55ead3dd10f808

    So I got:
    publicKeyUrl, signature, salt and timestamp

    And it works perfectly. Authorization on the Unity side works without any problems.
     
    SebT_Unity likes this.
  11. ted05051997

    ted05051997

    Joined:
    May 7, 2020
    Posts:
    4
    Is there any update on this issue?
     
  12. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    278
    Hi,
    I've asked the development team to take a look at the suggested workaround proposed above.
    We also have an open ticket with Apple.

    I will postback here when I have more news
     
  13. AndreaMar

    AndreaMar

    Joined:
    Oct 29, 2019
    Posts:
    35
    People here are saying that this git branch is working properly. I still have to give it a try as soon as I can.

    I confirm. It's working. It's impossible to select target platforms while building tars though.

    I'm nonetheless waiting for the official release.

    EDIT: I'm having troubles when I switch back to Android. Unity is building the Apple plugins for Android as well and this creates problems. It seems I cannot deselect the Android platform from the plugin inspector: even if I select only iOS and apply changes, as I try to build the .apk selection are resetting to "Any platform". :mad:
     
    Last edited: Mar 16, 2023
  14. GingerNingerish

    GingerNingerish

    Joined:
    Sep 17, 2019
    Posts:
    5
    Tried the fix but it currently has the GetSalt and Get Signature functions disabled which i need to Authorize cloud saving.
     
  15. AndreaMar

    AndreaMar

    Joined:
    Oct 29, 2019
    Posts:
    35
    Use this. GetSalt() and GetSignature() functions are not available with this mod. Use .Salt and .Signature properties instead. They work fine in my project.

    An annoying problem though is that every time I switch to Android for building my game these plugins (I'm using Core and GameKit) are included in the build process which I cannot complete because of a few errors. I can't edit the selected devices in the plugin inspector. I always have to remove the packages and re-import them again.

    I also cannot target iOS versions lower than 14.0. If I do, the app will crash on launch because of a GameKitWrapper-something missing. But I haven't checked yet if this is a requirement for the mod only or for the official Apple release as well.

    I hope they'll fix this soon.
     
    squigglebucket likes this.
  16. GingerNingerish

    GingerNingerish

    Joined:
    Sep 17, 2019
    Posts:
    5
    Weird, I tried using the .Salt and .Signature properties and it kept telling me there was no permision/access for it or something I forgot the specifics, even though everything was public. This caused me to switch back to whatever the latest was. I have had wayyyyy too many issues with Apple and XCode from these plugins.

    I'm just going to hold out for a fix. I hope it is actually being worked on.
     
    AndreaMar likes this.
  17. AndreaMar

    AndreaMar

    Joined:
    Oct 29, 2019
    Posts:
    35
    Can you upload a screenshot?
     
  18. GingerNingerish

    GingerNingerish

    Joined:
    Sep 17, 2019
    Posts:
    5
    I might be going crazy now. I reimported the fix again reverting from the latest version. Now .GetSignature() and .Signature both don't exist. Think I will wait this out.
     
  19. dennis_unity308

    dennis_unity308

    Joined:
    Sep 14, 2022
    Posts:
    1
    You have to switch branches to `fix-fetch-items`. https://github.com/muZZkat/unityplugins/tree/muzzkat/fix-fetch-items.
    Run the python script to build the unity tar files. Then import.

    Personally, I unpack the entire tar files and copy the uncompressed folder into my project entirely.
     
  20. GingerNingerish

    GingerNingerish

    Joined:
    Sep 17, 2019
    Posts:
    5

    Yeah absolutely, that's exactly what I did, which is funny becuase importing the tar file dirrectly causes it to have no read/write permissions to imported package files which was a whole nother headache I had to figure out.

    But anyways, I had the latest version, reverted to the the fix branch, which was indeed working, since the GetSignature() was removed. Discovered the .Signature reference, which in the editor kept telling me there were no permisions for that reference like it was a private varriable. So I just reverted back to the latest branch.

    As per the advice of the others, AndreaMar asked me to get the screen of that error. So I went through the whole proccess again. Now I do not have GetSignature() or .Signature. So I am certainly on the Fix branch especially after re-doing the plugins like 3 times now.

    So thats where I am at.
     
  21. Razera

    Razera

    Joined:
    Oct 5, 2015
    Posts:
    5
    Hello! We were struggled with this error in the past days and we found a workaround. Open the GKIdentityVerificationResponse.cs script and change the GKIdentityVerificationResponse function from internal to public and the error will be solved!


    Code (CSharp):
    1. public GKIdentityVerificationResponse(ulong timestamp,
    2.             IntPtr publicKeyUrl, int publicKeyUrlLength,
    3.             IntPtr signature, int signatureLength,
    4.             IntPtr salt, int saltLength)
    5.         {
    6.             Timestamp = timestamp;
    7.  
    8.             var publicKeyUrlBytes = new byte[publicKeyUrlLength];
    9.             Marshal.Copy(publicKeyUrl, publicKeyUrlBytes, 0, publicKeyUrlLength);
    10.             PublicKeyUrl = System.Text.Encoding.UTF8.GetString(publicKeyUrlBytes);
    11.            
    12.             Signature = new byte[signatureLength];
    13.             Marshal.Copy(signature, Signature, 0, signatureLength);
    14.  
    15.             Salt = new byte[saltLength];
    16.             Marshal.Copy(salt, Salt, 0, saltLength);
    17.  
    18.         }
     
  22. Razera

    Razera

    Joined:
    Oct 5, 2015
    Posts:
    5
    Hello guys! We were having a lot of problems in the past few days with this error in FetchItems and we finally made a build with success and here go some advices:

    1 - The https://github.com/muZZkat/unityplugins/tree/muzzkat/fix-fetch-items branch fixes the FetchItems Bad Access error in IOS build.
    2 - Make sure you are in muZZkat's branch, you have to enter the git and checkout to fix-fetch-items branch.
    3 - To make sure if you are in muZZkat's branch, the functions GetSignature() and GetSalt() must be missing. You have to change those functions with .Signature and .Salt variables.
    4 - If your Unity Editor logs an error saying that the script doesn't have access/permission to the class, go to GKIdentityVerificationResponse.cs script and change the GKIdentityVerificationResponse() function from internal to public.
     
    Last edited: Apr 17, 2023
  23. Jonathan-FourFats

    Jonathan-FourFats

    Joined:
    Apr 21, 2016
    Posts:
    20
    Last edited: Apr 28, 2023
  24. TomTheMan59

    TomTheMan59

    Joined:
    Mar 8, 2021
    Posts:
    317
    Please sir, is there any news? The fix I was using https://developer.apple.com/forums/thread/722593 doesn't work with macOS builds.
     
  25. Epsilon_Delta

    Epsilon_Delta

    Joined:
    Mar 14, 2018
    Posts:
    213
    Hi, I created a fork on github from official Apple/unityplugins:

    https://github.com/EpsilonD3lta/unityplugins

    and integrated two pull requests:
    1. Fix for correct multiplatform compilation from this fork: https://github.com/dodgy-ltd/apple-unityplugins/tree/cross-platform-fixes
    2. Fix for FetchItems exception from this fork: https://github.com/muZZkat/unityplugins/tree/muzzkat/fix-fetch-items

    Second fix causes to GetSalt and GetSignature methods change to Salt and Signature fields so you have to use those.
    It seems to be working, on client and serverside too, tested on iOS devices, not tested on macOS or anything else.
    I used recomended unity 2020.3.33 to build the plugins with command
    python3 build.py -m iOS
    . My xCode version is 14.2
     
    Last edited: Jul 18, 2023
    lucascurci, Brogan89 and TeorikDeli like this.
  26. TomTheMan59

    TomTheMan59

    Joined:
    Mar 8, 2021
    Posts:
    317
    @SebT_Unity Is there any news on the fixes? It has been over half a year. On the latest version of Unity 2023.2.0b5, both macOS and iOS cannot build while using the apple plugin.
     
  27. GingerNingerish

    GingerNingerish

    Joined:
    Sep 17, 2019
    Posts:
    5
    It is absoluelty pathetic that such a basic function is not fixed.
     
  28. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    772
    Thanks for the info! It seems that is obsolete now... I don't see any path to using Unity's Authentication on iOS at this time... :(

    https://docs.unity3d.com/2023.3/Documentation/Manual/net-SocialAPI.html
     
  29. TheEugeneL

    TheEugeneL

    Joined:
    Dec 7, 2017
    Posts:
    41
    It's just awful to see. My current projects work this way. And I don't know at all what to do so that users don't lose their data. The worst part is that there is no replacement, and there doesn't seem to be one.
     
    MousePods likes this.
  30. lucascurci

    lucascurci

    Joined:
    Feb 7, 2019
    Posts:
    5
    There is a serious issue here, Unity Authentication and cloud saves is unusable if this is not fixed quickly. The normal way of implementing it cannot be by merging a PR of some dude with a commit from another dude.
    Even with this fixes, the plugin does not provide necessary data to sign in with Unity.

    a disaster going on for more than 6 months
     
    pandolfini and MousePods like this.
  31. TheEugeneL

    TheEugeneL

    Joined:
    Dec 7, 2017
    Posts:
    41
    I use authorization mainly to save players data.

    Unfortunately I decided to leave unity services and started working on my own, simpler solution on mysql, as I don't see any way out and can't trust solutions from Unity if such simple things can't be fixed for more than half a year. It's absolutely frustrating
     
  32. TomTheMan59

    TomTheMan59

    Joined:
    Mar 8, 2021
    Posts:
    317
    Any Unity developer! Is there any update? How can a paid service be broken for this long?
     
  33. chengg_unity

    chengg_unity

    Unity Technologies

    Joined:
    May 15, 2022
    Posts:
    60
    Hello everyone,
    Apologies for the delayed response. We are still collaborating with Apple to provide an update on the Apple Unity plugin for a permanent solution. In the meantime, we wanted to share this document with you that offers a workaround.
    Please let us know if you have any feedback on this document, and we’ll make updates as necessary. Thank you!
     
  34. sokolwow

    sokolwow

    Joined:
    Dec 19, 2012
    Posts:
    3
  35. carlosmejia083

    carlosmejia083

    Joined:
    Sep 20, 2020
    Posts:
    2
    HUGE thanks! this worked for me. What a headache the Apple SDK