Closed Bug 681791 Opened 12 years ago Closed 12 years ago

When trying to create a too large canvas, don't throw, instead just use a smaller drawing buffer

Categories

(Core :: Graphics: CanvasWebGL, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla10

People

(Reporter: bjacob, Assigned: jgilbert)

References

()

Details

Attachments

(1 file, 5 obsolete files)

We currently file a few WebGL conformance tests, like

https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/sdk/tests/conformance/canvas/drawingbuffer-static-canvas-test.html

Because we throw on canvas.width = something_huge when SetDimensions fails.

Chrome doesn't throw there.

Chrome also won't use a drawingbuffer larger than the max texture size or 4k, whichever is smaller.

We need to fail less on resizing-canvases-to-large-sizes by using a smaller drawingbuffer if needed.
Blocks: 615976
No longer blocks: webgl-conformance
Depends on: 688112
Assignee: nobody → jgilbert
Blocks: 688112
No longer depends on: 688112
This change basically guarantees that GLContext will not be changed if a resize attempt fails.
Blocks: 685229
It didn't occur to me before that the arguably time-saving initialize once approach was incompatible with soft-failing resizing.
Updated try: https://tbpl.mozilla.org/?tree=Try&usebuildbot=1&rev=322fe6cae175
Yeah, that didn't work so well. 
Updated:
https://tbpl.mozilla.org/?tree=Try&usebuildbot=1&rev=089d1b13072f
Status: NEW → ASSIGNED
Current patch file.
Attachment #564827 - Attachment is obsolete: true
Attachment #566099 - Flags: review?(bjacob)
Attachment #566099 - Flags: review?(bjacob) → feedback?(bjacob)
Ran into a problem on OS X.
Fixed CGL impl.
Attachment #566099 - Attachment is obsolete: true
Attachment #566099 - Flags: feedback?(bjacob)
Attachment #566404 - Flags: review?(bjacob)
For some reason my last changes reset. Maybe I reset my patch file somehow.
Updated try with CGL fix:
https://tbpl.mozilla.org/?tree=Try&rev=ff8c9387530d
Fixed errant tab issues and added further commenting.
Attachment #566404 - Attachment is obsolete: true
Attachment #566404 - Flags: review?(bjacob)
Attachment #567141 - Flags: review?(bjacob)
Predicates too-verbose debug printf on mDebugMode.
Attachment #567141 - Attachment is obsolete: true
Attachment #567141 - Flags: review?(bjacob)
Attachment #567147 - Flags: review?(bjacob)
Comment on attachment 567147 [details] [diff] [review]
Guarantees that GLContext::ResizeOffscreen is harmless if it fails

Review of attachment 567147 [details] [diff] [review]:
-----------------------------------------------------------------

This looks all good!

Just one remark about something to keep in mind. The ClearSafely() call is mega-super-important for security: we must prevent WebGL scripts from reading back uninitialized video memory from a newly resized canvas. In your AA patches, the FBO becomes two separate FBOs, right. So will we need two ClearSafely() calls there?
Attachment #567147 - Flags: review?(bjacob) → review+
> Just one remark about something to keep in mind. The ClearSafely() call is
> mega-super-important for security: we must prevent WebGL scripts from
> reading back uninitialized video memory from a newly resized canvas. In your
> AA patches, the FBO becomes two separate FBOs, right. So will we need two
> ClearSafely() calls there?

I will triple-check, but we shouldn't need to. After clearing the draw buffer, the read buffer /may/ be uninitialized, but before any read call is possible, we blit over the cleared draw buffer, clearing the read buffer. Basically, it's only possible to access if you can read it without using GL commands to do so. We could just deliberately blit over the cleared draw buffer, as that should be minimal cost compared to assembling a resized buffer, but it should not be necessary. If it were necessary, there would be other problems with our WebGL restrictions anyways.
Carrying forward r+ from bjacob after PR_TRUE/FALSE conversion.
Attachment #567147 - Attachment is obsolete: true
Attachment #567820 - Flags: review+
Re-landed with proper commit message (sorry, should have checked that)
http://hg.mozilla.org/integration/mozilla-inbound/rev/716915ed489c
https://hg.mozilla.org/mozilla-central/rev/716915ed489c
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla10
You need to log in before you can comment on or make changes to this bug.