LoadSceneAsync freezes

I’ve got a weird problem with the addressables: when I try to load a certain scene my app sometimes freezes.

The function is an IEnumrator called by a coroutine and looks like this, pretty simple and works for all scenes since more then a year with hundreds of different scenes:

handleLoading = Addressables.LoadSceneAsync(key);

while (!handleLoading.IsDone) {
    ShowLoadingScreen();
    yield return null;
}

As said the code cannot be the problem because it works great for (almost) all scenes. So far I’ve found just one scene where it doesnt work but the thing is it works sometimes?! I restart the app and try it again and again and sometimes the scene loads and sometimes the app freezes. Super weird?! When the app freezes the CPU load goes down to 0.1% and nothing is happening anymore except that I the app stops working. I do then have to kill it via task manager.
When I delete the addressable manually and redownload it it also works always on the first app start. But with the second start it’s not for sure anymore that it is loading successfully.

I read about such issues in the changelog so I updated the addressables package to the latest version 1.20 but this doesn’t seem to fix the issue.

Has anyone got any idea that could cause the problem? Or any ideas I could do to debug the problem? As said so far the problem occurs very randomly to me…

I tried to get to the bottom of the problem and realized that this is an editor-only problem! Whenever trying to load a bundle the second time the editor freezes as described above.
But when I build the app and try to do the exact same thing with the exact same bundle again and again it works and works and works…?

How can this problem be editor exclusive? Whats the issue here? Any ideas?

@Tayfe
Hey there, by any chance is it possible for you to try pulling the scene loading call out of the coroutine? There is actually a small chance when a scene is loaded from within a coroutine that it can create a race condition with another editor operation which leads to the editor getting stuck. We’ve only actually run into this issue in a live game one other time before - it seems like it might be the result of some sort of editor limitation. If this is that same issue, pulling the loading call out of the coroutine and waiting on it some other way should fix the issue. Sorry for the inconvenience!

That said, when we previously fixed the issue we didn’t actually get a proper chance to dissect why exactly it happens and find a proper fix for it beyond just not loading the problematic scene from within a coroutine. Would it be possible by any chance for you to send in a bug report with a project that reproduces the issue? That would be super helpful for us to better understand this issue and fix it in future versions of addressables!

Thanks for your help! I finally managed to figure it out and came at least up with a workaround.

So the problem was not related to the addressables but to the scenes I was trying to load. These scenes had some invalid meshes which caused the error

[Physics.PhysX] TriangleMesh::loadFromDesc: desc.isValid() failed!

This made everything crash! The reason I didn’t figure it out directly was because most times the editor hang up before the error message could even be printed to the console. So it took me a lot of restarts before I stumbled across this error message the first time.

I upgraded then to Unity 2022.1 and there I recieved a more precise error message

"pb_Mesh-228134" mesh must have at least three distinct vertices to be a valid collision mesh.

And using the newer version this error didn’t killed the editor anymore! So the update to the newer version solved my problem here. Anyways I would like to see this fix (that this kind of error doesn’t kill the editor anymore) in older versions like Unity 2020.3.

Hi @unity_shane do you know if this problem is only editor specific?

I seemed to have run into this issue for a mac build (Unity 2021.3.1) and I do have the LoadSceneAsync called from within a coroutine. Wondering if that is the culprit?

It only hangs about 1 out of 20 times in the macOS build.

Hi there @luoboa , it’s been awhile so I don’t super remember the code that causes this, but as I understand it it’s probably possible for this to happen in a shipped game as well (i.e. outside the editor), if at all possible, I recommend pulling your scene loads out of a coroutine just to not risk this issue happening, as I don’t think there’s much we can do from the addressables side to fix this as it is due to an editor limitation.

1 Like

I know this posts a bit old, but we’ve just been having a similar problem. We use addressables, but the particular scene we had problems with wasn’t being loaded via Addressables.

Looking through the Addressables code though, if you dig far enough Addressables is loading the scene with SceneManager.LoadSceneAsync the same as we are.

In our case the problem seems to be that a prefab in the scene being loaded had a gameobject with a component attached, however the components script had previously been deleted. The difficult part, was that that component had been removed from the prefab in the prefab it was nested in. So the component wasn’t missing on the object in the scene, because it had been removed by an override in the prefab it was nested in.

Troubleshooting was also made more difficult because the editor wasn’t displaying all the logs before the freeze was occurring. Fortunately we figured out that the actual log file was more consistent, and the last error was always a “The referenced script (Unknown) on this Behaviour is missing!”

Same symptoms, only intermittent failure to load and a large complex project, so I can’t produce a useful bug report, just a similar set of symptoms and our particular solution. I’m not even 100% convinced it is fixed yet given the intermittent nature of the problem.

The problem may not be addressables, but the core engines async scene loading.