[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Public WebGL] Lifetime of WebGL objects in Firefox and Webkit
- To: Vladimir Vukicevic <firstname.lastname@example.org>
- Subject: Re: [Public WebGL] Lifetime of WebGL objects in Firefox and Webkit
- From: Kenneth Russell <email@example.com>
- Date: Mon, 27 Jun 2011 11:15:05 -0700
- Cc: Benoit Jacob <firstname.lastname@example.org>, public webgl <email@example.com>, Chris Marrin <firstname.lastname@example.org>
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1309198508; bh=vv1Q91cFqJ48M1jJPNEYGl9fXfQ=; h=MIME-Version:In-Reply-To:References:Date:Message-ID:Subject:From: To:Cc:Content-Type:Content-Transfer-Encoding; b=JN4IW3/Yfl7QDqTdEa6tMcW28qCJ1iccNRFex3/0WbVmlBOjxaS/Ty3n4GkBZXKQ/ 4AO3eMXvOS3z9Q56ywLiw==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=beta; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=COWWT3g1+V3j8YTOneB4k8DYlKmQ7OX6JWW6nTsAMO4=; b=eAOLW7c0NwgOVEL1F7clR2DBQCfdwYlsUQxHcxpNSjLWVZoAG9JjW6aGle8s2BdE0q o4jxYhLN8sWDYYMFM6tQ==
- Domainkey-signature: a=rsa-sha1; c=nofws; d=google.com; s=beta; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=QGK6yBrg4aF0jdFfV9E1tE//XwlGMKxsX7drbaqngktejhqVYYwcMncSYv+4MDvfuq ksnzftUutrI5bhLiJADg==
- In-reply-to: <BANLkTik4NN8w--_a4pe5VpJFbvfp2k1kog@mail.gmail.com>
- List-id: Public WebGL Mailing List <public_webgl.khronos.org>
- References: <1076858097.337214.1309022066203.JavaMail.email@example.com> <788576513.337434.1309027073734.JavaMail.firstname.lastname@example.org> <BANLkTik4NN8w--_a4pe5VpJFbvfp2k1kog@mail.gmail.com>
- Sender: email@example.com
On Sat, Jun 25, 2011 at 4:48 PM, Vladimir Vukicevic <firstname.lastname@example.org> wrote:
> On Sat, Jun 25, 2011 at 2:37 PM, Benoit Jacob <email@example.com> wrote:
>> As far as I can see, in both Firefox and Webkit, the WebGLRenderingContext stores a hash table of reference pointers to all the WebGL objects associated to this context, such as textures.
>> This means that unreferenced objects such as textures are kept alive until the WebGLRenderingContext gets destroyed. The only way to destroy a WebGL texture earlier than the context itself, is to call deleteTexture explicitly.
> I think this is intended, and explicitly allowed by the spec. There's
> no real way to specify GC behaviour, so the only thing that can be
> said is "at some point". Code is explicitly encouraged to use the
> delete* functions to better manage their own resources, because even
> if browsers were to implement better gc semantics, they wouldn't be
> perfect, and objects could accumulate until a gc actually happens.
>> It's easy to imagine (admittedly bad) JS code that would inadvertently cause a leak because of that. Imagine a video player that would create a new texture object for each frame, let it go out of scope and naively expect that to destroy it.
>> Should we implement a change making the WebGLRenderingContext no longer keep WebGL objects alive?
> I don't think it's possible to do this; as I said, there's no way to
> specify gc behaviour, and there's really no concept of "out of scope"
> or anything like that... trying to define it is probably a rat's nest.
Correct. The behavior in the spec was decided upon to avoid
dependencies on the garbage collection algorithm or implementation.
>> The spec also says:
>>> void deleteTexture(WebGLTexture texture) (OpenGL ES 2.0 §3.7.13, man page)
>>> Delete the texture object contained in the passed WebGLTexture as if by calling glDeleteTextures. If the texture has already been deleted the call has no effect. Note that the texture object will be deleted when the WebGLTexture object is destroyed. This method merely gives the author greater control over when the texture object is destroyed.
>> As a naive implementer reading this, my questions is "should deleteTexture actually call glDeleteTextures immediately?", the beginning of the above paragraph suggests so ("as if by calling glDeleteTextures") but the rest casts doubt on that: "Note that the texture object will be deleted when the WebGLTexture object is destroyed." This suggests that the texture object only gets destroyed when the actual WebGLTexture JS object is destroyed i.e. on the next GC after all references to it were lost. In any case, both Firefox and Webkit destroy the texture immediately in deleteTexture.
> This is indeed confusing. I'd suggest something like:
> "Delete the texture object contained in the passed WebGLTexture as if
> by calling glDeleteTextures. If the texture has already been deleted
> the call has no effect. This method is the preferred way to manage
> texture object lifetimes. Merely releasing all references to a
> WebGLTexture object will cause it to be deleted at some point in the
> future, which may mean anything up to and including context
> destruction time."
> I actually don't like the last sentence there all that much; do we
> even need it? (Or just delete the "Note that..." section in the
> current text.) We already have a separate section on object
We could replace that last sentence with a link to the section (3,
"WebGL resources") describing object lifetimes, in order to reduce
duplicated text in the spec.
This rewrite sounds fine to me. Anyone else? Note that this change
would need to be made to all of the delete calls' documentation in the
You are currently subscribed to firstname.lastname@example.org.
To unsubscribe, send an email to email@example.com with
the following command in the body of your email: