[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Public WebGL] Resurrecting Update Scheduling
- To: Chris Marrin <email@example.com>
- Subject: Re: [Public WebGL] Resurrecting Update Scheduling
- From: Gregg Tavares <firstname.lastname@example.org>
- Date: Thu, 15 Apr 2010 13:48:01 +0800
- Cc: public webgl <email@example.com>
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1271310484; bh=A5J0jVaaxwrOmVhYUPujmt47u4I=; h=MIME-Version:In-Reply-To:References:Date:Message-ID:Subject:From: To:Cc:Content-Type; b=W8tsJHArtXbrNY/v0QheCdSiVdQ+BLxo6hOmPal6w2Fhd/9aF+HtWcgBzQennZppk eV+XD9Ct1Rd3rLVjWu5nQ==
- Domainkey-signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=mime-version:in-reply-to:references:date:message-id:subject:from:to: cc:content-type:x-system-of-record; b=u20lc3Y4Z4aUSS7vXLK9ZA4iDAwZUpNMaaCao2cVGgxLzvLuF7JJQnOEax17SI0jO SIpYxXFO/mZBq7bSvMvhw==
- In-reply-to: <A6758CA2-3274-4120-AA29-9E1F000613A5@apple.com>
- References: <A6758CA2-3274-4120-AA29-9E1F000613A5@apple.com>
- Sender: firstname.lastname@example.org
On Thu, Apr 15, 2010 at 2:16 AM, Chris Marrin <email@example.com>
I've been thinking about WebGL on embedded processors lately. These devices have a couple of constraints that make me want to revive my 'setRenderFunction' proposal from a while back.
The problem is that (at least some of) these devices have constraints on how the rendering engine works that makes them stall more often than desktop OpenGL implementations. For a platform that refreshes at 60Hz, setting a 100Hz timer (which is common in the demos I've seen) means you can stall a lot. That's especially painful for an embedded processor which needs to waste as little time as possible.
Setting a fast timer has other issues for embedded processors. It makes it impossible for the system to throttle back the framerate to conserve battery power or to stop rendering entirely when you switch away from the browser window.
A while back I proposed a update scheduler for WebGL. I think it's especially important for embedded browsers. The issue was actually raised by Gregg who was concerned about useless spinning when the browser is not visible. An update scheduler would solve that problem. I've also included a suggestion from Cedric about being able to know whether or not the context is visible. Here is a revised version of that scheduler proposal:
Suggestion: What about
This has been brought up before but this issue is not unique to WebGL. Apps using the 2d context as well as apps that use just plain HTML both have this issue as well. The example I posted before to show the issue is real was a 2d canvas example and this one is pure HTML.
They are moving stuff around just by repositioning floating DIVs and it has the same problem, it hogs the CPU even when not visible.
This is the WebGL group, not the HTML5 group but it still seems like an opportunity to try to solve this more generally.
The first call would be made to setup the callback function and the target framerate. Whenever you want to update a frame you would call scheduleUpdate() and the callback would be called in the near future. For things like a spinning cube you would call scheduleUpdate() in your updateFunction. To avoid rendering when the canvas is not visible, you can use isContextVisible().
This mechanism would do several things that would be hard or impossible with the existing interval timer:
1) It would fire only once regardless of the number of times scheduleRender() was called.
2) Calls would be throttled to keep framerate at or below targetFramerate.
3) Call frequency can be adjusted to keep intervals consistent. This includes both setting a shorter interval to keep up with targetFramerate and moderating the rate when rendering overhead requires a slower interval than targetFramerate.
4) Call frequency can be reduced on a browser specific basis to keep WebGL from taking up too much CPU.
This system is opt-in. It doesn't prevent a WebGL app from firing timers like today. But it gives authors a tool to write CPU friendly apps, and because of (3) it can smooth out the animation in some cases as well.
You are currently subscribe to firstname.lastname@example.org.
To unsubscribe, send an email to email@example.com with
the following command in the body of your email: