Skip to content

Commit 630ece1

Browse files
committed
Securize refresh rate selection
If the XR_FB_display_refresh_rate extension was available we assumed that the API will always return a non empty list of supported refresh rates. However in some particular configurations the extension might appear as available but no refresh rates will be ever returned. That could cause crashes due to assertions. As this is an extension and not a critical piece of the main execution path we should just report the error and bail out. This was happening to me when trying to run the AOSP flavour in a Quest device. With this fix Wolvic can be run in Quest devices even with the AOSP flavour.
1 parent b7c8d9b commit 630ece1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

app/src/openxr/cpp/DeviceDelegateOpenXR.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,11 @@ struct DeviceDelegateOpenXR::State {
495495

496496
uint32_t displayRefreshRateCount = 0;
497497
CHECK_XRCMD(OpenXRExtensions::sXrEnumerateDisplayRefreshRatesFB(session, 0, &displayRefreshRateCount, nullptr));
498-
CHECK(displayRefreshRateCount > 0);
498+
if (displayRefreshRateCount == 0) {
499+
VRB_ERROR("OpenXR runtime reports 0 display refresh rates but XR_FB_display_refresh_rate is supported");
500+
return;
501+
}
502+
499503
refreshRates.resize(displayRefreshRateCount);
500504
CHECK_XRCMD(OpenXRExtensions::sXrEnumerateDisplayRefreshRatesFB(session, displayRefreshRateCount, &displayRefreshRateCount, refreshRates.data()));
501505

@@ -733,7 +737,7 @@ struct DeviceDelegateOpenXR::State {
733737
}
734738

735739
void UpdateDisplayRefreshRate() {
736-
if (!OpenXRExtensions::IsExtensionSupported(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME))
740+
if (!OpenXRExtensions::IsExtensionSupported(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME) || refreshRates.empty())
737741
return;
738742

739743
float suggestedRefreshRate = 0.0;

0 commit comments

Comments
 (0)