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 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.