pex-gl / pex-context

Modern WebGL state wrapper for PEX: allocate GPU resources (textures, buffers), setup state pipelines and passes, and combine them into commands.
http://pex-gl.github.io/pex-context/
MIT License
160 stars 12 forks source link

Runtime error handling #54

Open vorg opened 6 years ago

vorg commented 6 years ago

Currently if you provide a mesh with invalid vertex layout e.g. aPosition attribute missing the pex-context will crash via failed assert . e.g.

assert.fail(`Can't set uniform "${name}" with a null value`)
assert.fail(`Command is missing attribute "${name}" at location ${location} with ${attrib}`)

It's annoying because it's breaking e.g. pex-renderer render loop and the whole app stops so the options are as follows

a) crash and ask you to fix code immediately b) don’t render invalid meshes c) don’t render invalid meshes and print warning (forever and ever every frame..)

Currently option a) is implemented. After discussion with @nicknikolov I tried to implement option c) but it's not without issues:

I'm currently leaning towards keeping option a) as null uniform or missing mesh attribute usually indicates invalid data or algorithm error. If we want to avoid our render loop being broken or app crashing some kind of watchdogs should be in the higher layers. E.g. pex-renderer switches to "show 100% red material" for shaders that failed to compile. In the case of geometry would that be a Cube? what if fullscreen quad fails?

Thoughts?

dmnsgn commented 5 years ago

I would keep crashing and enhance the error as much as possible.