Re: [whatwg] Hardware accelerated canvas

2012-09-05 Thread Jonas Sicking
On Tue, Sep 4, 2012 at 10:15 AM, Boris Zbarsky bzbar...@mit.edu wrote: So now our list is: 1) Have a way for pages to opt in to software rendering. 2) Opt canvases in to software rendering via some sort of heuristic (e.g. software by default until there has been drawing to it for

Re: [whatwg] Hardware accelerated canvas

2012-09-05 Thread Benoit Jacob
- Original Message - On Tue, Sep 4, 2012 at 10:15 AM, Boris Zbarsky bzbar...@mit.edu wrote: So now our list is: 1) Have a way for pages to opt in to software rendering. 2) Opt canvases in to software rendering via some sort of heuristic (e.g. software by default until

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Robert O'Callahan
We might be able to do some sort of hack where if a 2D canvas isn't drawn to for a while (say five seconds), we read back a copy of it for safe-keeping. I have to say though, we've been shipping 2D canvas with the context-loss problem to millions of users for a couple of years now and I don't

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Erik Möller
On Mon, 03 Sep 2012 23:47:57 +0200, Tobie Langel tobie.lan...@gmail.com wrote: I apologize in advance, as this is slightly off-topic. I've been unsuccessfully looking for info on how Canvas hardware acceleration actually works and haven't found much. Would anyone have pointers? Thanks.

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread James Robinson
I believe this ship has already sailed for the most part - several major browsers (starting with IE9) have shipped GPU based canvas 2d implementations that simply lose the image buffer on a lost context. Given that there are a fair number of benchmarks (of varying quality) around canvas 2d speed

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Boris Zbarsky
On 9/4/12 12:30 PM, James Robinson wrote: Many applications redraw the entire canvas on every frame This is already assuming there are frames involved. There are lots of applications (graphing comes to mind!) where you really want the canvas to be essentially a write-once-read-forever image.

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Boris Zbarsky
On 9/4/12 12:43 PM, Boris Zbarsky wrote: 1) Have a way for pages to opt in to software rendering. 2) Opt canvases in to software rendering via some sort of heuristic (e.g. software by default until there has been drawing to it for several event loop iterations, or whatever). 3) Have

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread David Geary
On Tue, Sep 4, 2012 at 10:43 AM, Boris Zbarsky bzbar...@mit.edu wrote: On 9/4/12 12:30 PM, James Robinson wrote: Many applications redraw the entire canvas on every frame This is already assuming there are frames involved. There are lots of applications (graphing comes to mind!) where you

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread David Geary
On Tue, Sep 4, 2012 at 10:53 AM, Boris Zbarsky bzbar...@mit.edu wrote: On 9/4/12 12:43 PM, Boris Zbarsky wrote: 1) Have a way for pages to opt in to software rendering. 2) Opt canvases in to software rendering via some sort of heuristic (e.g. software by default until there has been

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Tab Atkins Jr.
On Tue, Sep 4, 2012 at 10:07 AM, David Geary david.mark.ge...@gmail.com wrote: On Tue, Sep 4, 2012 at 10:53 AM, Boris Zbarsky bzbar...@mit.edu wrote: Ms2ger points out (without endorsing) that there's an: 8) Have every author who wants their canvas to stick around call toDataURL() and stick

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Boris Zbarsky
On 9/4/12 1:02 PM, David Geary wrote: Sure, but those use cases will be in the minority What makes you say that? Outside of games, I think they're a majority of the canvas-using things I've seen. I think it makes the most sense to add a context lost handler to the spec and leave it up to

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Boris Zbarsky
On 9/4/12 1:07 PM, David Geary wrote: And then the browser presumably uses the img to regenerate the canvas on a lost context? No, then the author just forgets about the broken-ass canvas and shows the img to the user. Basically using a canvas as a transient buffer to get the image data

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Glenn Maynard
On Tue, Sep 4, 2012 at 11:43 AM, Boris Zbarsky bzbar...@mit.edu wrote: 2) Opt canvases in to software rendering via some sort of heuristic (e.g. software by default until there has been drawing to it for several event loop iterations, or whatever). 4) Auto-snapshot based on some

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Mark Callow
On 12/09/04 10:02, David Geary wrote: Sure, but those use cases will be in the minority, and we're already talking about a very rare occurrence in the first place, so the odds of a very expensive regeneration on a lost context must be near Lotto levels. It is not a rare occurrence on mobile

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Szymon Piłkowski
On 4 September 2012 19:15, Boris Zbarsky bzbar...@mit.edu wrote: On 9/4/12 1:02 PM, David Geary wrote: Sure, but those use cases will be in the minority What makes you say that? Outside of games, I think they're a majority of the canvas-using things I've seen. I'd like to point out

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Ian Hickson
On Mon, 3 Sep 2012, Glenn Maynard wrote: As Erik said, taking a snapshot of the canvas is very expensive on some platforms. If you're rendering a game in realtime, you never have a time out where you can tolerate an expensive readback. If you're rendering a game in realtime, the issue

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread David Geary
On Tue, Sep 4, 2012 at 11:12 AM, Tab Atkins Jr. jackalm...@gmail.comwrote: On Tue, Sep 4, 2012 at 10:07 AM, David Geary david.mark.ge...@gmail.com wrote: On Tue, Sep 4, 2012 at 10:53 AM, Boris Zbarsky bzbar...@mit.edu wrote: Ms2ger points out (without endorsing) that there's an: 8)

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Boris Zbarsky
On 9/4/12 1:20 PM, Glenn Maynard wrote: The only reason I can think of switch renderers, instead of snapshotting, is to deal with losing the context *mid*-render, while a script is still drawing. (That seems like a problem so rare as to be almost theoretical, though.) The main reason to

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Justin Novosad
On Tue, Sep 4, 2012 at 10:22 AM, Mark Callow callow_m...@hicorp.co.jpwrote: It is not a rare occurrence on mobile devices. On my tablet WebGL app's lose their context every time the tablet goes to sleep. Since the timeout is so short, it only take a brief distraction and poof! the tablet is

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Ashley Gullen
It sounds like the real issue is mobile: - it seems pretty difficult to make a desktop lose a context - most mobile browsers still use software rendering, or at least haven't had GPU acceleration very long, so there are unlikely to be bug reports about it - it sounds like mobile devices lose

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Justin Novosad
On Tue, Sep 4, 2012 at 11:04 AM, Ashley Gullen ash...@scirra.com wrote: It sounds like the real issue is mobile: - it seems pretty difficult to make a desktop lose a context - most mobile browsers still use software rendering, or at least haven't had GPU acceleration very long, so there are

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Erik Möller
On Tue, 04 Sep 2012 19:15:46 +0200, Boris Zbarsky bzbar...@mit.edu wrote: On 9/4/12 1:02 PM, David Geary wrote: Sure, but those use cases will be in the minority What makes you say that? Outside of games, I think they're a majority of the canvas-using things I've seen. I think it makes

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Kornel Lesiński
On Tue, 04 Sep 2012 19:35:32 +0100, Justin Novosad ju...@chromium.org wrote: That doesn't sound too evil, but the ideal solution would be one that would not involve web standards at all. If there was a way of ensuring GPU resource persistence on mobile platforms (swap-out resources rather

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Kornel Lesiński
On Tue, 04 Sep 2012 17:43:11 +0100, Boris Zbarsky bzbar...@mit.edu wrote: 5) Save command stream. 6) Have a way for pages to explicitly snapshot a canvas. 7) Require opt in for hardware accelerated rendering. Any others? Of the above, I don't think #5 and #7 are realistic, for what it's

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Erik Möller
On Tue, 04 Sep 2012 20:49:57 +0200, Kornel Lesiński kor...@geekhood.net wrote: until improvements in OS/drivers/hardware make this a non-issue (e.g. if the OS can notify applications before gfx context is lost, then browsers could snapshot then and problem will be gone for good) We've

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Jussi Kalliokoski
This might be a silly idea, but what about this: When all references to the context are lost (garbage collected), simply store the image on the canvas and make it behave like it was just an image. This would lose all the state of the context, but since the problem seems to be mostly with things

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Glenn Maynard
(some quotes restored) On Tue, Sep 4, 2012 at 12:28 PM, Ian Hickson i...@hixie.ch wrote: Realistically, there are too many pages that have 2D canvases that are drawn to once and never updated for any solution other than don't lose the data to be adopted. How exactly this is implemented

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Boris Zbarsky
On 9/4/12 3:17 PM, Jussi Kalliokoski wrote: When all references to the context are lost (garbage collected) That never happens while the canvas itself is alive, since if nothing else the canvas has a reference to the context. -Boris

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Jussi Kalliokoski
Hmm... Is it visible to the page outside getContext() ? On Tue, Sep 4, 2012 at 10:21 PM, Boris Zbarsky bzbar...@mit.edu wrote: On 9/4/12 3:17 PM, Jussi Kalliokoski wrote: When all references to the context are lost (garbage collected) That never happens while the canvas itself is alive,

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Oliver Hunt
The context is owned by the canvas element. If the canvas element is still alive then by definition so is the context. --Oliver On Sep 4, 2012, at 12:31 PM, Jussi Kalliokoski jussi.kallioko...@gmail.com wrote: Hmm... Is it visible to the page outside getContext() ? On Tue, Sep 4, 2012 at

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Boris Zbarsky
On 9/4/12 3:31 PM, Jussi Kalliokoski wrote: Hmm... Is it visible to the page outside getContext() ? No. Why does that matter? -Boris

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Jussi Kalliokoski
I'm just wondering if there's a way to detect if the canvas was made with the purpose of drawing a static image. On providing a better way for those single shot canvases to make sure that the image is preserved, I think one way would be to add a complementing method to toDataURL(), being

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Rik Cabanier
Rereading the mail thread, it seems like most people want/can live with a callback that informs the developer that the canvas needs to be recreated. If the developer doesn't use this new feature, he will get current behavior where the browser will do snapshotting at reasonable intervals (or fail

Re: [whatwg] Hardware accelerated canvas

2012-09-04 Thread Charles Pritchard
On 9/4/2012 10:12 PM, Rik Cabanier wrote: Rereading the mail thread, it seems like most people want/can live with a callback that informs the developer that the canvas needs to be recreated. Wouldn't this be more appropriate as a webgl-2d extension? It seems like webgl support is a

Re: [whatwg] Hardware accelerated canvas

2012-09-03 Thread Erik Möller
On Mon, 03 Sep 2012 00:14:49 +0200, Benoit Jacob bja...@mozilla.com wrote: - Original Message - On Sun, 2 Sep 2012, Erik Möller wrote: As we hardware accelerate the rendering of , not just with the webgl context, we have to figure out how to best handle the fact that GPUs loose

Re: [whatwg] Hardware accelerated canvas

2012-09-03 Thread Erik Möller
On Mon, 03 Sep 2012 03:37:24 +0200, Charles Pritchard ch...@jumis.com wrote: Canvas GPU acceleration today is done via transform3d and transitions. I hope everyone are aware that this connection is just coincidental. The fact that one vendor decided to flip the hardware acceleration

Re: [whatwg] Hardware accelerated canvas

2012-09-03 Thread Benoit Jacob
- Original Message - On Mon, 03 Sep 2012 00:14:49 +0200, Benoit Jacob bja...@mozilla.com wrote: - Original Message - On Sun, 2 Sep 2012, Erik Möller wrote: As we hardware accelerate the rendering of , not just with the webgl context, we have to figure out how

Re: [whatwg] Hardware accelerated canvas

2012-09-03 Thread Benoit Jacob
- Original Message - What is really meant here by Canvas GPU acceleration? This means use GL/D3D to implement the 2D canvas drawing primitives; but what really matters here, is that this requires using a GL/D3D texture/surface as the primary storage for the 2D canvas drawing buffer.

Re: [whatwg] Hardware accelerated canvas

2012-09-03 Thread Ian Hickson
On Sun, 2 Sep 2012, Benoit Jacob wrote: Realistically, there are too many pages that have 2D canvases that are drawn to once and never updated for any solution other than don't lose the data to be adopted. How exactly this is implemented is a quality of implementation issue. With

Re: [whatwg] Hardware accelerated canvas

2012-09-03 Thread Glenn Maynard
On Mon, Sep 3, 2012 at 11:11 AM, Ian Hickson i...@hixie.ch wrote: There are ways to make it work without forgoing acceleration, e.g. taking regular backups of the canvas contents, remembering every instruction that was sent to the canvas, etc. As Erik said, taking a snapshot of the canvas is

Re: [whatwg] Hardware accelerated canvas

2012-09-03 Thread David Geary
On Mon, Sep 3, 2012 at 7:21 AM, Benoit Jacob bja...@mozilla.com wrote: - Original Message - What is really meant here by Canvas GPU acceleration? This means use GL/D3D to implement the 2D canvas drawing primitives; but what really matters here, is that this requires using a GL/D3D

Re: [whatwg] Hardware accelerated canvas

2012-09-03 Thread Rik Cabanier
On Mon, Sep 3, 2012 at 10:31 AM, David Geary david.mark.ge...@gmail.comwrote: On Mon, Sep 3, 2012 at 7:21 AM, Benoit Jacob bja...@mozilla.com wrote: - Original Message - What is really meant here by Canvas GPU acceleration? This means use GL/D3D to implement the 2D canvas

Re: [whatwg] Hardware accelerated canvas

2012-09-03 Thread Tobie Langel
I apologize in advance, as this is slightly off-topic. I've been unsuccessfully looking for info on how Canvas hardware acceleration actually works and haven't found much. Would anyone have pointers? Thanks. --tobie

[whatwg] Hardware accelerated Canvas

2012-09-03 Thread Saurabh Jain
Hi, Hardware accelerated Canvas is a necessity. If it is not done than HTML5 will never be able to compete with native platforms. Most applications need 2D rendering for UI but application developers these days demand at par performance with native counterparts. WebGL is not a good option for 2D

[whatwg] Hardware accelerated canvas

2012-09-02 Thread Erik Möller
As we hardware accelerate the rendering of canvas, not just with the webgl context, we have to figure out how to best handle the fact that GPUs loose the rendering context for various reasons. Reasons for loosing the context differ from platform to platform but ranges from going into

Re: [whatwg] Hardware accelerated canvas

2012-09-02 Thread Ashley Gullen
Why is it prohibitively expensive to handle a lost context automatically in a canvas 2D? Having written a 2D engine which supports this (albeit in DirectX), don't you just need to recreate the surface, set up your render state again, recreate any textures that were referenced, then continue? (In

Re: [whatwg] Hardware accelerated canvas

2012-09-02 Thread Glenn Maynard
On Sun, Sep 2, 2012 at 12:13 PM, Ashley Gullen ash...@scirra.com wrote: Why is it prohibitively expensive to handle a lost context automatically in a canvas 2D? Having written a 2D engine which supports this (albeit in DirectX), don't you just need to recreate the surface, set up your render

Re: [whatwg] Hardware accelerated canvas

2012-09-02 Thread Ian Hickson
On Sun, 2 Sep 2012, Erik Möller wrote: As we hardware accelerate the rendering of canvas, not just with the webgl context, we have to figure out how to best handle the fact that GPUs loose the rendering context for various reasons. Reasons for loosing the context differ from platform to

Re: [whatwg] Hardware accelerated canvas

2012-09-02 Thread Benoit Jacob
- Original Message - On Sun, 2 Sep 2012, Erik Möller wrote: As we hardware accelerate the rendering of , not just with the webgl context, we have to figure out how to best handle the fact that GPUs loose the rendering context for various reasons. Reasons for loosing the

Re: [whatwg] Hardware accelerated canvas

2012-09-02 Thread Rik Cabanier
On Sun, Sep 2, 2012 at 2:24 PM, Ian Hickson i...@hixie.ch wrote: On Sun, 2 Sep 2012, Erik Möller wrote: As we hardware accelerate the rendering of canvas, not just with the webgl context, we have to figure out how to best handle the fact that GPUs loose the rendering context for

Re: [whatwg] Hardware accelerated canvas

2012-09-02 Thread Glenn Maynard
On Sun, Sep 2, 2012 at 4:24 PM, Ian Hickson i...@hixie.ch wrote: Realistically, there are too many pages that have 2D canvases that are drawn to once and never updated for any solution other than don't lose the data to be adopted. How exactly this is implemented is a quality of implementation

Re: [whatwg] Hardware accelerated canvas

2012-09-02 Thread Charles Pritchard
On 9/2/2012 5:36 PM, Glenn Maynard wrote: On Sun, Sep 2, 2012 at 4:24 PM, Ian Hickson i...@hixie.ch wrote: Realistically, there are too many pages that have 2D canvases that are drawn to once and never updated for any solution other than don't lose the data to be adopted. How exactly this is