[WebGPU] Instant multi-GB memory increase on https://webgpu.github.io/webgpu-samples/samples/resizeCanvas
Categories
(Core :: Graphics: WebGPU, defect)
Tracking
()
People
(Reporter: mayankleoboy1, Assigned: aleiserson)
References
(Regression, )
Details
(Keywords: regression)
Crash Data
Attachments
(2 files)
Go to https://webgpu.github.io/webgpu-samples/samples/resizeCanvas
AR: Instant multi-GB continuous memory increase
ER: Not so
Bisection: bug 1906679
Reporter | ||
Comment 1•11 months ago
|
||
In full-screen window, the memory rise is so rapid that you cant capture any profile or about:memory.
But of you reduce the window size, the memory rise is less rapid (though still quite fast).
I managed to capture a profile with the "webgpu" preset logging: https://share.firefox.dev/3zPyEaY
Comment 2•11 months ago
|
||
Set release status flags based on info from the regressing bug 1906679
:teoxoy, since you are the author of the regressor, bug 1906679, could you take a look? Also, could you set the severity field?
For more information, please visit BugBot documentation.
Updated•11 months ago
|
Updated•11 months ago
|
Updated•11 months ago
|
Reporter | ||
Comment 4•7 months ago
|
||
I can still repro.
profile with webgpu preset logging: https://share.firefox.dev/3EdyOui
Comment 8•6 months ago
|
||
That looks like a different issue on another sample, could you open a new bug for it?
Hi. Filled new bug https://bugzilla.mozilla.org/show_bug.cgi?id=1954913
Comment 10•3 months ago
|
||
I believe the specific problem here (on my Metal device at least) is that GPUTexture.destroy()
doesn't do anything. Texture memory only gets freed on GC, even though explicitly calling destroy()
sounds like it should deallocate as soon as possible.
The resizeCanvas sample creates a new multisampled texture and destroys the old one every frame, so that's why its memory usage spikes.
Here is a minimal example:
const device = await (await navigator.gpu.requestAdapter()).requestDevice();
let texture;
function recreateTexture() {
if (texture) {
// Texture memory isn't actually freed until GC on Firefox
texture.destroy();
}
texture = device.createTexture({
size: [800, 800],
format: navigator.gpu.getPreferredCanvasFormat(),
usage: GPUTextureUsage.RENDER_ATTACHMENT,
});
const commandEncoder = device.createCommandEncoder();
const passEncoder = commandEncoder.beginRenderPass({
colorAttachments: [{
view: texture.createView(),
loadOp: "clear",
storeOp: "store",
}]
});
passEncoder.end();
device.queue.submit([commandEncoder.finish()]);
requestAnimationFrame(recreateTexture);
}
requestAnimationFrame(recreateTexture);
I opened an issue in upstream wgpu for the potential cause: https://github.com/gfx-rs/wgpu/issues/7697
Comment 12•3 months ago
|
||
ashivaram264 thanks for fixing this! I confirmed that the fix upstream resolves the issue.
Comment 14•3 months ago
|
||
Copying crash signatures from duplicate bugs.
Assignee | ||
Updated•3 months ago
|
Assignee | ||
Comment 15•3 months ago
|
||
The fix for this has now landed in firefox and is in the latest nightly. The demo is working for me on Mac, but I have the impression this issue was most problematic on Windows. Since Teo verified the fix previously, I am going to close the bug anyways.
Updated•3 months ago
|
Description
•