-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Metal hal seems to accumulate CAMetalLayers in view on iOS #3190
Comments
Cc @jinleili |
get_metal_layer is actually only called when |
If that's the case, then is the code that checks for an existing |
Yes, making it only callable from the crate would make sense. It confused me because it looked like it was designed to be idempotent, but then it wasn't. |
It is indeed possible for a user to pass a UIView with CAMetalLayer, and I need to think about how to better check CAMetalLayer. |
On iOS, this code seems to be appending a new sublayer to the UIView's main layer each time the function is called:
wgpu/wgpu-hal/src/metal/surface.rs
Lines 125 to 134 in a377ae2
If the
view
'slayer
is not aCAMetalLayer
, we create one, and add to the end ofview
'slayer
's list of sublayers. But theview
's layer itself doesn't change, so if we call this function again, we're just going to create and add a newCAMetalLayer
, not return the one we created last time, which seems to be what the function is trying to do.I'm not sure this is actually a bug; I just noticed it while looking at the code. Putting it here just in case.
The text was updated successfully, but these errors were encountered: