Page.captureScreenshot() fails when running --headless
Reported by
rutterp...@gmail.com,
Apr 21 2017
|
|||||||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36 Steps to reproduce the problem: 1. Run Chromium with --headless flag 2. Use "chrome-remote-interface" (nodejs module) to capture page screenshot (Page.captureScreenshot()), or follow the steps described on http://www.abhishekshukla.com/chrome/capture-screenshot-in-chrome-without-any-tool-plugin-extension/ to capture a screenshot What is the expected behavior? Screenshot is created, callback is called (when using chrome-remote-interface). What went wrong? Exception occurs: Chrome stderr [0421/101318.467:ERROR:snapshot_win.cc(56)] Failed to print window: Invalid window handle. (0x578) Chrome stderr [0421/101318.467:ERROR:snapshot_win.cc(144)] NOT IMPLEMENTED Did this work before? N/A Does this work in other browsers? N/A Chrome version: 60.0.3078.0 Channel: dev OS Version: 10.0 Flash Version:
,
Apr 24 2017
,
Apr 25 2017
,
Apr 25 2017
I haven't been able to reproduce this issue on 60.0.3081.0 anymore, although the screenshots that are created are blank/have no content. See the attached file for an example.
,
Apr 25 2017
It works for me when the "--disable-gpu" flag is passed in along with "--headless".
,
Apr 26 2017
Are you running the same version (60.0.3081.0)? And also, on windows? I'm also passing --disable-gpu.
,
Apr 27 2017
David, do you remember if we're supposed to end up in snapshot_win.cc in headless mode? I'd expect us to use the aura path instead.
,
Apr 27 2017
I'll take a look, afaik --screenshot flag essentially uses the same devtools command, so I'm surprised Page.captureScreenshot doesn't work. It might be a matter of plumbing it correctly anyway, similar to Mac.
,
May 2 2017
,
May 9 2017
I'm not sure this is unique to Windows. I'm seeing this on Mac Canary 60.0.3093.0.
/Applications/Chromium.app/Contents/MacOS/Chromium \
--headless \
--disable-gpu \
--remote-debugging-port=9222
const fs = require('fs');
const chrome = require('chrome-remote-interface');
chrome(async protocol => {
const {Page} = protocol;
await Page.enable();
Page.navigate({url: 'https://www.chromestatus.com/features'});
Page.loadEventFired(async timestamp => {
const {data} = await Page.captureScreenshot();
fs.writeFileSync('screenshot.png', data, 'base64');
protocol.close();
});
});
screenshot.png is 1px,1px. Adding --window-size=1280,1696 makes no difference.
,
May 9 2017
,
May 9 2017
This looks like maybe you're not setting fromSurface=true in the CaptureScreenshot command params? I think headless on windows (and possibly mac?) currently only supports screenshots from the surface. I think maybe we should be forcing fromSurface=true for headless in general, since anything else doesn't really make sense in headless mode.
,
May 9 2017
You are right Erick, I'll see if it can be forced in headless, otherwise adding fromSurface=true should fix it
,
May 9 2017
,
May 10 2017
Able to reproduce this on macOS Sierra
,
May 11 2017
Issue 719900 has been merged into this issue.
,
May 13 2017
fromSurface=True does not seem to resolve the blank screenshots on Mac Sierra for 59.0.3071.47 (Official Build) beta (64-bit).
,
May 15 2017
Hey scott. I can't reproduce your error: /Applications/Google\ Chrome\ 3.app/Contents/MacOS/Google\ Chrome --version Google Chrome 59.0.3071.47 beta $ /Applications/Google\ Chrome\ 3.app/Contents/MacOS/Google\ Chrome --headless --screenshot=headless.png --disable-gpu http://www.example.com [0515/104708.382429:INFO:headless_shell.cc(436)] Written to file headless.png. Note that the screenshot flag calls Page.CaptureScreenshot(fromSurface=true)
,
May 15 2017
dvallet: I'll prepare a test case. Note that we're attempting to screenshot a canvas element.
The same application works fine when --headless is removed, and --screenshot works fine for us as well.
Here's how we're calling for the screenshot:
data = {
"id": self._get_request_id(),
"method": "Page.captureScreenshot",
"fromSurface": True,
}
And what we receive:
{"id":5,"result":{"data":"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAAtJREFUCB1jYAACAAAFAAGNu5vzAAAAAElFTkSuQmCC"}}
Again, removing --headless causes the same call to return a 2.5M image.
,
May 15 2017
,
May 15 2017
#19: Do things work if you try capturing something that isn't a canvas?
,
May 15 2017
#21 It does not work. I modified the code to put some text and a number in a div instead of drawing on a canvas. Same issue: non-headless downloads a valid PNG, headless is empty.
,
May 17 2017
,
May 18 2017
https://codereview.chromium.org/2871113002/ is the CL changing the default value of the fromSurface argument in the Page.captureScreenshot API. https://codereview.chromium.org/2887023002/ is the CL changing Telemetry to pass "false" for the fromSurface argument all the time. It's important for Chrome's GPU tests that this at least remain an option, even once Telemetry is updated with headless support. I'd appreciate it if we could land https://codereview.chromium.org/2887023002/ and let Telemetry roll forward before landing https://codereview.chromium.org/2871113002/ . This will avoid losing coverage of important code paths on the tryservers.
,
May 18 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/6f8d636e0a218db1d2b6bee09250566a89eaa02c commit 6f8d636e0a218db1d2b6bee09250566a89eaa02c Author: catapult-deps-roller@chromium.org <catapult-deps-roller@chromium.org> Date: Thu May 18 07:51:55 2017 Roll src/third_party/catapult/ d76621c5e..dd9db5d3f (5 commits) https://chromium.googlesource.com/external/github.com/catapult-project/catapult.git/+log/d76621c5ec84..dd9db5d3f658 $ git log d76621c5e..dd9db5d3f --date=short --no-merges --format='%ad %ae %s' 2017-05-17 kbr Pass False for fromSurface argument to Page.captureScreenshot. 2017-05-17 rnephew [Telemetry] Rename DisableBenchmark to PermenantlyDisableBenchmark in StoryExpectations 2017-05-17 sullivan Fix typo in api documentation 2017-05-17 kbr Expose browser command line via SystemInfo. 2017-05-17 sullivan Add documenation on the alert list JSON format. Created with: roll-dep src/third_party/catapult BUG= 714058 ,711065, 718635 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, see: http://www.chromium.org/developers/tree-sheriffs/sheriff-details-chromium#TOC-Failures-due-to-DEPS-rolls CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_optional_gpu_tests_rel TBR=sullivan@chromium.org Change-Id: I7d0e18ec4ac4032ca270f38f6f406bf1357a33f0 Reviewed-on: https://chromium-review.googlesource.com/508260 Reviewed-by: <catapult-deps-roller@chromium.org> Commit-Queue: <catapult-deps-roller@chromium.org> Cr-Commit-Position: refs/heads/master@{#472727} [modify] https://crrev.com/6f8d636e0a218db1d2b6bee09250566a89eaa02c/DEPS
,
May 24 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/54bf385aa6becac4aeecd2bf79604bc9421b6306 commit 54bf385aa6becac4aeecd2bf79604bc9421b6306 Author: catapult-deps-roller@chromium.org <catapult-deps-roller@chromium.org> Date: Wed May 24 03:47:30 2017 Roll src/third_party/catapult/ 51b31788b..f136f4800 (2 commits) https://chromium.googlesource.com/external/github.com/catapult-project/catapult.git/+log/51b31788b65c..f136f480014c $ git log 51b31788b..f136f4800 --date=short --no-merges --format='%ad %ae %s' 2017-05-23 rnephew [Telemetry] Add android device specific test conditions to StoryExpectations 2017-05-23 kbr Fixed specification of Page.captureScreenshot's fromSurface argument. Created with: roll-dep src/third_party/catapult BUG=711065, 714058 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, see: http://www.chromium.org/developers/tree-sheriffs/sheriff-details-chromium#TOC-Failures-due-to-DEPS-rolls CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_optional_gpu_tests_rel TBR=sullivan@chromium.org Change-Id: I5b265c2cf360b33111f678fed0abf43c32790fbf Reviewed-on: https://chromium-review.googlesource.com/513473 Reviewed-by: <catapult-deps-roller@chromium.org> Commit-Queue: <catapult-deps-roller@chromium.org> Cr-Commit-Position: refs/heads/master@{#474152} [modify] https://crrev.com/54bf385aa6becac4aeecd2bf79604bc9421b6306/DEPS
,
May 24 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/b7b00695911984b3be8f9e7894ac84123136e38e commit b7b00695911984b3be8f9e7894ac84123136e38e Author: dvallet <dvallet@chromium.org> Date: Wed May 24 08:04:43 2017 Change from_surface default value to true BUG= 714058 Review-Url: https://codereview.chromium.org/2871113002 Cr-Commit-Position: refs/heads/master@{#474207} [modify] https://crrev.com/b7b00695911984b3be8f9e7894ac84123136e38e/content/browser/devtools/protocol/page_handler.cc [modify] https://crrev.com/b7b00695911984b3be8f9e7894ac84123136e38e/headless/app/headless_shell.cc [modify] https://crrev.com/b7b00695911984b3be8f9e7894ac84123136e38e/headless/lib/headless_web_contents_browsertest.cc [modify] https://crrev.com/b7b00695911984b3be8f9e7894ac84123136e38e/third_party/WebKit/Source/core/inspector/browser_protocol.json
,
May 30 2017
This should be working now
,
May 31 2017
@dvallet@chrominum.org - do I need to download new chromedriver or chrome build for this?
,
May 31 2017
You should be fine if you use chrome canary, otherwise the change will trickle down to dev/beta/stable eventually |
|||||||||||||
►
Sign in to add a comment |
|||||||||||||
Comment 1 by rutterp...@gmail.com
, Apr 21 2017