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

Fix: Reduce WebGL checks to reduce instances of Rats! error #728

Merged
merged 1 commit into from
Mar 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/lib/Browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const MIME_H264_MAIN = 'video/mp4; codecs="avc1.4D401E"';
const MIME_H264_HIGH = 'video/mp4; codecs="avc1.64001E"';
const EXT_STANDARD_DERIVATIVES = 'OES_standard_derivatives';
const EXT_LOSE_CONTEXT = 'WEBGL_lose_context';
const EVENT_WEBGL_CONEXT_LOST = 'webglcontextlost';
const EVENT_WEBGL_CONTEXT_LOST = 'webglcontextlost';

let { userAgent } = navigator;
let name;
Expand Down Expand Up @@ -184,7 +184,7 @@ class Browser {
if (!gl) {
const canvas = document.createElement('canvas');
// Should stop 'Rats! WebGL hit a snag' error when checking WebGL support
canvas.addEventListener(EVENT_WEBGL_CONEXT_LOST, (e) => {
canvas.addEventListener(EVENT_WEBGL_CONTEXT_LOST, (e) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove the supportsWebGL global variable?

Copy link
Contributor Author

@tonyjin tonyjin Mar 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will still be useful if someone is viewing a folder that has multiple 3D/360 files since that result will be cached between previews.

/* istanbul ignore next */
e.preventDefault();
/* istanbul ignore next */
Expand Down Expand Up @@ -353,10 +353,8 @@ class Browser {
swf: Browser.hasFlash(),
svg: Browser.hasSVG(),
mse: Browser.hasMSE(),
webgl: Browser.hasWebGL(),
mp3: Browser.canPlayMP3(),
dash: Browser.canPlayDash(),
box3d: Browser.supportsModel3D(),
h264: {
baseline: Browser.canPlayH264Baseline(),
main: Browser.canPlayH264Main(),
Expand Down
17 changes: 17 additions & 0 deletions src/lib/__tests__/Browser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,4 +500,21 @@ describe('lib/Browser', () => {
expect(hasIssue).to.be.false;
});
});

describe('getBrowserInfo()', () => {
it('should return browser capabilities', () => {
const browserInfo = Browser.getBrowserInfo();
const expectedFields = [
'name',
'swf',
'svg',
'mse',
'mp3',
'dash',
'h264'
];

expect(expectedFields.every((field) => typeof browserInfo[field] !== 'undefined')).to.be.true;
});
});
});