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

Allow recycling IDs as soon as the drop_* wgpu-core function is called #5217

Closed
3 tasks
nical opened this issue Feb 7, 2024 · 1 comment · Fixed by #5244
Closed
3 tasks

Allow recycling IDs as soon as the drop_* wgpu-core function is called #5217

nical opened this issue Feb 7, 2024 · 1 comment · Fixed by #5244

Comments

@nical
Copy link
Contributor

nical commented Feb 7, 2024

We recently found out that the hook for telling wgpu-core users that allocate their own IDs that an index is safe to reuse has been refactored away at some point. So Gecko currently never reuse any index. Oops.

We could re-introduce a hook for communicating reusable registry indices, but I'd like to simplify things to the point that we don't have to.

Currently the Drop impl for ResourceInfo is what tells the registry that an index can be reused. It is called when the reference-counted resource struct is dropped which in principle should happen after we call wgpu-core's <resource>_drop function... Except if the resource's Arc is moved out of the registry before <resource>_drop in which case the index might be made reusable to soon. That's what causing the headaches in #5141.
My main issue with the current system is that by having reference-counting in between the registry and its recycling logic, we introduced an invariant that was easy to break and broke it without noticing. Instead I would like the registry to completely own the ID reuse logic without being affected by reference counting that is hard to predict.

Proposal

As soon as the wgpu-core resource_drop functions are called, we make the ID reusable. To do this we need:

  • Gecko to remove wpgu-core code in the content process (patches being reviewed)
  • Remove all internal usage of IDs in wgpu-core
  • Reuse Ids as soon as <resource>_drop. For Gecko this means we have a simple rule for when it is safe to reuse IDs.
@nical
Copy link
Contributor Author

nical commented Feb 8, 2024

This would also fix our current issue with leaked deduplicated bindgroup registry slots.

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

Successfully merging a pull request may close this issue.

1 participant