Calling a subgraph more than once in a for loop results in error code 1 due to incorrect return jump address for end of loop
closed
Temporal
VRCSDK3-2019.12.19.19.56
UDONSDK-2019.12.19.18.37_Public
Testing in editor
When using a subgraph multiple times within the same for loop, the Udon VM exits with error code 1 at the end of the first loop. A sample of the graph and subgraph can be seen in the images below.
Calling the subgraph in sequence without a for loop runs as expected. Having only one subgraph call per loop works as expected.
Upon closer inspection of the Udon Assembly code, the JUMP address at the end of the for loop 0x000053 does not correspond to the start of the for loop that increments the index, but another code segment.
After modifying the bytecode in the .asset file to correspond to the correct JUMP address of 0x00002F, the code runs as expected.
The compiled assembly by the graph compiler that doesn't work:
And the modified assembly that does work:
Original .asset:
.asset with modified bytecode that works: https://nyanpa.su/f/vrc/working.asset
Photo Viewer
View photos in a modal
Log In
Momo the Monster
updated the status to
closed
Closing this out as we're taking a new approach to subgraphs as SubPrograms soon.
Temporal
Issue still somewhat present on
VRCSDK3-2020.02.23.13.54
UDONSDK-2020.02.23.14.05_Public
though cause might be different as it looks like jump addresses are now incorrectly offset by -3 bytes now (related to end addresses now being offset by -3 bytes perhaps? 0xFFFFFFFC), for original case in op.
Tupper - VRChat
updated the status to
tracked
Temporal
Issue still present on
VRCSDK3-2019.12.21.16.01
UDONSDK-2019.12.22.12.32_Public
also forgot to include subgraph asset in original post:
Also to add on, this issue also seems happen if multiple subgraphs (regardless if the same or not) are used within the same execution path after any node that requires the use of a JUMP instruction, such as Branches, For and While loops. It also affects the JUMP_IF_FALSE instruction used for exiting the for/while loop.
When using 2 different subgraphs, only one of subgraph is compiled into the udon assembly. JUMP target addresses however, target an address with the assumption that both subgraphs were in the assembly source. With the same subgraph called twice, the JUMP target address also assumes that the same subgraph is there twice. For example in the test case in my post, the compiled subgraph is 36 bytes long. The target address 0x000053 is offset by 36 bytes from the correct target address of 0x00002F.
Edit: Looks like using different subgraphs regardless of any branching/loops also results in only one of them being compiled into the assembly.
Temporal
Still present on:
VRCSDK3-2020.02.03.22.36
UDONSDK-2020.02.03.11.56_Public