Skip to content

st/oxr: Increase active_wait_frames count after previous xrBeginFrame has been called

zhibin wang requested to merge quic_zhibinw/monado:begin_frame_fix into main

Problem:

When run the UE4 OpenXR app (switch levels), xrWaitFrame and xrBeginFrame is called like below:

---- xrWaitFrame ------------ xrWaitFrame ------------ xrWaitFrame ------------ xrWaitFrame --------  
\------------ xrBeginFrame ------------ xrBeginFrame ------------ ---------------------- --- xrBeginFrame

The third xrBeginFrame call is too late and cause error XR_ERROR_CALL_ORDER_INVALID, which happens at

https://gitlab.freedesktop.org/monado/monado/-/blob/main/src/xrt/state_trackers/oxr/oxr_session.c#L553

		// max 2 xrWaitFrame can be in flight so a second xrBeginFrame
		// is only valid if we have a second xrWaitFrame in flight
		if (active_wait_frames != 2) {
			return oxr_error(log, XR_ERROR_CALL_ORDER_INVALID, "xrBeginFrame without xrWaitFrame");
		}

Solution:

With this fix, xrWaitFrame first will block until the previous xrBeginFrame finish and then increase "active_wait_frames".

In this way, the fourth xrWaitFrame will block and do not add count for "active_wait_frames", and the third xrBeginFrame can be called successfuly, and then the fourth xrWaitFrame will continue normally.

Verification

Verified on Android (native/Unity/UE) app and CTS.

Edited by zhibin wang

Merge request reports