Merging flows after Branch generates incorrect Udon Assembly
aurycat
Hi, I've found a bug in the Udon Graph compiler to do with merging/combining flows within the same Event.
See the picture of the graph labeled "A". The program will always flow into the False branch, then it should log Counter, increment Counter by 1, and then log it again. So if Counter starts at 0, it should print 0 then 1. However, the program actually just prints 0 and 0 again.
Compare that to the graph labeled "B", which should have exactly the same behavior -- all that changed was moving a flow to another set of identical nodes. And, moreover, the flow that was changed never even gets executed because the program will always take the False branch. However, with program "B", the program now has the correct behavior of printing 0 then 1.
I've attached an picture of an annotated side by side comparison of the compiled Udon Assembly for each of these programs. The "good" case ("B") is on the left, and the "bad" case ("A") is on the right. See that the code is identical -- except for a missing 4 instructions for the increment on the "bad" case.
Basically, it seems the compiler is assuming the flows exiting a Branch node will never merge back together, which isn't true. I'm a little confused about what the compiler is actually trying to do right now... the False case somehow gets both Logs, but misses the addition. But regardless, the solution will require figuring out the point at which the flows merge back together and having both True and False cases end by JUMPing to that instruction.
Thanks!
Log In
Sayamame
It is potentially the same kind of bug as this Canny( https://feedback.vrchat.com/udon/p/temporary-value-is-not-initialized-if-it-is-also-appears-in-unreached-path ) .
In the linked one, it's happening in a variable handling node via Branch.
The same thing happens when we merge the flow of Branch.
aurycat
Also, to be clear, this doesn't just happen with this contrived example, it appears to happen any time flows merge at some point after a Branch node.