mapbox / mapbox-gl-supported

A library to determine if a browser supports Mapbox GL JS
BSD 3-Clause "New" or "Revised" License
42 stars 17 forks source link

Catch error if createShader is unsupported #33

Closed ryanhamley closed 3 years ago

ryanhamley commented 4 years ago

Fixes https://github.com/mapbox/mapbox-gl-supported/issues/32 by catching any error that occurs when calling createShader and returning false

ryanhamley commented 4 years ago

I'm not able to test this directly because I don't have access to an iOS device with a sufficiently old browser. However, I ran the test page in this directory locally and confirmed that it reports that GL is supported as expected. I simulated this error by changing the function to something that doesn't exist so an error is thrown. The error was caught and the test page reported that WebGL is not supported. If I simulate the error without the try/catch, I do see an error in the console and the test page crashes. I take all of this collectively to mean that this PR should fix the error reported in #32

ryanhamley commented 4 years ago

I'm also not sure why CI is running on this repo when there's no config file. We should either turn this off or add a config, but since there's no real test suite here, turning it off is probably fine.

hyperknot commented 4 years ago

That's the good approach, as I've run into a very rare Firefox error for "Permission denied to access property "createShader" ". It was on Firefox 68 + Windows 10. This would catch that as well.