browsingContext.captureScreenshot should return an error instead of a screenshot with a reduced size
Categories
(Remote Protocol :: WebDriver BiDi, defect, P3)
Tracking
(firefox149 fixed)
| Tracking | Status | |
|---|---|---|
| firefox149 | --- | fixed |
People
(Reporter: hbenl, Assigned: sameembaba, Mentored)
References
(Blocks 1 open bug)
Details
(Whiteboard: [webdriver:m19][webdriver:external][lang=js], [wptsync upstream][webdriver:relnote])
Attachments
(1 file)
Currently, browsingContext.captureScreenshot caps the screenshot size if the requested size is too large. But the BiDi spec says that it should return an unsupported operation error if it can't capture a screenshot (which in my opinion includes this case where the browser can only capture a screenshot with a reduced size).
Comment 1•6 months ago
|
||
I think that we should better update step 13 of the remote end steps and use the trying mechanism. If render the document to a canvas fails we probably want to raise a unable to capture screen error as well.
Comment 2•6 months ago
|
||
It should indeed be step 3 because that's the place where the canvas is created. So unsupported operation error is correct.
| Assignee | ||
Comment 3•4 months ago
|
||
Hi, I’ve got my local setup ready! would it be okay if I work on this issue?
Comment 4•4 months ago
|
||
Sameem, you are welcome to work on this bug. Let me know in case you have questions. Thanks!
| Assignee | ||
Comment 5•4 months ago
|
||
Thanks! I'm getting started now.
I've located the resize logic in remote/shared/Capture.sys.mjs inside capture.canvas. My plan is to remove the code that caps the dimensions and replace it with an error check.
| Assignee | ||
Comment 6•4 months ago
|
||
Updated•4 months ago
|
Comment 9•3 months ago
|
||
| bugherder | ||
Comment 11•3 months ago
|
||
Thank you so much Sameem!
Comment 12•2 months ago
|
||
As I just saw, in Firefox we increased the maximum size for screenshots to 65535x65535 pixels to match Chrome's behavior. The changes landed end of January this year via bug 1911583. That's the reason why the most recent testing didn't throw an error with 32767x32767 sizes.
| Assignee | ||
Comment 13•2 months ago
|
||
We just have to change the test dimension to fix it! When we landed the patch i don't think it had any problem with the test we wrote. So, what is the plan?
Comment 14•2 months ago
|
||
Hm, I wonder why the test def test_huge_full_screenshot in testing/web-platform/mozilla/tests/webdriver/classic/take_full_screenshot/screenshot.py still passes. I would expect that it fails now.
Sameem, I'm currently away until next week. So if you could file a new bug and take a look why the error is still thrown for the above test it would be great. My colleagues in the #webdriver channel can help you in case of questions. Thanks!
| Assignee | ||
Comment 15•2 months ago
|
||
Yeah, they should all fail the new test i have created as they have the previous boundaries(32768px)! I will check what is wrong here
| Assignee | ||
Comment 16•2 months ago
|
||
I did some test and i see when i instrumented capture.canvas. Canvas allocation succeeds with 32768×32768 (DPR=1). The failure occurs inside drawSnapshot, which throws NS_ERROR_LOSS_OF_SIGNIFICANT_DATA which we catch and throw an UnsupportedOperationError. That is why the the test still passes
| Assignee | ||
Comment 17•2 months ago
|
||
Hey there, i got busy last week! So, I didnt have time to work on it! The above message i sent about the different error being is this how it supposed behavior or do we have to change it?
Comment 18•2 months ago
|
||
Interesting. First, could you check if it also fails with drawWindow() (the other code block)? Just force readback to be true for this purpose. Maybe they only increased it for that code path. If yes we would have to think about how to better handle it.
| Assignee | ||
Comment 19•2 months ago
|
||
I tested both paths:
• drawWindow() fails in the Canvas 2D layer with InvalidStateError: Canvas exceeds max size, due to the gfx.canvas.max-area limit.
• drawSnapshot() fails deeper in the snapshot/compositor pipeline with NS_ERROR_LOSS_OF_SIGNIFICANT_DATA.
Comment 20•2 months ago
|
||
(In reply to Sameem [:sameembaba] from comment #19)
I tested both paths:
•
drawWindow()fails in the Canvas 2D layer withInvalidStateError: Canvas exceeds max size, due to thegfx.canvas.max-arealimit.
•drawSnapshot()fails deeper in the snapshot/compositor pipeline withNS_ERROR_LOSS_OF_SIGNIFICANT_DATA.
Hi Lee, given that you wrote the patch on bug 1911583 maybe you can help us? Maybe it was not intended to use larger canvas sizes for screenshots, especially when both the width and height larger than 32767? Or it is a miss and we should add proper support for it? Thanks!
Comment 21•2 months ago
•
|
||
(In reply to Henrik Skupin [:whimboo][⌚️UTC+1] from comment #20)
(In reply to Sameem [:sameembaba] from comment #19)
I tested both paths:
•
drawWindow()fails in the Canvas 2D layer withInvalidStateError: Canvas exceeds max size, due to thegfx.canvas.max-arealimit.
•drawSnapshot()fails deeper in the snapshot/compositor pipeline withNS_ERROR_LOSS_OF_SIGNIFICANT_DATA.Hi Lee, given that you wrote the patch on bug 1911583 maybe you can help us? Maybe it was not intended to use larger canvas sizes for screenshots, especially when both the width and height larger than 32767? Or it is a miss and we should add proper support for it? Thanks!
To be compatible with our Skia backends, the total size still needs to fit in a signed 32-bit integer to not overflow. For compat, we needed to be able to support sizes such as 64000x10, which is a very small area objectively, but has a dimension over the previous 32K limit. We, however, would not support a 64000x64000 canvas, because that would violate the constraint that the size can fit in signed 32 bits without overflow.
Essentially, I kept the area constraint to the same effective value as would be imposed by a 32K x 32K limit (as I am not sure yet we want to allow canvases that can consume more memory internally without any headroom), but I allow individual dimensions to reach up to 64K. The gfx.canvas.max-area pref implements this constraint.
Comment 22•2 months ago
|
||
Thank you Lee!
Sameem, with the above information I may propose that we re-add a check that the size of the screenshot doesn't exceed the gfx.canvas.max-area value. That way we would be flexible with any future change and as well could raise a specific error beside any other platform error which could happen as well. Would you like to file and work on such a bug?
Comment 24•2 months ago
|
||
Great. I filed bug 2020302 for it.
Updated•1 month ago
|
Description
•