jabuwu / rusty_spine

Spine runtime for Rust (and wasm!) transpiled from the official C Runtime.
https://docs.rs/rusty_spine
Other
43 stars 4 forks source link

Updating skeletons in parallel is not thread safe #1

Open jabuwu opened 2 years ago

jabuwu commented 2 years ago

I'm making a note of this here in case anyone tries it. It does not work. The primary suspects seems to be reference counting of attachments being non-atomic.

https://github.com/jabuwu/rusty_spine/blob/34a326468f70e67daadaaab00237995f3837782e/src/attachment.rs#L29

Unfortunately, this is a non-trivial fix since the C code won't play nice with Rust atomics.

Skeletons which do not share attachments (skeletons that have a different SkeletonData as others) are probably fine to be updated in parallel.

Attachments in general are really unsafe and could use a proper Handle type to address them safely.