[Bf-blender-cvs] [10981bc8c09] master: Fix T98944: Uninitialized XRFrameState can prevent VR/OpenXR viewing

Peter Kim noreply at git.blender.org
Fri Jun 17 10:26:07 CEST 2022


Commit: 10981bc8c092dda48ed5228cc19108513035abf0
Author: Peter Kim
Date:   Fri Jun 17 17:25:48 2022 +0900
Branches: master
https://developer.blender.org/rB10981bc8c092dda48ed5228cc19108513035abf0

Fix T98944: Uninitialized XRFrameState can prevent VR/OpenXR viewing

This provides a workaround for the VR session stopping due to an error
in locating controller poses. The problem was that for the actions sync
on the first frame, the session's XrFrameState/predicted display time
had not been initialized yet, which led to an error in xrLocateSpace()
(the error was only observed for some OpenXR runtimes since the first
frame pose state would be inactive for other runtimes, skipping the
call to xrLocateSpace()).

The timing of action updates relative to frame state updates could be
reworked in the future, but for now simply check for a valid display
time to avoid an error on the first frame.

===================================================================

M	intern/ghost/intern/GHOST_XrAction.cpp

===================================================================

diff --git a/intern/ghost/intern/GHOST_XrAction.cpp b/intern/ghost/intern/GHOST_XrAction.cpp
index 587b1124848..0e725bf4075 100644
--- a/intern/ghost/intern/GHOST_XrAction.cpp
+++ b/intern/ghost/intern/GHOST_XrAction.cpp
@@ -332,23 +332,26 @@ void GHOST_XrAction::updateState(XrSession session,
         break;
       }
       case GHOST_kXrActionTypePoseInput: {
-        XrActionStatePose state{XR_TYPE_ACTION_STATE_POSE};
-        CHECK_XR(
-            xrGetActionStatePose(session, &state_info, &state),
-            (std::string("Failed to get state for pose action \"") + action_name + "\".").data());
-        if (state.isActive) {
-          XrSpace pose_space = ((subaction != nullptr) && (subaction->space != nullptr)) ?
-                                   subaction->space->getSpace() :
-                                   XR_NULL_HANDLE;
-          if (pose_space != XR_NULL_HANDLE) {
-            XrSpaceLocation space_location{XR_TYPE_SPACE_LOCATION};
-            CHECK_XR(
-                xrLocateSpace(
-                    pose_space, reference_space, predicted_display_time, &space_location),
-                (std::string("Failed to query pose space for action \"") + action_name + "\".")
-                    .data());
-            copy_openxr_pose_to_ghost_pose(space_location.pose,
-                                           ((GHOST_XrPose *)m_states)[subaction_idx]);
+        /* Check for valid display time to avoid an error in #xrLocateSpace(). */
+        if (predicted_display_time > 0) {
+          XrActionStatePose state{XR_TYPE_ACTION_STATE_POSE};
+          CHECK_XR(xrGetActionStatePose(session, &state_info, &state),
+                   (std::string("Failed to get state for pose action \"") + action_name + "\".")
+                       .data());
+          if (state.isActive) {
+            XrSpace pose_space = ((subaction != nullptr) && (subaction->space != nullptr)) ?
+                                     subaction->space->getSpace() :
+                                     XR_NULL_HANDLE;
+            if (pose_space != XR_NULL_HANDLE) {
+              XrSpaceLocation space_location{XR_TYPE_SPACE_LOCATION};
+              CHECK_XR(
+                  xrLocateSpace(
+                      pose_space, reference_space, predicted_display_time, &space_location),
+                  (std::string("Failed to query pose space for action \"") + action_name + "\".")
+                      .data());
+              copy_openxr_pose_to_ghost_pose(space_location.pose,
+                                             ((GHOST_XrPose *)m_states)[subaction_idx]);
+            }
           }
         }
         break;



More information about the Bf-blender-cvs mailing list