2

I've got an error I'm trying to catch with MapboxGL that doesn't handle when a version of IE switches the webGL render modes from hardware to software. I've been pouring over documentation and console logging pretty much everything I can, but can't find any documented way to find out if webGL is using hardware or software render modes.

Any ideas?

2
  • Does trying to create a context with {failIfMajorPerformanceCaveat : true} catch it?
    – samgak
    Jan 17, 2017 at 19:20
  • It does on load, but not during runtime. So it will prevent you from running if the conditions on load will severely degrade performance, but not if something happens during runtime.
    – KameronB
    Jan 17, 2017 at 19:44

1 Answer 1

4

You can check whether or not a browser can run GL JS in a hardware render mode using the mapbox-gl-supported library

<script src='mapbox-gl-supported.js'></script>
<script>
if (mapboxgl.supported({failIfMajorPerformanceCaveat: true})) {
    // hardware mode! :D
} else {
    // software mode :(
}
</script>
2
  • This works at load, but won't change dynamically if IE switches from hardware to software during the runtime.
    – KameronB
    Jan 17, 2017 at 23:08
  • @KameronB Have you tried reinitializing the canvas context? I mean, no browser is going to suddenly delete all references to any object that is still at play if that is what you are referring to.
    – Jack G
    Oct 31, 2018 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.