Skip to content
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

Vulkan Mobile leaks RIDs on exit even in empty project (StorageBuffer, Framebuffer, Texture) #89182

Closed
akien-mga opened this issue Mar 5, 2024 · 6 comments · Fixed by #89531

Comments

@akien-mga
Copy link
Member

Tested versions

  • Reproducible in 4.3.dev (f9ebd84), 4.3-dev1, 4.2.1-stable (didn't test earlier)

System information

Fedora Linux 39 (KDE Plasma) - Wayland - Vulkan (Forward+) - dedicated AMD Radeon RX 7600M XT (RADV NAVI33) () - AMD Ryzen 7 7840HS w/ Radeon 780M Graphics (16 Threads)

Issue description

When exiting the editor after editing a Vulkan Mobile project (empty new project included), the following leaks are reported:

WARNING: 1 RID of type "StorageBuffer" was leaked.
     at: _free_rids (./servers/rendering/rendering_device.cpp:5191)
 - RID:624587029086219
WARNING: 1 RID of type "Framebuffer" was leaked.
     at: _free_rids (./servers/rendering/rendering_device.cpp:5191)
 - RID:625025115750887
WARNING: 4 RIDs of type "Texture" were leaked.
     at: finalize (./servers/rendering/rendering_device.cpp:5344)
 - RID:625020820790930
 - RID:625033705692822
 - RID:625046590594712
 - RID:625059475496602

Running a 3D scene doesn't seem to trigger that leak, so it seems to be specific to the editor, possibly the default preview environment?

CC @godotengine/rendering

Steps to reproduce

  • Create new project with Vulkan Mobile rendering method
  • Open it from a terminal
  • Close and see the leak report

Minimal reproduction project (MRP)

Empty Vulkan Mobile project

@clayjohn
Copy link
Member

clayjohn commented Mar 5, 2024

Marking as a good first issue. It might not be the best issue if you are a total beginner at open source and c++. This is more of a good first issue for someone who has a little bit of experience in open source and/or c++ and is looking for a good first task with Godot

What we need to do is identify what resources have been created that aren't freed at the end. Most likely everything will be within https://github.com/godotengine/godot/blob/master/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp

Resource creation almost always follows the pattern of ***_create() I.e. framebuffer_create() to create framebuffer

When exiting the engine, any resource created by the renderer should be freed in the destructor, You can see a few example there already:

RenderForwardMobile::~RenderForwardMobile() {

@sullyscience
Copy link
Contributor

I can take a look at this.

@BalmundSM
Copy link

BalmundSM commented Mar 12, 2024

After writing this piece of code after line 2840 in destructor I got rid of StorageBuffer warning:

for (uint32_t i = 0; i < RENDER_LIST_MAX; i++) {
  if (scene_state.instance_buffer[i] != RID()) {
    RD::get_singleton()->free(scene_state.instance_buffer[i]);
  }
}

The code is from "render_forward_clustered.cpp". Why was it deleted from mobile part?

@sullyscience
Copy link
Contributor

It looks like that code was missed when the instance data was added to the mobile render (in this commit)

The texture and framebuffer leaks were caused by RenderSceneBuffersRD::allocate_blur_textures()

@BalmundSM
Copy link

It seems this issue fixed by #89531. Why not close it?

@AThousandShips
Copy link
Member

Because it's not merged yet, it's not fixed yet :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants