The behavior of webgl function getUniformLocation is inconsistent compared to other browsers


#1

Invalid uniform locations returned by the webgl function getUniformLocation() are inconsistent with values returned by Chrome and Firefox. This causes developers to write Brave specific code.

Regardless of which behavior is “correct”, it would be nice if various browsers could be consistent.

In Chrome and Firefox a uniform location can be compared to null to identify invalid locations. In Brave there is no obvious way to detect invalid locations.

Update 1: The behavior described in this report is caused by Brave “finger printing protection”. With Brave finger printing protection enabled a simple webgl2 example will work, until a call to getUniformLocation() is added. Remove the call to getUniformLocation() and the example works. Disable finger printing protection and the example works with a call to getUniformLocation(). The same example code works in Chrome and Firefox. Note Brave will run the example in all scenarios when the example is loaded from a file, ie without finger printing protection.

Update 2: This example code works when served from https://webgl2fundamentals.org/webgl/webgl-2d-rectangles.html When served on a LAN from node.js at address http://localhost:80 the example works. However when served on a LAN from node.js using a local IP address calls to the function getUniformLocation() fail, both on the PC serving the files and on other PCs on the LAN.

Update 3: Posting this to help other developers. To get around the issue my code tests for exceptions on getUniformLocation(). If an exception occurs the user is presented with a message indicating finger printing protection is breaking the website and asks that they disable the protection, or switch to Chrome. Ironically finger printing protection is leaking information by identifying the browser as Brave, because as far as I’ve seen Brave is the only browser with the getUniformLocation() issue.