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: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Le Hoang Quyen 2020-02-17 22:47:57 +08:00 коммит произвёл Commit Bot
Родитель 5f5292c86e
Коммит ee89849b7c
1 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -226,7 +226,13 @@ void SurfaceMtl::destroy(const egl::Display *display)
mDepthTexture = nullptr;
mStencilTexture = nullptr;
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)