Skip to content

Commit e35bb9a

Browse files
authored
Merge pull request #1414 from LibertyGlobal/RDKDEV-1093_webgl_context_leak_fix
RDKDEV-1093: improve gfx memory handling
2 parents 84f4018 + 059a14d commit e35bb9a

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,13 @@ void WebGLRenderingContextBase::removeActivityStateChangeObserver()
12381238

12391239
WebGLRenderingContextBase::~WebGLRenderingContextBase()
12401240
{
1241+
if (!m_isPendingPolicyResolution) {
1242+
// need to remove from the group first, before we destroy the graphics context
1243+
// othwerwise, in case this is the last context in the group, when the context group tries
1244+
// to cleanup the remaining objects, it will not call deleteImpl (see WebGLObject::deleteObject)
1245+
// since the context is no longer available
1246+
m_contextGroup->removeContext(*this);
1247+
}
12411248
// Remove all references to WebGLObjects so if they are the last reference
12421249
// they will be freed before the last context is removed from the context group.
12431250
m_boundArrayBuffer = nullptr;
@@ -1262,7 +1269,6 @@ WebGLRenderingContextBase::~WebGLRenderingContextBase()
12621269
detachAndRemoveAllObjects();
12631270
loseExtensions(LostContextMode::RealLostContext);
12641271
destroyGraphicsContextGL();
1265-
m_contextGroup->removeContext(*this);
12661272
}
12671273

12681274
{
@@ -1299,6 +1305,8 @@ void WebGLRenderingContextBase::destroyGraphicsContextGL()
12991305
removeActivityStateChangeObserver();
13001306

13011307
if (m_context) {
1308+
// first release the big textures allocated for the FBOs
1309+
m_context->reshape(0,0);
13021310
m_context->setClient(nullptr);
13031311
m_context = nullptr;
13041312
removeActiveContext(*this);

0 commit comments

Comments
 (0)