Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: getWebGLCtx was returning false on supported environments #378

Merged
merged 1 commit into from
May 11, 2020
Merged

Bugfix: getWebGLCtx was returning false on supported environments #378

merged 1 commit into from
May 11, 2020

Conversation

pmarfany
Copy link

Hi!

I'm updating my code to use the new release of this library and I came across a compatibility problem with IE11 (not that we care a lot, but a lot of people on our website actually use it 😅).

Anyway, the visor was throwing an error indicating that WebGL was not supported, which was weird as we are using another library that uses it without any problem.

After taking a look at the code, it appears that the following fragment inside the getWebGLCtx method always returns after the first element inside the names array (some checks for the first "truthful").

const names = ['webgl', 'experimental-webgl', 'moz-webgl', 'webkit-3d'];

[...code...]

names.some((name) => {
  try {
    context = canvas.getContext(name);
    return true;
  }
  catch (e) {
    return false;
  }
});

According to the HTMLCanvasStandard, the getContext method will just return null if the context is not supported, thus always returning true to the webgl context (the first one in the array) even if it's not supported.

This PR changes the returning condition to check if the value is different from null.

Merge request checklist

@mistic100 mistic100 merged commit d22d849 into mistic100:dev May 11, 2020
@mistic100 mistic100 added the bug label May 11, 2020
@mistic100
Copy link
Owner

Thank you

@mistic100 mistic100 added this to the 4.0.4 milestone May 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants