maierfelix / maierfelix/webgpu

Resource leak in GPUCanvasContext::getSwapChainPreferredFormat

Open
#35 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
248
Forks
17
PR merge metrics
No merged PRs in 30d

Description

It appears that the new WGPUSwapChainImpl pointer returned by wgpuDeviceCreateSwapChain() does not get deleted; this causes AddressSanitizer to flag the leak. See the instance variable in the code snippet below:

  if (window->preferredSwapChainFormat == WGPUTextureFormat_Undefined) {
    WGPUSwapChainDescriptor descriptor;
    descriptor.nextInChain = nullptr;
    // returns always the same address, so we dont have to release this temp swapchain?
    descriptor.implementation = device->binding->GetSwapChainImplementation();
    WGPUSwapChain instance = wgpuDeviceCreateSwapChain(device->instance, nullptr, &descriptor);
    glfwPollEvents();
    window->preferredSwapChainFormat = device->binding->GetPreferredSwapChainTextureFormat();
  }

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at GPUCanvasContext::getSwapChainPreferredFormat and inspect the instance variable created by wgpuDeviceCreateSwapChain(). Use AddressSanitizer to reproduce the reported leak, then verify that the temporary swap chain is released and the sanitizer no longer reports it.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
computer-graphics
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.