Skip to content

Commit a4fbc07

Browse files
authored
display offersession promise failure instead of showing console errors (#27492)
* display offersession promise failure instead of showing console errors * change log() to warn() for offersession handler
1 parent 589eeb1 commit a4fbc07

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

examples/jsm/webxr/ARButton.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,12 @@ class ARButton {
107107
if ( navigator.xr.offerSession !== undefined ) {
108108

109109
navigator.xr.offerSession( 'immersive-ar', sessionInit )
110-
.then( onSessionStarted );
110+
.then( onSessionStarted )
111+
.catch( ( err ) => {
112+
113+
console.warn( err );
114+
115+
} );
111116

112117
}
113118

@@ -118,7 +123,12 @@ class ARButton {
118123
if ( navigator.xr.offerSession !== undefined ) {
119124

120125
navigator.xr.offerSession( 'immersive-ar', sessionInit )
121-
.then( onSessionStarted );
126+
.then( onSessionStarted )
127+
.catch( ( err ) => {
128+
129+
console.warn( err );
130+
131+
} );
122132

123133
}
124134

examples/jsm/webxr/VRButton.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ class VRButton {
7373
if ( navigator.xr.offerSession !== undefined ) {
7474

7575
navigator.xr.offerSession( 'immersive-vr', sessionInit )
76-
.then( onSessionStarted );
76+
.then( onSessionStarted )
77+
.catch( ( err ) => {
78+
79+
console.warn( err );
80+
81+
} );
7782

7883
}
7984

@@ -84,7 +89,12 @@ class VRButton {
8489
if ( navigator.xr.offerSession !== undefined ) {
8590

8691
navigator.xr.offerSession( 'immersive-vr', sessionInit )
87-
.then( onSessionStarted );
92+
.then( onSessionStarted )
93+
.catch( ( err ) => {
94+
95+
console.warn( err );
96+
97+
} );
8898

8999
}
90100

examples/jsm/webxr/XRButton.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ class XRButton {
7777
if ( navigator.xr.offerSession !== undefined ) {
7878

7979
navigator.xr.offerSession( mode, sessionOptions )
80-
.then( onSessionStarted );
80+
.then( onSessionStarted )
81+
.catch( ( err ) => {
82+
83+
console.warn( err );
84+
85+
} );
8186

8287
}
8388

@@ -88,7 +93,12 @@ class XRButton {
8893
if ( navigator.xr.offerSession !== undefined ) {
8994

9095
navigator.xr.offerSession( mode, sessionOptions )
91-
.then( onSessionStarted );
96+
.then( onSessionStarted )
97+
.catch( ( err ) => {
98+
99+
console.warn( err );
100+
101+
} );
92102

93103
}
94104

0 commit comments

Comments
 (0)