Taking screenshots of long pages silently fails
Categories
(DevTools :: General, defect, P2)
Tracking
(firefox77 fixed)
Tracking | Status | |
---|---|---|
firefox77 | --- | fixed |
People
(Reporter: RNicoletto, Assigned: nchevobbe)
References
(Depends on 1 open bug, )
Details
(Keywords: testcase, Whiteboard: [polish-backlog][difficulty=medium])
Attachments
(2 files, 3 obsolete files)
Updated•12 years ago
|
Reporter | ||
Comment 1•12 years ago
|
||
Updated•12 years ago
|
Comment 2•12 years ago
|
||
Comment 3•12 years ago
|
||
Comment 4•12 years ago
|
||
Comment 5•12 years ago
|
||
Comment 6•12 years ago
|
||
Comment 7•12 years ago
|
||
Comment 8•12 years ago
|
||
Comment 9•12 years ago
|
||
Comment 10•12 years ago
|
||
Comment 11•12 years ago
|
||
Comment 12•12 years ago
|
||
Comment 14•12 years ago
|
||
Comment 15•12 years ago
|
||
Comment 16•12 years ago
|
||
Comment 17•12 years ago
|
||
Comment 18•12 years ago
|
||
Comment 19•12 years ago
|
||
Comment 20•12 years ago
|
||
Comment 21•12 years ago
|
||
Comment 22•12 years ago
|
||
Comment 23•12 years ago
|
||
Comment 24•12 years ago
|
||
Comment 26•12 years ago
|
||
Comment 27•12 years ago
|
||
Comment 28•12 years ago
|
||
Comment 29•12 years ago
|
||
Comment 31•12 years ago
|
||
Comment 32•12 years ago
|
||
Comment 33•12 years ago
|
||
Comment 34•12 years ago
|
||
Comment 35•12 years ago
|
||
Comment 36•12 years ago
|
||
Comment 37•12 years ago
|
||
Comment 38•12 years ago
|
||
Comment 39•12 years ago
|
||
Comment 40•12 years ago
|
||
Comment 41•12 years ago
|
||
Comment 42•12 years ago
|
||
Comment 43•12 years ago
|
||
Comment 44•11 years ago
|
||
Updated•11 years ago
|
Comment 45•11 years ago
|
||
Comment 46•11 years ago
|
||
Updated•11 years ago
|
Comment 47•11 years ago
|
||
Updated•11 years ago
|
Comment 48•11 years ago
|
||
Comment 49•11 years ago
|
||
Updated•10 years ago
|
Updated•10 years ago
|
Comment 51•10 years ago
|
||
Comment 52•10 years ago
|
||
Comment 53•10 years ago
|
||
Updated•10 years ago
|
Comment 60•9 years ago
|
||
Comment 61•9 years ago
|
||
Comment 64•9 years ago
|
||
Comment 67•7 years ago
|
||
Comment 68•7 years ago
|
||
Comment 69•7 years ago
|
||
Updated•6 years ago
|
Comment 74•6 years ago
|
||
Comment 75•6 years ago
|
||
Updated•6 years ago
|
Comment 78•5 years ago
|
||
(In reply to Maxim Degtyarev from comment #67)
Still reproducible on Firefox 54.0 (32-bit).
Tried execute "screenshot --clipboard --fullpage" on
https://time4buying.com/wella-toners and got following in the browser console:Exception { message: "", result: 2147500037, name: "NS_ERROR_FAILURE",
filename: "resource://gre/modules/commonjs/too…", lineNumber: 308,
columnNumber: 0, data: null, stack: "createScreenshotData@resource://gre…",
location: XPCWrappedNative_NoHelper } cli.js:2056
Object { isTypedData: true, data: Object, type: "error" } cli.js:2056
Object { columnNumber: 0, lineNumber: 308, message: "", stack:
"createScreenshotData@resource://gre…" } cli.js:2056
I have already fixed this. But as soon as you fix this bug, you ought to run into the limitation of canvas.toDataURL , so basically the actual issue was a exception at around 700px width/height on a 96dpi system. But as soon as you stitch 3-4 images of such size, your toDataURL will fail and throw. I am trying to find a work around.
Comment 79•5 years ago
•
|
||
We're having issues producing large images with the :screenshot
command on very long pages and/or when using high resolution DPR values (e.g. :screenshot --fullpage --dpr 2
and above).
When stressing screenshots in that way, I guess there are multiple things that may fail. Here are some failures I could reproduce with a blank document. Note: I'm using screenshots of the visible content only, so this may not include classes of problems that involve the --fullpage
option.
A. Screenshot fails if one dimension is larger than 32767
- Open in a new tab:
data:text/html,<body style="background:pink"></body>
- Open Responsive Design Mode, and set the RDM viewport to width=1000, height=50
- In Console, run
:screenshot --dpr 32.767
- In Console, run
:screenshot --dpr 32.768
In my tests, step 3 produces a 32767×1638 image, and step 4 fails silently.
B. Fails if area is larger than X?
With a square viewport, we reach a limit earlier than edge>32767.
- Open in a new tab:
data:text/html,<body style="background:pink"></body>
- Open Responsive Design Mode, and set the RDM viewport to width=1000, height=1000
- Run
:screenshot --dpr 11.18
- Run
:screenshot --dpr 11.181
#3 works and gives me a 11180×11180 image.
#4 fails silently (expected: a 11181×11181 image).
So what's the difference between #3 and #4?
Expected image dimensions | Number of pixels | Profile |
---|---|---|
11180 × 11180 | 124,992,400 | https://perfht.ml/2nHVATP |
11181 × 11181 | 125,014,761 | https://perfht.ml/2m8b6Iu |
It looks like we have a limit at 125,000,000 pixels (or 500MB if 4 bytes per RGBA pixel?).
The profiles also show that #3 takes 900+MB of memory, while #4 is flat, so it's probably failing early on purpose.
If we do this test again with a 1250×1000 viewport, we can run:
:screenshot --dpr 9.999
-> 12498×9999 image:screenshot --dpr 10
-> 12500×10000 image (Profile: https://perfht.ml/2mPytGV):screenshot --dpr 10.001
-> fails silently
UX considerations
If we don't want or can't change those limits, we should log a message in the Console saying why we can't make a screenshot. Something like:
Screenshot image is too large. Firefox cannot currently make screenshot images taller than 32767 pixels, or with a pixel count higher than 125 megapixels. Try using the --dpr option with a lower resolution:
:screenshot --fullpage --dpr 1
Assignee | ||
Comment 80•5 years ago
|
||
For the error message, you can make something very quickly like:
diff --git a/devtools/server/actors/webconsole/utils.js b/devtools/server/actors/webconsole/utils.js
--- a/devtools/server/actors/webconsole/utils.js
+++ b/devtools/server/actors/webconsole/utils.js
@@ -700,15 +700,23 @@ WebConsoleCommands._registerOriginal("sc
owner.helperResult = (async () => {
// creates data for saving the screenshot
// help is handled on the client side
- const value = await captureScreenshot(args, owner.window.document);
- return {
- type: "screenshotOutput",
- value,
- // pass args through to the client, so that the client can take care of copying
- // and saving the screenshot data on the client machine instead of on the
- // remote machine
- args,
- };
+ try {
+ const value = await captureScreenshot(args, owner.window.document);
+ return {
+ type: "screenshotOutput",
+ value,
+ // pass args through to the client, so that the client can take care of copying
+ // and saving the screenshot data on the client machine instead of on the
+ // remote machine
+ args,
+ };
+ } catch (e) {
+ console.error(e);
+ return {
+ type: "error",
+ message: "Firefox wasn't able to take a screenshot.",
+ };
+ }
})();
});
I passed a plain string, but we should pass the key of a localized string in webconsole.properties.
Not sure we can assume it failed because of the image size though.
Also, I remember someone talking about a replacement for the current screenshot code (for Fission): drawSnapshot
(dom/ipc/WindowGlobalParent.cpp#372).
I'm not sure this is completely production ready, but we might play with this in a near future.
Comment 83•5 years ago
|
||
This is an old bug with many duplicates and a high vote count, we should really think of adding an error message when this happens. The most frustrating for people is that nothing happens.
A better solution would be to use the code that Firefox Screenshot uses as the tool does not seem subject to the same limitation.
Updated•5 years ago
|
Comment 84•5 years ago
•
|
||
(In reply to Patrick Brosset <:pbro> from comment #83)
A better solution would be to use the code that Firefox Screenshot uses as the tool does not seem subject to the same limitation.
Actually bug 1576210 and bug 1570231 seem to disagree with this. But at least the tool does not fail silently. A part of the webpage still gets turned into the image.
Firefox Screenshot does this by capping the max height and width of the image with these values used here.
This diff shows when and how the capping was added. Note that the tool displays a warning when a full page screenshot was cut-off.
Comment 85•5 years ago
|
||
The changes made here are meant to make the screenshot code in DevTools
closer to how the Firefox Screenshots addon works.
- It cuts off large images to 10000x10000
- It reduces drp to 1 for fullpage images
When those things happen, a warning is logged in the content console so
the user is aware that they did happen.
Finally, because there are still cases when taking a screenshot could fail,
an error is logged in the content console when this happens.
Updated•5 years ago
|
Comment 86•5 years ago
|
||
This is an attempt at fixing this. The UI of it is based on the console. I posted a message in DevTools' public Slack (in #ux), so this is not final, but I believe this is our best option right now.
Comment 87•5 years ago
|
||
It reduces dpr to 1 for fullpage images
This could regress the --fullpage --dpr <number>
use case advertised here:
https://meyerweb.com/eric/thoughts/2015/10/22/firefoxs-screenshot-command/
Two ways to avoid that:
- Don't automatically change the DPR; when failing, the error message could suggest taking a screenshot with
:screenshot --fullpage --dpr 1
. - Or automatically change the DPR only if
--dpr <number>
is not specified.
Comment 88•5 years ago
•
|
||
(In reply to Florens Verschelde :fvsch from comment #87)
- Or automatically change the DPR only if
--dpr <number>
is not specified.
This is how I have implemented it. DPR will be decreased to 1 only if --fullpage
is defined and --dpr
is not specified.
Comment 89•5 years ago
|
||
Comment 90•5 years ago
|
||
Backed out for failures on browser_jsterm_screenshot_command_warnings.js
backout: https://hg.mozilla.org/integration/autoland/rev/c79d03d2790b674b4e07aee2b95e20bd350e0bbc
failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=290989815&repo=autoland&lineNumber=185854
[task 2020-02-28T15:55:29.696Z] 15:55:29 INFO - Details: error creating Audio decoder" {file: "chrome://devtools/content/webconsole/index.html" line: 0}]
[task 2020-02-28T15:55:29.696Z] 15:55:29 INFO - Buffered messages logged at 15:53:39
[task 2020-02-28T15:55:29.697Z] 15:55:29 INFO - Console message: [JavaScript Error: "getScreenshot(http://example.com/browser/devtools/client/webconsole/test/browser/test_jsterm_screenshot_command.html) failed: TypeError: NetworkError when attempting to fetch resource." {file: "resource://activity-stream/lib/Screenshots.jsm" line: 59}]
[task 2020-02-28T15:55:29.697Z] 15:55:29 INFO - getScreenshotForURL@resource://activity-stream/lib/Screenshots.jsm:59:10
[task 2020-02-28T15:55:29.698Z] 15:55:29 INFO - asyncmaybeCacheScreenshot@resource://activity-stream/lib/Screenshots.jsm:112:37
[task 2020-02-28T15:55:29.698Z] 15:55:29 INFO - _fetchScreenshot@resource://activity-stream/lib/TopSitesFeed.jsm:527:23
[task 2020-02-28T15:55:29.698Z] 15:55:29 INFO - _fetchIcon@resource://activity-stream/lib/TopSitesFeed.jsm:515:16
[task 2020-02-28T15:55:29.698Z] 15:55:29 INFO - getLinksWithDefaults@resource://activity-stream/lib/TopSitesFeed.jsm:408:16
[task 2020-02-28T15:55:29.698Z] 15:55:29 INFO - asyncrefresh@resource://activity-stream/lib/TopSitesFeed.jsm:431:30
[task 2020-02-28T15:55:29.698Z] 15:55:29 INFO - onAction@resource://activity-stream/lib/TopSitesFeed.jsm:771:14
[task 2020-02-28T15:55:29.698Z] 15:55:29 INFO - _middleware/</<@resource://activity-stream/lib/Store.jsm:63:17
[task 2020-02-28T15:55:29.698Z] 15:55:29 INFO - Store/this[method]@resource://activity-stream/lib/Store.jsm:39:54
[task 2020-02-28T15:55:29.698Z] 15:55:29 INFO - init/this.intervalId<@resource://activity-stream/lib/SystemTickFeed.jsm:27:24
[task 2020-02-28T15:55:29.698Z] 15:55:29 INFO - notify@resource://gre/modules/Timer.jsm:62:17
[task 2020-02-28T15:55:29.698Z] 15:55:29 INFO -
[task 2020-02-28T15:55:29.698Z] 15:55:29 INFO - Buffered messages finished
[task 2020-02-28T15:55:29.698Z] 15:55:29 INFO - TEST-UNEXPECTED-FAIL | devtools/client/webconsole/test/browser/browser_jsterm_screenshot_command_warnings.js | Test timed out -
[task 2020-02-28T15:55:30.693Z] 15:55:30 INFO - Removing tab.
Comment 91•5 years ago
|
||
Nicolas, do you think we could fix the test failure?
Honza
Assignee | ||
Comment 92•5 years ago
|
||
yes, we should try to move that over the finish line.
I'm going to have a look
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Updated•5 years ago
|
Comment 93•5 years ago
|
||
Comment 94•5 years ago
|
||
bugherder |
Comment 95•5 years ago
|
||
Thanks for pushing it over the finish line for me Nicolas! Really appreciate it. This is going to save some users from a lot of frustration I hope.
Comment 96•4 years ago
|
||
Thanks a lot Patrick for starting this patch. One less papercut!
Updated•4 years ago
|
(In reply to Patrick Brosset <:pbro> from comment #88)
This is how I have implemented it. DPR will be decreased to 1 only if
--fullpage
is defined and--dpr
is not specified.
Is that how it was implemented? Because it looks like if --fullpage
is specified, it will always use a dpr value of 1.
Updated•4 years ago
|
Updated•3 years ago
|
Description
•