Search Unity

[0.3.5-preview, Bug] Addressables faild to initialize in chrome browser

Discussion in 'Addressables' started by s-vovik, Sep 11, 2018.

  1. s-vovik

    s-vovik

    Joined:
    Mar 24, 2017
    Posts:
    14
    I've build project and upload all the stuff (build files and addressable bundles) to a web server. If I open url in the Edge browser - everything is working as expected. But in the chrome I have some troubles:

    Failed to load file://unityengine.application.persistentdatapath/com.unity.addressables/catalog_2018.09.11.16.27.44.hash: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

    Please help to fix this
     
  2. mentorgame1

    mentorgame1

    Joined:
    Oct 31, 2016
    Posts:
    19
    what i know about this is that probably u r using localPath something like File:// at least that whats been called on the game webpage file:// since the bundles/files to load are in the save folder of the website. i u use remoteLoadPath http:// it will work correctly or manualy change the build files to load using http on local server not file://
     
  3. s-vovik

    s-vovik

    Joined:
    Mar 24, 2017
    Posts:
    14
    Thanks for reply.
    No I'm using addressables since 0.1.2-preview and figured out a little how everything works there. I have 3 remote groups. Each one has it's own BuildPath and LoadPath.
    004.png

    LobbyGroup & CombatGroups BundleMode == PackSeparately, Priority I leave as default.

    Every thing works fine till 0.2.2-preview. But there was a bug with groups serialization (thay reset theres properties to default after Build or Play) and I thought it depends in some way. So I belive if groups will be fixed, this bug will be gone too. As we can see in 0.3.5 groups are fine, but WebGL build is not working in chrome and firefox browsers, but perfectly works in Microsoft Edge. The reason is firefox & chrome restricts file url because of security reason and edge doesn't. And Unity WebGL build use file url to get local *.hash files to check cashed *.json files for changes.

    I've made some research. Ok, if default addressables initialization is broken I can made it manualy. So I restricted automatic initializationm and made it via script
    Code (CSharp):
    1. #define ADDRESSABLES_DISABLE_AUTO_INITIALIZATION // here is how to disable auto initialization of addressables
    2.  
    3. using UnityEngine;
    4. using UnityEngine.AddressableAssets;
    5. using UnityEngine.Events;
    6. using UnityEngine.ResourceManagement;
    7.  
    8. /// <summary>
    9. /// Bootstrap
    10. /// </summary>
    11. public class StartController : MonoBehaviour
    12. {
    13.     public UnityEvent OnInitialized;
    14.  
    15.     void Awake()
    16.     {      
    17.         Debug.Log("Addressables.LoadCatalogsFromRuntimeData...");
    18.  
    19. Addressables.LoadCatalogsFromRuntimeData("http://tests.no.ip/AssetBundles/Client/settings.json").Completed += operation =>
    20.         {
    21.             if (operation.Status == AsyncOperationStatus.Succeeded)
    22.                 Debug.Log("Addressables.LoadCatalogsFromRuntimeData OK");
    23.             else
    24.                 Debug.Log("Addressables.LoadCatalogsFromRuntimeData FAILD");
    25.  
    26.             OnInitialized.Invoke();  // Fire event, other  behaviors is waiting for it;
    27.         };
    28.              
    29.         // Initialize ServiceLocator
    30.         Services.Initialize();
    31.     }  
    32. }
    33.  
    Check it out in Editor. Addressables.Mode == Packed
    Console log:
    005.png
    The LobbyScene is in DefaultGroup, it loads and that means addressables initialized and work pretty well.

    Unfortunatly in chrome & firefox we have the same problems. LobbyScene didn't showup. Console tells us
    Failed to load file://unityengine.application.persistentdatapath/com.unity.addressables/catalog_2018.09.11.16.27.44.hash: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

    So I'm pretty sure that this is the bug.
     
    Sascha1977 likes this.
  4. s-vovik

    s-vovik

    Joined:
    Mar 24, 2017
    Posts:
    14
    Does anyone else has this problems in WebGL build opening in chrome/firefox/safari or it's just my local issue?