Commit ee89849b by Le Hoang Quyen Committed by Commit Bot

Metal: Fixed memory leak due to the CAMetalLayer still attached to super layer

When destroying SurfaceMtl, the CAMetalLayer should detach from its super layer, otherwise memory leak could happen. This memory leak caused the end2end tests to ran out of memory. Bug: angleproject:2634 Change-Id: I8ea91cccdb42cf0ae8ef807cf01f1e05043dc7c1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2060250 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 5f5292c8
...@@ -226,7 +226,13 @@ void SurfaceMtl::destroy(const egl::Display *display) ...@@ -226,7 +226,13 @@ void SurfaceMtl::destroy(const egl::Display *display)
mDepthTexture = nullptr; mDepthTexture = nullptr;
mStencilTexture = nullptr; mStencilTexture = nullptr;
mCurrentDrawable = nil; mCurrentDrawable = nil;
mMetalLayer = nil; if (mMetalLayer && mMetalLayer.get() != mLayer)
{
// If we created metal layer in SurfaceMtl::initialize(),
// we need to detach it from super layer now.
[mMetalLayer.get() removeFromSuperlayer];
}
mMetalLayer = nil;
} }
egl::Error SurfaceMtl::initialize(const egl::Display *display) egl::Error SurfaceMtl::initialize(const egl::Display *display)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment