#UniTask pending task issue

1 messages · Page 1 of 1 (latest)

kind geode
#

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

brazen veldt
kind geode
#

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

brazen veldt
#

First you gotta make sure the task condition is awaiting plthe right thing properly.

kind geode
brazen veldt
#

If it still doesn't works, then whatever it awaits, doesn't complete.

brazen veldt
#

You don't need to await

kind geode
#

How do I run the task then?

brazen veldt
#

Just call the async void method as a regular method.

kind geode
#

Ohhhh

brazen veldt
#

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.

kind geode
# brazen veldt Ah, it's a Unitask. Why is it a Unitask?

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

kind geode
brazen veldt
#

First of all, a little bit of garbage is not gonna kill you. Second of all, you can use async instead coroutines.

brazen veldt
kind geode
kind geode
#

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

brazen veldt
#

Try maybe wait Until?
Also log the start of the task as well as the start and end of the job.

kind geode
#

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

kind geode
#

await UniTask.Yield();

brazen veldt
#

That would just wait for one frame.

kind geode
#

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

brazen veldt
#

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.

kind geode
kind geode