Open
Bug 976173
Opened 11 years ago
Updated 2 years ago
preserveDrawingBuffer: false breaks printing of Canvas / WebGL
Categories
(Core :: Graphics: CanvasWebGL, enhancement, P5)
Tracking
()
NEW
People
(Reporter: mpd, Unassigned)
References
Details
(Whiteboard: webgl-internal)
Attachments
(1 file)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36
Steps to reproduce:
Go to www.google.com/maps (opt in to the new Google Maps)
Ensure you're not in lite mode
Try to print
Actual results:
The canvas isn't printed
Expected results:
The canvas should be printed (and is in Chrome).
I've verified this is due to preserveDrawingBuffer:false set when we get the context.
Reporter | ||
Updated•11 years ago
|
Component: General → Canvas: WebGL
Comment 1•11 years ago
|
||
Can we not draw such webgl canvases to a 2d canvas?
http://mxr.mozilla.org/mozilla-central/source/content/html/content/src/HTMLCanvasElement.cpp?rev=fed727c12315&mark=274-274,286-287#270
(I know very little about webgl)
Comment 2•11 years ago
|
||
I understand this reproduces at least on Windows and OS X
OS: Mac OS X → All
Comment 3•11 years ago
|
||
But note that Chrome has the same behavior as we do for this testcase...
Comment 4•11 years ago
|
||
It's possible that printing will need a different way to capture the state of gl canvases. :(
Comment 5•11 years ago
|
||
No, this bug almost certainly falls into the general bucket of "we implement preserveDrawingBuffer:false in the wrong way by not waiting for the next frame to actually start rendering, like we should, before clearing the framebuffer". There is no need to add any specific code paths for printing. Jeff Gilbert or Dan Glastonbury would know more.
Comment 6•11 years ago
|
||
(In reply to Benoit Jacob [:bjacob] from comment #5)
> No, this bug almost certainly falls into the general bucket of "we implement
> preserveDrawingBuffer:false in the wrong way by not waiting for the next
> frame to actually start rendering, like we should, before clearing the
> framebuffer". There is no need to add any specific code paths for printing.
> Jeff Gilbert or Dan Glastonbury would know more.
There's nothing really 'wrong' about what we do WRT pDB:false. Generally, we haven't don't clear a pDB:false frame until about 2-3 frames after it was generated, when we reuse that surface.
The mechanics of pDB:false don't lend themselves to printing, or toDataURL, for that matter. Don't use the pDB:false optimization if you need to do these things. While printing is not mentioned in the spec, our code effectively handles toDataURL and printing similarly, I believe.
"Testcase that shows that we can only paint a gl canvas to a 2d one until composite has happened if preserveDrawingBuffer:false" is almost exactly what the spec says should happen.
Comment 7•11 years ago
|
||
I'll note that while we're spec-compliant, this behavior is not spec-mandated, so we could fix it, if possible.
Severity: normal → enhancement
Status: UNCONFIRMED → NEW
Ever confirmed: true
Updated•11 years ago
|
Hardware: x86 → All
Updated•11 years ago
|
Whiteboard: webgl-internal
Comment 8•11 years ago
|
||
I didn't realize that our behavior here was still spec-compliant; I thought that the spec now mandated preserving the drawing buffer until the next frame starts rendering (i.e. another draw or clear operation is made). Sorry if that was wrong. Can you just explain, since the present testcase doesn't do any draw or clear after the initial frame, why we have to clear the drawing buffer in this case?
Comment 9•11 years ago
|
||
(In reply to Benoit Jacob [:bjacob] from comment #8)
> I didn't realize that our behavior here was still spec-compliant; I thought
> that the spec now mandated preserving the drawing buffer until the next
> frame starts rendering (i.e. another draw or clear operation is made). Sorry
> if that was wrong. Can you just explain, since the present testcase doesn't
> do any draw or clear after the initial frame, why we have to clear the
> drawing buffer in this case?
We don't have the same frame simultaneously in both content and the compositor.
It doesn't matter that the user hasn't drawn, but rather that they drew on the previous frame, and we need to composite that frame. We should be able to add logic to 'hold open a read lock' for the previous frame, but this does add complexity.
Spec on pDB:False:
If this flag is false, attempting to perform operations using this context as a source image after the rendering function has returned can lead to undefined behavior. This includes readPixels or toDataURL calls, or using this context as the source image of another context's texImage2D or drawImage call.
Basically, if when you return from a rendering function, it's like calling SwapBuffers. (unless we haven't Presented to the compositor yet) With pDB:false, your data isn't still there, because you have a new surface to draw into from calling SwapBuffers.
Comment 10•11 years ago
|
||
Got it, thanks. The present bug is RESOLVED INVALID, then. Could we flag the drawingbuffer state as undefined and generate a helpful warning when the result of an operation is consequently undefined (like, here, getting at the drawing buffer's pixels) ?
Comment 11•11 years ago
|
||
(In reply to Benoit Jacob [:bjacob] from comment #10)
> Got it, thanks. The present bug is RESOLVED INVALID, then. Could we flag the
> drawingbuffer state as undefined and generate a helpful warning when the
> result of an operation is consequently undefined (like, here, getting at the
> drawing buffer's pixels) ?
That's a decent idea then. I'm leaving this as 'NEW', since we *could* fix it, even if we don't have to. I have lowered the importance to 'enhancement', which makes it clear from bugzilla search results that this is not a priority, even if it's still open.
Updated•6 years ago
|
Priority: -- → P5
Comment 14•4 years ago
|
||
Jeff, we now can do async operations from printing more easily, do you know what's a good time to read back the 2D / WebGL buffer if any? This may be easy-ish to fix.
Flags: needinfo?(jgilbert)
Updated•4 years ago
|
Summary: preserveDrawingBuffer:false breaks printing → preserveDrawingBuffer: false breaks printing of Canvas / WebGL
Comment 15•4 years ago
|
||
Printing needs to ask the compositor for readback, not webgl. Webgl doesn't per se have access to the data after Presentation with PDB:false.
Flags: needinfo?(jgilbert)
Comment 17•2 years ago
|
||
This is making printouts of Mapbox maps blank, as discovered at https://github.com/webcompat/web-bugs/issues/111242
Given that, perhaps we should we bump the priority of this bug?
Updated•2 years ago
|
Severity: normal → S3
Updated•2 years ago
|
You need to log in
before you can comment on or make changes to this bug.
Description
•