KhronosGroup / KhronosGroup/WebGL
webglcontextcreationerror under specified and under tested
- Dominant language
- HTML
- Stars
- 2.9k
- Forks
- 703
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 4
Description
[Here's a fiddle](https://jsfiddle.net/greggman/eb2gg3xk/) based on this [SO question](http://stackoverflow.com/questions/36565598/webglcontextcreationerror-event-is-it-triggered-synchronously)
The code basically does this
1. Make a canvas
2. Attach a `webglcontextcreationerror` event listener to the canvas
3. Make a 2d context from that canvas
4. Make a webgl context from the same canvas
Trying on Chrome, Firefox, and Safari.
Neither Firefox nor Safari dispatch an event even though they correctly fail to create a webgl context.
There are 3 issues
1. The spec doesn't make it clear if they are suppose to dispatch an event
2. The spec doesn't make it clear if that event is synchronous or asynchronous.
The spec says `dispatch` but then it says something about
> The task source for all tasks queued [HTML] in this section is the WebGL task source.
That to me makes it ambiguous. Is the event going in a queue to be dispatched later or is it dispatched immediately?
This is important because if you actually want to use the event you would structure your code differently.
```
// for sync
make canvas
add event listener that records reason
make context
if context === null then
use error that was recorded
```
vs
```
// for async
make canvas
add event listener that reports reason
make context
if context === null then
assume event handler will eventually get the reason
```
This second style doesn't work currently because neither Firefox nor Safari dispatch the event.
3. Regardless there are no tests.
Either that example should dispatch an event or not and should be tested
Contributor guide
Research direction
Start with the linked JSFiddle and reproduce the four-step sequence: add the event listener, create a 2D context, then attempt a WebGL context. Read the relevant event wording and task-source text in the WebGL specification, compare behavior in Chrome, Firefox, and Safari, and add tests that establish whether dispatch is required and synchronous or asynchronous.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100