LoadSceneAsync isn't keeping references

Hey guys,

I’ve got a weird issue. I’ve had a project working for some time now using Unity 2019.2.18 and addressable 1.8.3.

It was going great, bundles were loading and everything was working. We were unfortunately forced to update to 2019.3.13. With that, LoadSceneAsync doesn’t seem to keep references between scenes.

For example, we have 2 scenes in 2 bundles. They share some assets between them and we’ve put them into a 3rd bundle.

We’ll call them Scene A, Scene B.

Here’s a code snippet of how we’re loading a scene:

private IEnumerator LoadRoutine(string _addressableName)
    {
        IsLoading = true;

        //Load the next scene.
        var async = Addressables.LoadSceneAsync(_addressableName);

        while (async.IsDone == false)
        {
            yield return null;
        }

        if (async.Status == AsyncOperationStatus.Failed)
        {
            throw new System.Exception("Failed to load: " + _addressableName + ", " + async.OperationException);
        }
        IsLoading = false;
    }

That snippet of code works just fine in 2019.2.18.

However, in 2019.3.13, when I start up, I can load into Scene A or Scene B just fine. However when I try to go from Scene A to Scene B. Some of the references drop. For example, I’m losing material references and other objects that are needed. I’ll have invisible meshes and such. I can’t even go Scene B → Scene B without losing references. However, once the references are broken, I can try and reload the scene and it’ll work again. So broken SceneB → SceneB and it’ll work again.

The only way I’ve seemed to get around this, is by loading into an empty scene first, waiting for the load to be completed, then load into the next scene. So:
Scene A → Empty Scene → Scene B

That was a lot to take in probably, but has any one else run into this issue?

I’m going to flag this for the team to have a look, and pass along any guidance they might have.

We are having the very same issue. I believe this is the same issue that TreyK has responded to for me as well.

@TPetersonWay to me it kind of sounds like a race condition/ref count issue. Something like

  • SceneA is loaded already (dependencies also loaded)
  • SceneB starts loading (grabs already loaded dependencies)
  • Before SceneB load op can bump the ref count SceneA gets unloaded
  • Dependent bundles are unloaded because SceneB hadn’t bumped their ref count yet

This may not even be close to right, it’s just what kind of sounds like might be happening. I’m not sure what difference between 2019.2 and 2019.3 could be causing this to happen though. If you wouldn’t mind submitting a bug that would be a huge help. Sounds like something we need to look into.

In the upcoming 1.9.3 version of Addressables there is a fix that changes how we dead with scene load handle tracking internally… I don’t think that’s going to help you here but you might give that a shot when it comes out in the next week or two.

Is this the same problem?

Scene A is the start scene and in build. All it does is LoadSceneAsync Scene B.
Scene B is an addressable group and uses an asset from another group.
Now the bug: That asset (sprite from sprite atlas and as a test also an animator) is missing in Scene B.

Tested with 1.10.0.

@drallcom3 I think that issue sounds slightly different to me. If your SceneA was loaded through Addressables and the asset in question was also addressable and used in Scene A then you’d have the same issue. I’m not sure what’s going on with yours. You can file a bug if you like. Or feel free to start a new thread and ask questions