react-postprocessing
react-postprocessing copied to clipboard
Performance-bug with `<Select />`
Hi and thank you for your fantastic work on this project.
I've just encountered what I believe is a performance bug with the <Select /> component. In this trivial example, I get a CPU usage of 100%:
<Canvas>
<Selection>
<Select enabled>
<Box name="box" />
</Select>
</Selection>
</Canvas>
The react profiler says that the culprit is in the Selection / Select component:
I see two issues with this component:
-
this condition is always true, which is why a call to
selectis triggered every time this hook runs. In my case, this condition is always true for the<group />inside the<Select />component. But more generally, I think it would be true for every non-Mesh in the tree. -
here, the value of
apiis the "old" value, i.e. the value beforeapi.select()was executed. Importantly, in my case,api.selectedis always an empty array. Therefore, I believe the update of the selected objects shouldn't happen in a useEffect cleanup handler.
Just encountered this issue too, would be great to get the fix merged
Echoing what others have mentioned. It would be great to get an update on this