vkWaitForFences does not return in a timely manner with SYNC_FD

In Monado and the derived WiVRn OpenXR runtimes, fences are used for inter-process synchronization.

In comp_vk_client.c the game process creates a vkFence and exports it as a VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT. An empty submit is performed in order to signal the fence when work previously submitted on the queue is complete.

The handle is imported in the OpenXR service process and waited on.

By measuring the CPU time for the vkWaitForFences to return we can see that time varies between 2 values while it should be almost constant.

Monado can use timeline semaphores when the OpenXR API allows it (XR_KHR_vulkan_enable2) or with a specific vulkan layer. In that case, we don’t observe large wait times.

1 Like