MCPcopy Create free account
hub / github.com/BabylonJS/BabylonNative / IsSessionSupportedAsync

Method IsSessionSupportedAsync

Dependencies/xr/Source/ARCore/XR.cpp:796–843  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

794 }
795
796 arcana::task<bool, std::exception_ptr> System::IsSessionSupportedAsync(SessionType sessionType)
797 {
798 // Currently only AR is supported on Android
799 if (sessionType == SessionType::IMMERSIVE_AR)
800 {
801 // Spin up a background thread to own the polling check.
802 arcana::task_completion_source<bool, std::exception_ptr> tcs;
803 std::thread([tcs]() mutable
804 {
805 // Query ARCore to check if AR sessions are supported.
806 // If not yet installed then poll supported status up to 100 times over 20 seconds.
807 for (int i = 0; i < 100; i++)
808 {
809 ArAvailability arAvailability{};
810 ArCoreApk_checkAvailability(GetEnvForCurrentThread(), GetAppContext(), &arAvailability);
811 switch (arAvailability)
812 {
813 case AR_AVAILABILITY_SUPPORTED_APK_TOO_OLD:
814 case AR_AVAILABILITY_SUPPORTED_INSTALLED:
815 case AR_AVAILABILITY_SUPPORTED_NOT_INSTALLED:
816 tcs.complete(true);
817 break;
818 case AR_AVAILABILITY_UNKNOWN_CHECKING:
819 std::this_thread::sleep_for(std::chrono::milliseconds(200));
820 break;
821 default:
822 tcs.complete(false);
823 break;
824 }
825
826 if (tcs.completed())
827 {
828 break;
829 }
830 }
831
832 if (!tcs.completed())
833 {
834 tcs.complete(false);
835 }
836 }).detach();
837
838 return tcs.as_task();
839 }
840
841 // VR and inline sessions are not supported at this time.
842 return arcana::task_from_result<std::exception_ptr>(false);
843 }
844
845 arcana::task<std::shared_ptr<System::Session>, std::exception_ptr> System::Session::CreateAsync(System& system, void* graphicsDevice)
846 {

Callers

nothing calls this directly

Calls 2

GetEnvForCurrentThreadFunction · 0.85
GetAppContextFunction · 0.85

Tested by

no test coverage detected