InvSee-plus-plus icon indicating copy to clipboard operation
InvSee-plus-plus copied to clipboard

Data race in SpectatorInventoryView when running on Folia

Open Jannyboy11 opened this issue 1 year ago • 0 comments

InvSee++ uses SpectatorInventoryViews to combine the spectator's items and the target's items into one window. When running on Folia, the target's inventory is managed by the target's entity's region scheduler, while the spectator's inventory is managed by the spectator entity's region scheduler - which often will not be the same. Thus, multiple threads are possibly writing concurrently to the target's inventory whithout proper synchronisation.

I think the best solution is to adopt an STM-style of InventoryView, in which actions are calculated against a snapshot version of the target's inventory, and this action is then scheduled on the target's entity scheduler, with all the hairyness of rollbacks and whatnot if an action could not be applied correctly.

Jannyboy11 avatar May 18 '23 11:05 Jannyboy11