szeged / webrender

A GPU-based renderer for the web
https://doc.servo.org/webrender/
Mozilla Public License 2.0
45 stars 7 forks source link

Memory leak #288

Open SergeevPavel opened 5 years ago

SergeevPavel commented 5 years ago

Hi, thank for your great work. I doing some experiments on using webrender as a renderer for our ui framework and have faced with couple of problems.

I have simple example, that runs on mac os with metal backend. On every frame it sends display list with two rectangles. The problem with this is constant grow of used memory, according to profile on every frame render_impl allocates memory that will never be freed.

Second problem is about jni and shader recompilation. When I do same thing like in first example but throw jni most calls of submit_to_gpu return false (particularly error is OutOfDate, but according to this comment I'm not sure, that it's relevant) which leads to swapchain recreation and shader recompilation. Shader recompilation took time and also lead to huge memory leak.

I use macos 10.14.5 with Intel Iris Pro 1536 MB I will be very grateful if you give me some thoughts about this examples

zakorgy commented 5 years ago

@SergeevPavel thanks for the bug report. I am glad to see, that our work is used in a project. For the first problem: I will look into the issue. For the second part. Unfortunately I'm not really familiar with jni, and if you want to know more about that comment, maybe @kvark or @omni-viral could give you a proper explanation about that. For the shader recompilation part, if gfx-backend-metal will have a pipeline cache API like Vulkan it will be faster, the second part bothers me because I thought we are destroying the programs properly. I will try to look in that too.

kvark commented 5 years ago

I don't understand that part about jni. Please describe in more detail.

SergeevPavel commented 5 years ago

I'm working on lib that wrap webrender into jni interface. When I trying to run event loop on jvm thread it leads to constant errors from gfx-metal inside of render_impl. I don't understand how it connected, but I suppose it maybe explained throw some conflict of own jvm graphics code and gfx-metal. If it will be helpful I will try to reduce example from my lib and attach it here.

Second thing is that every swapchain_recreation consume bunch of memory, that leads to total used memory grow. I'm no sure but for me it also looks like mem leak.

kvark commented 5 years ago

Thank you for the info @SergeevPavel ! For memory leaks, we are aware that IOSurface objects get lost somehow on resize, and are looking into it.