LoadSceneAsync is returning errors after last addressable package 1.21.17 update

Hi everyone,

After updating the addressable package to version 1.21.17, Addressable.LoadSceneAsync() has been throwing two errors in our recent WebGL builds which we never encountered before.

  • “Scene ‘Assets/Scenes/WiringDiagrams/WiringBasic2014.unity’ couldn’t be loaded because it has not been added to the build settings or the AssetBundle has not been loaded.”
  • “ArgumentNullException: Value cannot be null. Parameter name: _unity_self”

The issue begins to occur after our bootstrap and main menu scenes are loaded and initialized. When a new scene is selected from the main menu, LoadSceneAsync() returns those error messages. None of the selectable scenes can load correctly.

I’ve tracked the problem down to the async op handle being returned from LoadSceneAsync(). It’s never assigned to operationHandle because the errors are triggered before then.

    IEnumerator QueueScene( string scene, bool additive )
    {
        if (!loadingScene)
        {
            loadingScene = true;
   
            yield return new WaitUntil( () => SceneManager.sceneCount == 1 && clearToLoad );
   
            operationHandle = Addressables.LoadSceneAsync( scene, additive ? LoadSceneMode.Additive : LoadSceneMode.Single, true );
   
            currentScene = SceneManager.GetSceneAt( SceneManager.sceneCount - 1 ).buildIndex;
            currentSceneName = SceneManager.GetSceneAt( SceneManager.sceneCount - 1 ).name;
            clearToLoad = false;
            loadingScene = false;
   
            try
            {
                StartCoroutine(WaitAndSetSceneActive( operationHandle ));
            }
            catch (Exception e)
            {
                Debug.Log($"Failed to Load Scene: {currentSceneName}\nError Exception: {e}");
            }
            finally
            {
                Debug.Log($"{currentSceneName} has successfully loaded.");
            }
        }
    }

I’ve also confirmed that related scene bundles are downloaded and cached in the browser cache before invoking LoadSceneAsync(). Also, the codebase has mostly remained unchanged before the package update and everything still works when playing in the editor.

I’ve attempted a few solutions to fix the error (some of which were from this forum for similar errors) but to no avail.

I’m not trying to suggest the new package has a regression, it’s more likely some bad code/race condition on our end :slight_smile: But I’m having a difficult time fixing this. How do I go about “revalidating” the operationHandle object is what I want to know.

Any guidance or help would be awesome. If any more info is needed, please let me know. Thanks in advance.

Our project is built with Unity 2022.3.5.f1.

ok, looking through the code it looks like they’ve changed
Addressables.DownloadDependenciesAsync(Assets.InternalId)
to only download the bundle now, it doesn’t load them automatically, can’t tell if this is intentional or not
currently working out how to manually tell it to load the bundle

1 Like

so

                    if (!(m_ProvideHandle.Location is DownloadOnlyLocation))
                    {
                        // this loads the bundle into memory which we don't want to do with download only bundles
                        m_AssetBundle = downloadHandler.assetBundle;
                    }

from the source code
DownloadOnlyLocation inherits from LocationWrapper, and there’s no other classes that inherit from it,
and nothing makes a new instance of LocationWrapper so there is physically no option to actually load it in when finished downloading , there might be some way of doing this but Documentation is 0,
probably the best thing to do is going to
UnityProject\Packages\manifest.json
“disableProjectUpdate”: true, add at the beginning before “dependencies” : {
and rollback to addressables
“com.unity.addressables”: “1.19.19”
there might be newer versions you can use that doesn’t have this bug

2 Likes

Thank you for the response. Interesting find… I’ll run some tests and try to verify the bundle loading behavior your describing in my project.

Unfortunately I can’t roll back the addressable package because it will re-introduce this editor bug that 1.21.17 included the fix for.

Maybe someone from the addressable team ( @davidla_unity or @pillakirsten ) can chime in with further guidance on this…

Bump.

bump

1 Like

We also have this issue. Bump.

1 Like

Same issue.

1 Like

Bump

Just wanted to give an update on this issue:

I was able to solve part of the error by doing what other people suggested in these threads :

In summary, you must release the operation handle used for DownloadDependencies before invoking LoadSceneAsync. That operation handle for DownloadDependencies has a lock on the bundle data until it is properly released.

However, once I added Release to our custom bundle controller, I was still getting the same error, but it would only trigger with the last scene bundle that was required to download.

Our project is setup to download and load several scene bundles after a user selects a scene from the main menu. These scene bundles include the scene the user selected, and other helper scenes that are all loaded in additively. while debugging, I noticed that LoadSceneAsync was being called before the final bundle finished downloading.

This was resolved by adding a yield that waited until all bundles were downloaded and their handles were released. After that change, LoadSceneAsync worked, and our scenes loaded!

I’m not sure why but it seems like the bundles were taking longer to download… either way this thread can be closed.

2 Likes

Having the same issue but with downloading sprites and text assets and trying to use them afterwards. Custom logs say asset was completely downloaded and ready to use but LoadAssetAsync results in an exception:
Unable to load dependent bundle from location e
where “e” is the first symbol of the assert guid.

It also repros when building addresasbles localy and selecting “Use existing build (Android)” (also need to start a Hosting Service with local hosting and etc)

Magically fixes by itself on second app start

It started to repro after update unity to 2022.3.16 and addressables to 1.21.19. Before update we were using unity 2021.3.27 and addressables 1.21.2, this setup worked fine (at least didn’t have this issue)

2 Likes

Hi,
I had the same problem. In Android build, the assets did not load with the same error message “Unable to load dependent bundle from location~”. Then I realized I did not release the download handle (when I called
DownloadDependenciesAsync). So I added a single line Addressables.Release(_downloadHandle); and everything was fixed. I am not sure how relevant this solution is to your specific case, but worked for me so I’m writing here just in case.

Unity version: 2022.3.20f1
Addressable version: 1.21.20

1 Like

I’m having the same issue.
Unity cannot load my addressable scenes because they are not added to the build settings.

Everything used to work fine until a few days ago.

Unity version: 2022.3.20f1
Addressable version: 1.21.20

I tried adding in what @gamelarson recommended above, but nothing changed for me.

public void BeginDownload()
        {
            downloadHandle = Addressables.DownloadDependenciesAsync(startMenuScene);
            downloadHandle.Completed += OnSceneLoaded;
        }



        private void OnSceneLoaded(AsyncOperationHandle obj)
        {
            Addressables.Release(downloadHandle);// is this not the right place?
             ...
         }

This was the only thing that helped me

Hey y’all, we’re aware of the issue, but haven’t gotten a repro project yet. If anyone here wouldn’t mind filing a bug, that’d be a huge help to us.

Hi, has a repro project been submitted for this issue yet? I’m running into this problem now and wouldn’t mind putting together a repro over the next couple of evenings if it will help resolve the issue.

Unity apparently updated my Addressables back to the latest somehow and this issue came back, Addressables 1.21.20.

Rolling back once again…

@davidla_unity sorry I am trying to get my game released and haven’t had time to create a repro. Honestly, I don’t want to spend time creating a simple example hoping to repro, and then it not repro because there is something more going on with the complexities of my full game. Otherwise, I totally would try to repro this because it is a VERY frustrating, especially now since Addressables updated on me and I spent the last 2 weeks chasing my tail trying to figure out why my levels stopped loading.

Rolling back to 1.19.19 has my game working once more.

Here is the repo to reproduce it
JayArrowz/AddressableSceneBug (github.com)

You have to build the project then run the exe. Ensure you do not have the files downloaded in AppData/Local.

Notice the issue occurs here: AddressableSceneBug/Assets/LoadingScreen.cs at main · JayArrowz/AddressableSceneBug (github.com)

Mono path[0] = 'C:/Users/J/OneDrive/Documents/BuildWinTest/AddressableSceneBug_Data/Managed'
Mono config path = 'C:/Users/J/OneDrive/Documents/BuildWinTest/MonoBleedingEdge/etc'
[PhysX] Initialized MultithreadedTaskDispatcher with 24 workers.
Initialize engine version: 2022.3.35f1 (011206c7a712)
[Subsystems] Discovering subsystems at path C:/Users/J/OneDrive/Documents/BuildWinTest/AddressableSceneBug_Data/UnitySubsystems
GfxDevice: creating device client; threaded=1; jobified=1
Direct3D:
    Version:  Direct3D 11.0 [level 11.1]
    Renderer: NVIDIA GeForce RTX 3080 (ID=0x2216)
    Vendor:   NVIDIA
    VRAM:     10053 MB
    Driver:   32.0.15.5599
Begin MonoManager ReloadAssembly
- Loaded All Assemblies, in  0.093 seconds
- Finished resetting the current domain, in  0.001 seconds
<RI> Initializing input.
<RI> Input initialized.
<RI> Initialized touch support.
[PhysX] Initialized MultithreadedTaskDispatcher with 24 workers.
UnloadTime: 0.581700 ms
Scene 'Assets/Scenes/DownloadedScene.unity' couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded.
To add a scene to the build settings use the menu File->Build Settings...
NullReferenceException: Object reference not set to an instance of an object
  at UnityEngine.ResourceManagement.ResourceProviders.SceneProvider+SceneOp.InternalLoadScene (UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation location, System.Boolean loadingFromBundle, UnityEngine.SceneManagement.LoadSceneParameters loadSceneParameters, System.Boolean activateOnLoad, System.Int32 priority) [0x00017] in <8ca064ccd930487f9d9e4a1371e793da>:0 
  at UnityEngine.ResourceManagement.ResourceProviders.SceneProvider+SceneOp.Execute () [0x00077] in <8ca064ccd930487f9d9e4a1371e793da>:0 
  at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].InvokeExecute () [0x00000] in <8ca064ccd930487f9d9e4a1371e793da>:0 
  at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].Start (UnityEngine.ResourceManagement.ResourceManager rm, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency, DelegateList`1[T] updateCallbacks) [0x0008b] in <8ca064ccd930487f9d9e4a1371e793da>:0 
  at UnityEngine.ResourceManagement.ResourceManager.StartOperation[TObject] (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject] operation, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency) [0x00000] in <8ca064ccd930487f9d9e4a1371e793da>:0 
  at UnityEngine.ResourceManagement.ResourceProviders.SceneProvider.ProvideScene (UnityEngine.ResourceManagement.ResourceManager resourceManager, UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation location, UnityEngine.SceneManagement.LoadSceneParameters loadSceneParameters, System.Boolean activateOnLoad, System.Int32 priority) [0x0004b] in <8ca064ccd930487f9d9e4a1371e793da>:0 
  at UnityEngine.ResourceManagement.ResourceManager.ProvideScene (UnityEngine.ResourceManagement.ResourceProviders.ISceneProvider sceneProvider, UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation location, UnityEngine.SceneManagement.LoadSceneParameters loadSceneParameters, System.Boolean activateOnLoad, System.Int32 priority) [0x0000e] in <8ca064ccd930487f9d9e4a1371e793da>:0 
  at UnityEngine.AddressableAssets.AddressablesImpl.LoadSceneAsync (UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation location, UnityEngine.SceneManagement.LoadSceneParameters loadSceneParameters, System.Boolean activateOnLoad, System.Int32 priority, System.Boolean trackHandle) [0x00020] in <de4f843f379446e18f14228fd803abe8>:0 
  at UnityEngine.AddressableAssets.AddressablesImpl.LoadSceneAsync (System.Object key, UnityEngine.SceneManagement.LoadSceneParameters loadSceneParameters, System.Boolean activateOnLoad, System.Int32 priority, System.Boolean trackHandle) [0x0005d] in <de4f843f379446e18f14228fd803abe8>:0 
  at UnityEngine.AddressableAssets.Addressables.LoadSceneAsync (System.Object key, UnityEngine.SceneManagement.LoadSceneMode loadMode, System.Boolean activateOnLoad, System.Int32 priority) [0x0000c] in <de4f843f379446e18f14228fd803abe8>:0 
  at UnityEngine.AddressableAssets.AssetReference.LoadSceneAsync (UnityEngine.SceneManagement.LoadSceneMode loadMode, System.Boolean activateOnLoad, System.Int32 priority) [0x00027] in <de4f843f379446e18f14228fd803abe8>:0 
  at LoadingScreen+<Preload>d__9.MoveNext () [0x000c9] in <ddf5da6850b3418da299f9379d5432e3>:0 
  at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00026] in <e422ced3d0f64bb29423e8338d57bc04>:0 

On second load its fine. It seems unity registers the scene.

Off topic: pretty disappointing such a simple bug which was spotted by staff wasn’t investigated and has been open for quite a bit, this issue is a pretty big show stopper from people using the newer addressable version.

bump anyone gonna reply and acknowledge this bug or leave this in a unusable state for over a year? Where is the triage? Where is the submission on the bug board?