Using Wait on the task from the LoadAssetAsync handle freezes the entire program

If you don’t put a timeout value on the Wait, the program just freezes. If you DO put a timeout value on the Wait, then after you finish, it doesn’t matter how long the timeout value is - IsDone is always false and the PercentComplete value of the handle always just returns 1. (Although it seemingly returns 1 regardless of the IsDone value, so maybe that’s not the best metric.) It seems that the task stays as WaitingForActivation for the whole duration of Wait, no matter how long that duration is. Any idea why that could be, and how can I safely wait for the end of the task so I can get the assets synchronously?

1 Like

I think Task.Wait() will cause a deadlock, use await keyword to wait a task.

But I can only await in an async method…and if I want to pause the main thread execution until the asset finishes loading in - for example, because I just discovered an asset I didn’t load in and I need to load it before I can proceed further, because the rest of my system is synchronous - then an async method is pointless. I need to get assets synchronously, hence why I wanted to wait on the task.

1 Like

I know what you mean, but use await keyword is the best idea I’ve come up with so far.
I’m also confused about this why not Addressables provide a synchronized function.

Same issue here two years later. It might be baffling that Unity shipped Addressables like this but I’d guess their multi-platform functionality limits their APIs.

They do have a synchronous workflow now though: Synchronous Workflow | Addressables | 1.20.5

It would be nice if the documentation discussed the fact that the functionality of Task objects is limited within Unity. I didn’t see anything on Operations | Addressables | 1.20.5

I was really confused and hit a major speed bump from Task not behaving like it was supposed to.