0
Fixed

Problem (bug?) with Unity Web Request and Wait Until Unit

Garnette 7 months ago updated by MWMDragon 6 days ago 9

Currently having some difficulty with Wait Until in conjunction with Unity Web Request - Download Handler and recognizing 'is done'. An on button click event (checked for coroutine) kicks off the GET Unity Web Request flowing to the Send Web Request and then I have the Wait Until unit to wait until the Download Handler is done, however, it never updates to 'done'/true. I have also tried using Wait Until Response Code = 200 and tried Wait Until Progress = 1. Neither work. However, if I use Wait Delay 1 Sec I get all the values that never updated ie: Response Code = 200, Progress = 1 and the text from the Download Handler.

My concern with using the Wait 1 sec is not knowing how long any particular Player's internet connection will need to wait so, moving forward based on completion of a task (download handler finishing) would far more ideal than a bunch of wait seconds.

What am I doing wrong with the set up? Is it a bug or is there maybe an issue with it playing properly in the Unity Editor or?  See photo.

Thanks for any help in advance.

Bolt Version:
1.4.4
Unity Version:
2019.1.9f1
Platform(s):
iOS, Android, WebGL
Scripting Backend:
IL2CPP
.NET Version (API Compatibility Level):
.NET Standard 2.0
GOOD, I'M SATISFIED
Satisfaction mark by Garnette 6 months ago
+1
Pending Review

Hi Garnette,

At a glance, it looks like your initial approach should work, it looks like a bug.

I don't have time to have a look this week but I'll check in next week's rounds of fixes.

In the mean time, you could make a macro/super unit out of your collection of wait nodes to keep your graph tidier.

Thanks Lazlo!  I appreciate it.  

Working on Fix

Hi Garnette,

Thanks for the report, I could successfully reproduce it on my end.

At first glance, it seems like the issue is that the Wait Until condition fetching happens in a different scope than the initial coroutine, which then causes Bolt to dynamically fetch the UnityWebRequest.Get result at every frame. This leads to basically one new web request per frame instead of looking at the same request over time.

I'll look into fixing this without introducing any backward incompatibility, but if I can't I'll try to give you some workarounds.

+1
Fixed (Unreleased)

Hi Garnette,

I was able to fix the issue by changing the behaviour of Wait Until and Wait While units to reuse their entry flow for condition checking rather than creating a new flow at every frame. Not only is this more convenient, it's also much more faster and leaner.

It's hard to tell whether this would have any adverse side effect in the long term, but I can't foresee any. I'll therefore include the fix in Bolt v.1.4.10.

By the way, just FYI, you could also use UnityWebRequestAsyncOperation.isDone for the same result. In Bolt 2, we'll package a built-in Wait For Operation unit that takes any AsyncOperation input, so you won't have to check for isDone manually either.

Thanks Lazlo.  When do you think 1.4.10 will be released to the Assets store?  And I haven't ever updated my version of Bolt yet (I'm on 1.4.4) so, is it safe to update without breaking anything in my game?

+1

Hi Garnette,

I apologize for the delay. I'm investigating another coroutine issue and then I'll upload the new version.

Uploading from 1.4.4 to 1.4.10 should be a painless upgrade, but we always recommend a backup just in case.

+2
Fixed

Bolt 1.4.10 is now available: https://ludiq.io/bolt/download/1.4.10

Should be on the asset store soon too!

Thanks a bunch!

Tested working ;)