rojo-rbx / rbx-dom

Roblox DOM and (de)serialization implementation in Rust
MIT License
105 stars 42 forks source link

Humanoid instances should be serialized last in files #406

Closed Dekkonot closed 1 month ago

Dekkonot commented 2 months ago

We ran into an issue at Uplift Games where Motor6D instances were duplicating in Humanoid rigs. After doing some deeper inspection, it turns out this is because the Humanoid instance was loading before its joints and Roblox does this really cool thing where it tries to create joints for humanoid rigs that lack them. This is normally helpful but for this particular case actually results in humanoids having their joints made by Roblox... and then their joints load from the file, resulting in copies.

A fix for this issue is to just put Humanoids after their joints in a file. Since there's no easy way to inspect the structure of a DOM (it's an arbitrary depth tree), we should probably just put Humanoids last in the file to avoid this problem.

The good news is that this is only an actual problem for rbx_binary, since XML files are hierarchy based and as a result the joints of a Humanoid are guaranteed to load after the humanoid.