From 3cdd5fd711fe8063780d0d7f47c58cda7d8cb566 Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 19 Jan 2024 13:19:43 -0500 Subject: [PATCH] throw error if MAX_TEXTURE_IMAGE_UNITS is a bad value --- src/webgldrawer.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/webgldrawer.js b/src/webgldrawer.js index 71e544ca..9aaaf857 100644 --- a/src/webgldrawer.js +++ b/src/webgldrawer.js @@ -276,9 +276,15 @@ let maxTextures = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS); if(maxTextures <= 0){ // This can apparently happen on some systems if too many WebGL contexts have been created - // in which case maxTextures can be null, leading to out of bounds errors with the array + // in which case maxTextures can be null, leading to out of bounds errors with the array. + // For example, when viewers were created and not destroyed in the test suite, this error + // occured in the TravisCI tests, though it did not happen when testing locally either in + // a browser or on the command line via grunt test. + // use plain console.error instead of $.console.error in order to have the message show up in the test log. console.error(`There was a WebGL problem: bad value for MAX_TEXTURE_IMAGE_UNITS (${maxTextures})`); + throw(new Error(`WegGL error: bad value for gl parameter MAX_TEXTURE_IMAGE_UNITS (${maxTextures}). This could happen + if too many contexts have been created and not released, or there is another problem with the graphics card.`)); return; }