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

Resolve cycles in wgpu-core using weak references #5120

Closed
Tracked by #5121
nical opened this issue Jan 22, 2024 · 2 comments · Fixed by #5910
Closed
Tracked by #5121

Resolve cycles in wgpu-core using weak references #5120

nical opened this issue Jan 22, 2024 · 2 comments · Fixed by #5910
Labels
kind: refactor Making existing function faster or nicer type: enhancement New feature or request

Comments

@nical
Copy link
Contributor

nical commented Jan 22, 2024

At the moment the device has string reference to the resources and the resources have strong references to the device. This cycle is manually broken in triage_suspected by looking at the reference count.

We want to remove this manual reference count management and only rely on weak refst to break the cycles.

@cwfitzgerald put together a diagram that illustrates the end result:

Diagram of future strong and weak reference in wgpu-core

@nical
Copy link
Contributor Author

nical commented Feb 9, 2024

@cwfitzgerald how does the queue fit in the above diagram? The WebGPU spec says that the device has a strong reference to the queue (but we can make it work in the browser either way by having the JS-facing objects have the strong references in the right order even if wgpu-core internally has it the other way around).
Currently the queue has a strong reference in to the device in wgpu-core.

See also #5230.

@cwfitzgerald
Copy link
Member

@nical I believe it's "queue owns device", "device has weakref to queue". This doesn't really vibe with the idempotent queue method call on device in WebGPU, but I don't think we need to have that in wgpu-core.

If we were to model the WebGPU way, it would be "device owns InternalQueue", "queue owns InternalQueue". This way the device can hand out the same internal queue over and over to separate Queue objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: refactor Making existing function faster or nicer type: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants