diff options
author | David Snopek <dsnopek@gmail.com> | 2021-01-27 14:16:00 -0600 |
---|---|---|
committer | David Snopek <dsnopek@gmail.com> | 2021-01-27 20:48:11 -0600 |
commit | a23fc126eb0ea93e0ca8e622586649404e6f668e (patch) | |
tree | d3239404e722578be9eb7528fa03aa5ddbbf5ce8 /modules/webxr/native | |
parent | 1ea133b6b58a4cf4ba5c077095a5b59266bac8e4 (diff) |
Prevent fatal error in WebXR when 'immersize-ar' loses and regains tracking
Diffstat (limited to 'modules/webxr/native')
-rw-r--r-- | modules/webxr/native/library_godot_webxr.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/modules/webxr/native/library_godot_webxr.js b/modules/webxr/native/library_godot_webxr.js index 764656712d..8e9ef8a73c 100644 --- a/modules/webxr/native/library_godot_webxr.js +++ b/modules/webxr/native/library_godot_webxr.js @@ -380,6 +380,11 @@ const GodotWebXR = { gl.deleteTexture(texture); } GodotWebXR.textures[i] = null; + + const texture_id = GodotWebXR.texture_ids[i]; + if (texture_id !== null) { + GL.textures[texture_id] = null; + } GodotWebXR.texture_ids[i] = null; } @@ -460,7 +465,7 @@ const GodotWebXR = { godot_webxr_get_external_texture_for_eye__proxy: 'sync', godot_webxr_get_external_texture_for_eye__sig: 'ii', godot_webxr_get_external_texture_for_eye: function (p_eye) { - if (!GodotWebXR.session || !GodotWebXR.pose) { + if (!GodotWebXR.session) { return 0; } @@ -469,6 +474,13 @@ const GodotWebXR = { return GodotWebXR.texture_ids[view_index]; } + // Check pose separately and after returning the cached texture id, + // because we won't get a pose in some cases if we lose tracking, and + // we don't want to return 0 just because tracking was lost. + if (!GodotWebXR.pose) { + return 0; + } + const glLayer = GodotWebXR.session.renderState.baseLayer; const view = GodotWebXR.pose.views[view_index]; const viewport = glLayer.getViewport(view); |