[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] WEBGL_lose_context



What makes the problem especially horrible is that it is the _javascript_ garbage collector, which is ultimately responsible deleting the rendering context, may have triggers based on memory consumption, but I doubt there are many (if any) JS engines that track GPU resource usage. 

With 2D canvas, there is the simple trick of resizing the canvas to 0 before letting it go out of scope, which effectively eagerly deletes the canvas's pixel buffer, which is all we really care about in that case.

With a WebGL canvas, that trick will only release the drawing buffer resources, everything else in the context would need to be deleted manually.

Ideally, web devs should not have to worry about this, and the browser should just do the right thing, but unfortunately OpenGL just doesn't have good resource tracking APIs that could be used to trigger GCs.

On Tue, Nov 8, 2016 at 10:17 AM, Jukka Jylänki <jujjyl@gmail.com> wrote:

I agree and have myself sometimes pondered about how to kill a context explicitly, and there's no way other than to release refs to all GL objects and leave it to the GC. It would be nice to have an explicit API, although the lose_context extension is not it (and shouldn't be), because it matches the resource loss semantics from the system, to solve another problem, and not the context itself. It would be nice to have a deleteContext() feature, since otherwise getContext()ing something effectively "taints" the <canvas> and ties it to that context type for its remaining lifetime, which is a bit messy. Not critical, but agree this is a bit dirty part if the API.


On Nov 7, 2016 4:24 PM, "Ryan Patterson" <ryan.goat@gmail.com> wrote:
Unfortunately I have been unable to find the deleteContext function in the canvas API.  Some implementations keep webGL contexts around even after all references are set to null.  The WEBGL_lose_context extension seems to be the only way to declare you are finished with a context and free the context resource itself in a deterministic manor.
_____________
Ryan Patterson

On Fri, Nov 4, 2016 at 1:45 PM, Kenneth Russell <kbr@google.com> wrote:
This deliberately isn't specified. If you're looking for a way to free your application's resources, you should use the various delete* APIs.

-Ken


On Fri, Nov 4, 2016 at 10:28 AM, <omarhuseynov97@gmail.com> wrote:

It says the extension “WEBGL_lose_context” simulates webgl context loss. Does it mean the browser actually frees the resources on the GPU allocated by the webgl context or just pretends that it did?

 

-         Omar