#UniTask pending task issue
1 messages · Page 1 of 1 (latest)
I am pretty sure I'm doing this the wrong way, I assume I can get wheter or not refreshing is happening, I did this but it does nothing, the condition never goes back to false
I set it back to false at refreshing
Meaning your task never actually completes. Which leads us back to what I said previously about wait while
I inverted the condition ,it did not work either, then I swaped to await UniTask.Yield() and still nothing
what about the Forget() at the end of refresh? I used this because it seems like there is no way to call refresh if the caller function is not an async
I used async UniVoid before but It was still calling a lot of times
Why not? If it's an async void it should be run without problem. But I don't think Forget is the problem(could still remove it).
First you gotta make sure the task condition is awaiting plthe right thing properly.
because using await would mean turning Update into async Update
If it still doesn't works, then whatever it awaits, doesn't complete.
No.
You don't need to await
How do I run the task then?
Just call the async void method as a regular method.
Ohhhh
Ah, it's a Unitask. Why is it a Unitask?
I guess that's why the Forget is needed
In this case it seems like you won't lose anything from making it an async void method instead.
Yes, it is a UInitask, the reason is that I noticed that IEnumerators Generate some garbage on my code which lead to sttutering (this was before using Jobs system in my code, maybe it was't the coroutines but the lack of optimizations back then)
Should I try to roll back to coroutines or should I stay with UniTask? my biggest concern is sttutering due to GC
I heard UniTask had zero allocation on heap meaning zero garbage
Yeah, if I try to call this like a regular function, I get a warning
First of all, a little bit of garbage is not gonna kill you. Second of all, you can use async instead coroutines.
This is because it returns a Task. Make it a void instead.
I say it because before optimizing my code, my game was sttuttering from time to time, now it doesnt do that anymore since I moved to tasks, but still I am concerned about task being called and staying as pending
Alright, let me try
Same result, so what can I use instead of wait while? I remembered why I was using it
Actually it was for spawning chunks as they were ready
Try maybe wait Until?
Also log the start of the task as well as the start and end of the job.
Its weird because using wait while spawns my chunks as I expect to (surronding the player according to the render distance) but when I use Yield() it loads 1 chunk only but it no longer has pending tasks
Alright let me check
Just Yield()..?🤨
That would just wait for one frame.
So I just debugged, and using wait until instead of wait while gives the same result as yield, it spawns only one chunk at the time, but completes all the pending tasks
Meaning there's an issue with your logic.
It's too complicated for me to quickly figure it out, so you'll need to investigate it yourself.
Adding debugs would help you understand when and what happens.
It seems like that
I will try to simplify my code ignoring all those loops and such, maybe I can find out what happens