Open jesdazrez opened 11 months ago
Related: https://github.com/gfx-rs/metal-rs/issues/282.
Note that in general, every new
, alloc
and init
method can return NULL
in Out Of Memory situations.
But that's a bit theoretical, I agree that the above is definitely a higher-priority issue.
Yeah I think metal-rs
should make & document a choice regarding Option<T>
vs Result<T, _>
vs panic!
for those Out of Memory situations.
wgpu
would prefer Option
so we can properly report OOM errors without panicing
I was taking a look at the method and noticed it doesn't check what the
newTextureWithDescriptor
msg_send!
returns.According to the docs that call can return:
The
metal::Texture
type wraps aNonNull<_>
value (fromcargo expand texture
):So when that call fails
new_texture
will put a null ptr in aNonNull
which is UB:Seems like there's people already hitting those cases and
wgpu
now checks if the wrapped ptr is null, but that doesn't deal with the UB.Let me know if I'm missing something, otherwise I can create a PR to perform the check and make
create_texture
return anOption<Texture>