KhronosGroup / KhronosGroup/WebGL
Intrinsic (natural) size of WebGL canvas is unclear
- Dominant language
- HTML
- Stars
- 2.9k
- Forks
- 703
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 4
Description
Specifically in the case where drawing buffer size and canvas size don't match (which already gets into unspecified behavior), the WebGL spec is unclear about the intrinsic (natural) size of the canvas. This is important for at least 2 things:
- The default CSS size
- The drawImage() destination size
> If not specified, the dw and dh arguments must default to the values of sw and sh, interpreted such that one CSS pixel in the image is treated as one unit in the output bitmap's coordinate space. If the sx, sy, sw, and sh arguments are omitted, then they must default to 0, 0, the image's intrinsic width in image pixels, and the image's intrinsic height in image pixels, respectively.
> [[spec]](https://html.spec.whatwg.org/multipage/canvas.html#drawing-images)
Chrome and Firefox agree about the first thing: the default CSS size is the canvas size, not the drawing buffer size.
However, for drawImage() destination size, Chrome uses the canvas size, while Firefox uses the drawing buffer size.
Test case: https://codepen.io/kainino0x/pen/dyzqXym
Since this is stepping into unspecified territory, it's understandable that they differ. However there is this non-normative note [in the WebGL 1.0 spec](https://www.khronos.org/registry/webgl/specs/latest/1.0/#2.2) which almost seems to answer the question:
> The constraint above does not change the amount of space the canvas element consumes on the web page, even on a high-definition display. The canvas's intrinsic dimensions [CANVAS] equal the size of its coordinate space, with the numbers interpreted in CSS pixels, and CSS pixels are resolution-independent [CSS].
1. What is "the size of its coordinate space"?
2. Why is this text non-normative? The HTML canvas spec doesn't seem to answer it either, so it probably needs to be answered here - I think HTML only defines the intrinsic size for context modes `none` (and `2d` presumably), and sort of for `placeholder`.
Contributor guide
Research direction
Review the WebGL 1.0 specification section 2.2 alongside the HTML canvas drawing-images section and the linked CodePen test case. Resolve what intrinsic size means when canvas and drawing-buffer sizes differ, then clarify the relevant normative specification text and verify the behavior described by the test case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- html
- Domain
- computer-graphics, documentation, web-dev
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100