Closed Bug 1420382 Opened 7 years ago Closed 5 years ago

WGL context creation doesn't free the dummy context

Categories

(Core :: Graphics: CanvasWebGL, defect, P3)

57 Branch
defect

Tracking

()

RESOLVED DUPLICATE of bug 1347731

People

(Reporter: shimmer.huang, Assigned: jgilbert)

References

Details

(Whiteboard: [gfx-noted])

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0
Build ID: 20171112125346

Steps to reproduce:

The bug is located in source code @reateWindowOffscreenContext() in gfx\gl\GLContextProviderWGL.cpp, looks like a typo .

When the mozillar firefox creates WGL context via CreateWindowOffscreenContext(), it will call into OpenGL driver to create OpenGl context twice, and assign the context handler returned by OpenGL driver to a same variable twice, which means the 1st one would become a *zombie* context which will never be used/deleted. After tens of contexts have been created, OpenGL driver will fail to create new context due to out-of-memory.


Actual results:

In gfx\gl\GLContextProviderWGL.cpp

static already_AddRefed<GLContextWGL>
CreateWindowOffscreenContext()
{
    ....

    HGLRC context = sWGLLib.mSymbols.fCreateContext(dc);                      ------------>1st time to call wglCreateContext to create context
    if (sWGLLib.HasRobustness()) {
        int attribs[] = {
            LOCAL_WGL_CONTEXT_FLAGS_ARB, LOCAL_WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB,
            LOCAL_WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, LOCAL_WGL_LOSE_CONTEXT_ON_RESET_ARB,
            0
        };

        context = sWGLLib.mSymbols.fCreateContextAttribsARB(dc, nullptr, attribs);
    } else {
        context = sWGLLib.mSymbols.fCreateContext(dc);    ------------>2nd time to call wglCreateContext to create context

    }

    if (!context) {
        return nullptr;
    }

    SurfaceCaps caps = SurfaceCaps::ForRGBA();
    RefPtr<GLContextWGL> glContext = new GLContextWGL(CreateContextFlags::NONE, caps,
                                                      true, dc, context, win);
    return glContext.forget();
}


Expected results:

We should not do the 1st call for wglCreateContext().
More information, this issue would result some WebGL CTS cases fail in Win7.
Flags: needinfo?(shimmer.huang)
Component: Untriaged → Canvas: WebGL
Product: Firefox → Core
(Don't know this code well) Jeff, does this look right to you? As easy to fix as it looks?
Flags: needinfo?(jgilbert)
Whiteboard: [gfx-noted]
We must have lost the delete somewhere.
Assignee: nobody → jgilbert
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(jgilbert)
Summary: WGL context creation Typo in CreateWindowOffscreenContext() → WGL context creation doesn't free the dummy context
Issue still observed with latest Firefox v.57.0.2
Severity: normal → enhancement
Status: NEW → RESOLVED
Closed: 5 years ago
Flags: needinfo?(shimmer.huang)
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.