wgpu icon indicating copy to clipboard operation
wgpu copied to clipboard

[WebGL] huge memory usage when loading 4K 12bits textures

Open VincentJousse opened this issue 1 year ago • 4 comments

Description I use wgpu to develop a video player. when rendering 4K 12bits textures, the browser's developer tools shows very high memory usage. It seems that some texture memory is not freed.

Repro steps I can try to extract an example if needed.

Expected vs observed behavior I would have expected a constant memory footprint, but I reach 3.5Go after 192 frames displayed.

Platform linux, wgpu: 0.15 and 0.20

VincentJousse avatar Jun 05 '24 15:06 VincentJousse

Did you use a new texture in every frame? if so, the old texture should call destroy explicitly before being dropped on the web platform. maybe this issue is related https://github.com/gfx-rs/wgpu/issues/4092

mikialex avatar Jun 06 '24 08:06 mikialex

I call device.create_texture() at initialization only, and queue.write_texture() for each frame.

VincentJousse avatar Jun 07 '24 07:06 VincentJousse

I've seen this before in my wgpu/webgl codebase. It's something to do with the retention of write_buffer/texture intermediate buffers. they balloon out of control then randomly snap back to normal. I have yet to be able to track down what is going on inside of wgpu, but it's definitely within wgpu. You can see it if you pull stack traces of all live large allocations using a custom allocator.

cwfitzgerald avatar Jun 07 '24 21:06 cwfitzgerald

@cwfitzgerald Have you found a workaround ? Or may I contribute to wgpu if you give me some help ?

VincentJousse avatar Jun 10 '24 09:06 VincentJousse

I unfortunately don't work there anymore and never figured out why this happened, sorry

cwfitzgerald avatar Jan 11 '25 09:01 cwfitzgerald