Closed Bug 748135 Opened 13 years ago Closed 13 years ago

Add takeScreenshot() to nsIDOMWindowUtils

Categories

(Core :: DOM: Core & HTML, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: ttaubert, Assigned: ttaubert)

References

Details

Attachments

(1 file, 3 obsolete files)

Attached patch patch v1 (obsolete) — Splinter Review
This way we don't need a canvas to capture screenshots.
Attachment #617652 - Flags: review?(gavin.sharp)
We can probably remove canvas.mozFetchAsStream(), I don't think anything other than the thumbnail service uses it. I'd file a follow-up for it.
Blocks: 748136
The method needs a security check.
Attached patch patch v2 (obsolete) — Splinter Review
(In reply to Olli Pettay [:smaug] from comment #2) > The method needs a security check. Added. Another thing I noticed is that the screenshots captured aren't scaled down as they were before. I wasn't able to find the code responsible for this in .drawWindow()...
Attachment #617652 - Attachment is obsolete: true
Attachment #617652 - Flags: review?(gavin.sharp)
Attachment #617673 - Flags: review?(gavin.sharp)
Attached patch patch v3 (obsolete) — Splinter Review
Added a gfxContext->Scale() call to let the thumbnail be scaled down accordingly.
Attachment #617673 - Attachment is obsolete: true
Attachment #617673 - Flags: review?(gavin.sharp)
Attachment #617833 - Flags: review?(gavin.sharp)
Attached patch patch v4Splinter Review
Simplified the patch again because imgIEncoder already implements nsIAsyncInputStream.
Attachment #617833 - Attachment is obsolete: true
Attachment #617833 - Flags: review?(gavin.sharp)
Attachment #617840 - Flags: review?(gavin.sharp)
I did some measurements and the results are a bit surprising: The old approach that creates a canvas, calls drawWindow() and mozFetchAsStream() - that still extracts and encodes image data sync - takes on average 50ms. The new approach that calls takeScreenshot() and does the same sync image data encoding takes on average 150ms. Is this maybe because the Azure/Skia backend accelerates the resize/scale operation for canvases? BTW, my machine doesn't support HW accel. It would be interesting to know if mobile actually took a performance hit by implementing bug 724210. They don't seem to scale down and moved the PNG encoding to a different thread (which we could also do?) so that still might be a win...
Comment on attachment 617840 [details] [diff] [review] patch v4 Looks good to me. You should get review from a DOM peer (Olli?) and get feedback from some gfx person about your perf findings, I guess!
Attachment #617840 - Flags: review?(gavin.sharp) → feedback+
Adding khuey and hope he has some idea about the perf issues I'm seeing.
I'm not the right person to ask about gfx perf.
Hmm, that's what I thought. Adding roc to hopefully lighten us up regarding comment #6.
I spoke to Jeff&Joe about this - they weren't sure about why there was a perf difference, but suggested that using RenderDocument still wasn't optimal. They suggested instead adding an API to directly retrieve the drawn data (asynchronously), and then using that instead (which should work fine as long as we only want to capture the selected tab). Would need more feedback from them about how exactly to do that (Jeff suggested discussing it with Bas and roc), but it might be best to WONTFIX this and just focus on that instead.
Marking as WONTFIX based on comment #11.
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → WONTFIX
If you pass the widget_layers flag and the data you are asking for is actually retained we shouldn't need to do any painting, just composite the layer tree to the output context. However there are some things that might prevent that from happening. For the content to be retained it has to actually be visible on screen when you make the call, and you can't pass any flags to drawWindow or RenderDocument that ask for something different then what is drawn on screen.
For example, background tabs don't have any retained content because they are not visible.
The "but it might actually be slower or lower quality than normal" comment in the IDL is slightly worrying, but it sounds like we should get a bug on file to consider using DRAWWINDOW_USE_WIDGET_LAYERS? We currently only care about capturing thumbnails of displayed pages.
I guess it might be slower if its in GPU memory and we have to do readback? I'm not sure. I'm also not sure about the quality part.
The two flags in this patch (RENDER_IGNORE_VIEWPORT_SCROLLING, RENDER_DOCUMENT_RELATIVE) are the bad kind that make the widget layers flag not work so well.
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: