Search Unity

PlayerPrefs usage spits out a nasty error message on Xbox One

Discussion in 'Addressables' started by MartinCoatsink, Apr 22, 2020.

  1. MartinCoatsink

    MartinCoatsink

    Joined:
    Nov 13, 2019
    Posts:
    7
    As for as I know, PlayerPrefs are not supported on some platforms (including Xbox One), but it's still being used. This causes the following error message to be printed on start:

    [PlayerPrefs] Failed to get Data from MachineStorage. Error Code: 0x80830008
    [PlayerPrefs] (Get PROPERTY AddressablesRuntimeDataPath)
    [PlayerPrefs] ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    [PlayerPrefs]
    [PlayerPrefs] WARNING: MainThread delayed for 1591.510975 milliseconds
    [PlayerPrefs] while fetching machine storage.
    [PlayerPrefs]
    [PlayerPrefs] POTENTIAL XR VIOLATION! THE SYNCHRONOUS INITIALIZATION OF PLAYER
    [PlayerPrefs] PREFS IS AN ALMOST GUARANTEED XR VIOLATION. PLEASE PRIME AND INIT
    [PlayerPrefs] PLAYER PREFS PROPERLY BEFORE USING THEM FOR ANYTHING!
    [PlayerPrefs] ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    [PlayerPrefs]

    This issue seems serious, so I'll probably fix it myself by altering one line in AddressablesImpl.cs

    Figured I should raise this issue though for awareness.
     
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,821
    Thanks for flagging, Martin. I'll forward this for the team to take a look. Which version of Addressables are you currently using?
     
  3. MartinCoatsink

    MartinCoatsink

    Joined:
    Nov 13, 2019
    Posts:
    7
    The latest one (1.8.3)
     
  4. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,821
  5. MartinCoatsink

    MartinCoatsink

    Joined:
    Nov 13, 2019
    Posts:
    7
    Sure, I sent in a report just now
     
  6. Nefahl

    Nefahl

    Joined:
    Feb 20, 2017
    Posts:
    71
    Hello, we have the same issue with Addressables 1.19.15, are there any news to this?!

    @MartinCoatsink Do you mind elaborating on which change you made to the Addressable implementation to get it to work? :)
     
  7. Nefahl

    Nefahl

    Joined:
    Feb 20, 2017
    Posts:
    71
    Update, seems like being the same issue in a new location in the Addressables Plugin:

    [PlayerPrefs] MachineStorage data found, however no PlayerPrefs entry was found.
    [PlayerPrefs] (Get PROPERTY AddressablesRuntimeBuildLog)
    in BuildScriptPackedPlaymode.cs : 82/83

    Note: I can't find any PlayerPref mentioned in the changelog of the package so I don't know if updating would help.
    Also I'd like to suggest to add a test-case for this issue to make sure it's not occuring again in a release version after fixing it :)
     
    Last edited: Dec 21, 2022
  8. BernhardTheThreak

    BernhardTheThreak

    Joined:
    Dec 1, 2022
    Posts:
    4
    We have this warning on Xbox Series, while using 2022.2.15 with 1.21.9 addressables.
    @TreyK-47, are there any ways to circumvent this?

    Code (CSharp):
    1. [PlayerPrefs] (Get PROPERTY AddressablesRuntimeBuildLog)
    2. [PlayerPrefs] ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    3. [PlayerPrefs]
    4. [PlayerPrefs]   WARNING: MainThread delayed for 55.931427 milliseconds
    5. [PlayerPrefs]            while fetching machine storage.
    6. [PlayerPrefs]
    7. [PlayerPrefs]            POTENTIAL XR VIOLATION! THE SYNCHRONOUS INITIALIZATION OF PLAYER
    8. [PlayerPrefs]            PREFS IS AN ALMOST GUARANTEED XR VIOLATION. PLEASE PRIME AND INIT
    9. [PlayerPrefs]            PLAYER PREFS PROPERLY BEFORE USING THEM FOR ANYTHING!
    10. [PlayerPrefs] ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    11. [PlayerPrefs]
    12. Did not save cached content catalog because Application.persistentDataPath is an empty path.
    13. UnityEngine.Logger:Log(LogType, Object)
    14. UnityEngine.Debug:LogWarning(Object)
    15. UnityEngine.AddressableAssets.ResourceProviders.InternalOp:OnCatalogLoaded(ContentCatalogData)
    16. UnityEngine.AddressableAssets.ResourceProviders.InternalOp:CatalogLoadOpCompleteCallback(AsyncOperationHandle`1)
    17. DelegateList`1:Invoke(T)
    18. UnityEngine.ResourceManagement.ResourceManager:ExecuteDeferredCallbacks()
    19. UnityEngine.ResourceManagement.ResourceManager:Update(Single)
    20. UnityEngine.AddressableAssets.Initialization.InitializationOperation:InvokeWaitForCompletion()
    21. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:WaitForCompletion()
    22. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle:WaitForCompletion()
    23. UnityEngine.ResourceManagement.ChainOperationTypelessDepedency`1:InvokeWaitForCompletion()
    24. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1:WaitForCompletion()
     
  9. STG-SamSheth

    STG-SamSheth

    Joined:
    Jun 26, 2021
    Posts:
    2
    Hey, @BernhardTheThreak.

    Did you ever figure out how to resolve this? We're in the same boat.

    Thanks.
     
    Last edited: Sep 21, 2023
  10. NunesTimeGalleon

    NunesTimeGalleon

    Joined:
    May 31, 2023
    Posts:
    4
    We have not run into this issue using Unity 2022.3.5f1, Addressables version 1.21.17, but if my understanding of how Addressables work, this may be what's happening:

    When you first make an Addressable call, such as LoadAsset, etc, the Addressable system first checks if it has been initialized, and if it hasn't, it calls Addressables.InitializeAsync.

    I assume that during the Initialization of the Addressables, it performs a call to PlayerPrefs.

    When using GameCore to develop for Xbox, you must first initialize the PlayerPrefs through its async method, otherwise you get the nasty error you folks are seeing.

    My recommendation is, as soon as your game boots, before any other kind of Addressable call, you initialize both manually using a simple method such as for example:

    Code (CSharp):
    1. private IEnumerator Start()
    2. {
    3.  
    4.     //Note that the namespace used is different for initialization
    5.     yield return UnityEngine.GameCore.PlayerPrefs.InitializeAsync(null);
    6.  
    7.     AsyncOperationHandle<IResourceLocator> handle = Addressables.InitializeAsync();
    8.     yield return handle;
    9.        
    10.     //You should be ready to use PlayerPrefs and Addressables from here on out
    11.  }
    I am curious if that solution will fix the issues you are having, let me know.
     
    Last edited: Sep 27, 2023
  11. STG-SamSheth

    STG-SamSheth

    Joined:
    Jun 26, 2021
    Posts:
    2
    @NunesTimeGalleon, thank you very much. This worked for us.
     
    NunesTimeGalleon likes this.