regl-project / regl

👑 Functional WebGL
MIT License
5.19k stars 320 forks source link

Extensions loaded previously may pollute new regl instance #544

Open rreusser opened 4 years ago

rreusser commented 4 years ago

I discovered while debugging strange test interactions in #474 that regl may perform incorrectly in the somewhat obscure corner case in which you:

  1. create a regl instance with the ANGLE_instanced_arrays extension
  2. perform instanced rendering
  3. create a new regl context using the same canvas element but without ANGLE_instanced_arrays
  4. perform non-instanced rendering

The second regl instance knows nothing about the extension since you did not ask for it but still is subject to needing to maintain (or at least just unset) instanced rendering for the attributes.

This is pretty obscure and unlikely to cause real-world problems, but perhaps regl should query and register previously loaded extensions as available even if you did not ask for them.

mikolalysenko commented 4 years ago

I'll take a shot at it

rreusser commented 4 years ago

@mikolalysenko I think it's almost entirely a non-issue since reusing a canvas element for different webgl contexts is a bit of a strange thing to do, though it's maybe not invalid. The place where it jumped out was in the test scripts, which almost exclusively do that. See:

https://github.com/regl-project/regl/blob/cadd226650d345ac3599b067ebfb848439dc4fd8/test/attribute-constants.js#L6-L18