Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.


I have a Hololens application written in C++/WinRT that queries spatial surfaces using SpatialSurfaceObserver. For that, the App responds to ObservedSurfacesChanged event and there runs a function that obtains a list of spatial meshes with GetObservedSurfaces. Then, for each entry, a mesh is constructed and rendered.

I'm having issues with calls to GetObservedSurfaces. Measurements show, that it typically runs for 120-140 milliseconds. The first couple of runs after the application starts take almost 500 milliseconds. In itself, this could be acceptable. However, the call seems to block the entire application until it returns, which causes the render loop to drop several frames, ruining user experience. There is no locking that would freeze the application while MyApp::UpdateSpatialMeshes is running. If I replace the call auto surfaces = observer.GetObservedSurfaces(); with a simple one-second-long wait (and comment out everyting depending on surfaces), everything is fine no frame dropping occurs.

Does anyone have an idea why GetObservedSurfaces blocks my app or what I can do to use it more properly?

UPDATE: There are approx. 40 surface meshes in the returned collection, containing ~100k triangles.


winrt::Windows::Foundation::IAsyncAction MyApp::InitSurfaceObserver()
co_await winrt::resume_background();

auto status = co_await SpatialSurfaceObserver::RequestAccessAsync();
if (status == SpatialPerceptionAccessStatus::Allowed)
auto coordSys = m_stationaryReferenceFrame.CoordinateSystem();
m_surfaceObserver = SpatialSurfaceObserver();
m_surfaceObserver.ObservedSurfacesChanged([this](auto&& sender, auto&& args)
UpdateSpatialMeshes(m_surfaceObserver, coordSys); // runs in background

SpatialBoundingBox aabb = { { 0.0f,  0.0f, 0.0f }, { 20.0f, 20.0f, 5.0f } };
auto bounds = SpatialBoundingVolume::FromBox(coordSys, aabb);

// else: complain

winrt::fire_and_forget MyApp::UpdateSpatialMeshes(const SpatialCoordinateSystem& coordSys,
const SpatialSurfaceObserver& observer)
if (coordSys /* AND no other UpdateSpatialMeshes is currently running*/)
SpatialCoordinateSystem scs{ coordSys }; // back up the coordinate system
co_await winrt::resume_background();
auto surfaces = observer.GetObservedSurfaces(); // <<< FREEZES EVERYTHING

for (auto const& pair : surfaces)
  const GUID& id = pair.Key();
  auto surfaceInfo = pair.Value();
  if (!surfaceInfo) continue;
  // TryComputeLatestMeshAsync, then render


Sign In or Register to comment.