Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance-bug with <Select /> #236

Open
donalffons opened this issue Aug 12, 2023 · 0 comments
Open

Performance-bug with <Select /> #236

donalffons opened this issue Aug 12, 2023 · 0 comments

Comments

@donalffons
Copy link

donalffons commented Aug 12, 2023

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:
image

I see two issues with this component:

  1. this condition is always true, which is why a call to select is 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.
  2. here, the value of api is the "old" value, i.e. the value before api.select() was executed. Importantly, in my case, api.selected is always an empty array. Therefore, I believe the update of the selected objects shouldn't happen in a useEffect cleanup handler.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant