Skip to content

Commit e295849

Browse files
committed
Remove GET_VR_DISPLAYS_TIMEOUT since it can lead to false positives and Chrome 58-60 are no longer in reasonable circulation. Fixes #335
1 parent 124f711 commit e295849

File tree

2 files changed

+1
-25
lines changed

2 files changed

+1
-25
lines changed

‎src/config.js‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,6 @@ export default {
4242
// Added in 0.10.0.
4343
PROVIDE_MOBILE_VRDISPLAY: true,
4444

45-
// There are versions of Chrome (M58-M60?) where the native WebVR API exists,
46-
// and instead of returning 0 VR displays when none are detected,
47-
// `navigator.getVRDisplays()`'s promise never resolves. This results
48-
// in the polyfill hanging and not being able to provide fallback
49-
// displays, so set a timeout in milliseconds to stop waiting for a response
50-
// and just use polyfilled displays.
51-
// https://bugs.chromium.org/p/chromium/issues/detail?id=727969
52-
GET_VR_DISPLAYS_TIMEOUT: 1000,
53-
5445
/**
5546
* Options passed into the underlying CardboardVRDisplay
5647
*/

‎src/webvr-polyfill.js‎

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -129,22 +129,7 @@ WebVRPolyfill.prototype.getVRDisplays = function() {
129129
return Promise.resolve(this.getPolyfillDisplays());
130130
}
131131

132-
// Set up a race condition if this browser has a bug where
133-
// `navigator.getVRDisplays()` never resolves.
134-
var timeoutId;
135-
var vrDisplaysNative = this.native.getVRDisplays.call(navigator);
136-
var timeoutPromise = new Promise(function(resolve) {
137-
timeoutId = setTimeout(function() {
138-
console.warn('Native WebVR implementation detected, but `getVRDisplays()` failed to resolve. Falling back to polyfill.');
139-
resolve([]);
140-
}, config.GET_VR_DISPLAYS_TIMEOUT);
141-
});
142-
143-
return race([
144-
vrDisplaysNative,
145-
timeoutPromise
146-
]).then(nativeDisplays => {
147-
clearTimeout(timeoutId);
132+
return this.native.getVRDisplays.call(navigator).then((nativeDisplays) => {
148133
return nativeDisplays.length > 0 ? nativeDisplays : this.getPolyfillDisplays();
149134
});
150135
};

0 commit comments

Comments
 (0)