FocusManager does not compute distance to Canvas correctly
Overview
When raycasting UI with EventSystem, Unity returns distance value not from camera center, but from near clip plane. This can be fixed in FocusManager, when converting from camera space to worldSpace add nearClipPlane to the distance. This fixes the issue. See https://issuetracker.unity3d.com/issues/incorrect-distance-is-returned-when-using-eventsystem-dot-raycastall
Expected Behavior
Cursor focusing on WorldSpace Canvas is floating above it exactly at Cursor's Surface Distance.
Actual Behavior
Cursor focusing on WorldSpace Canvas is floating above it, more that Cursor's Surface Distance.
Steps to reproduce
Create a scene with WorldSpace canvas and a Raycast camera that has non-zero nearClip plane (bigger makes it more obvious). The cursor has an offset as well (set Cursor Surface Distance to be 0). The cursor will be floating above the world space canvas.
Unity Editor Version
2018.3.1
Mixed Reality Toolkit Release Version
2017.4.2.0
I agree with mgrman. This issue also causes the behavior I reported here. I had worked out that the nearClipPlane wasn't being taken into account but I couldn't get the values to add up quite right with what I was expecting. I didn't know about the Cursor Surface Distance, so that probably explains the discrepancy.
I believe the MRTK code did work as expected pre Unity 2017.4.3f1, and has been broken since probably due to the fix 934908.
I suspect mgrman is referring to Line 642 in FocusManager.
Changing this to:
newUiRaycastPosition.z = uiRaycastResult.distance + UIRaycastCamera.nearClipPlane;
Fixes the depth that the cursor appears at but it doesn't fix issue #3322 . This offset is probably needed in more than one place, I suspect Line 663 might be the culprit for that issue.
Actually Line 663 is just a Vector2 in screen coordinates.
Changing Line 689 and Line 697 so the distance has the UIRaycastCamera.nearClipPlane appears to fix issue #3322
This issue and #3322 have been listed as known issues in the new release of Mixed Reality Toolkit v2.0.0 Beta 2. I agree with this and have got similar results.
The same section of code from FocusManager.cs in MRTKv1 is in FocusProvider.cs in MRTKv2. I think Line 758 should be:
newUiRaycastPosition.z = raycastResult.distance + UIRaycastCamera.nearClipPlane;
and to fix issue #3322 Line 821 and Line 829 need to compare against uiRaycastResult.distance with the UIRaycastCamera.nearClipPlane added on.
The issue can be seen in the example scene InteractablesGallery.unity
Before patching (with Surface Cursor Distance set to 0):

After patching (with Surface Cursor Distance set to 0):

Great work digging down into these issues!
It looks like this issue was discussed in depth in this PR https://github.com/microsoft/MixedRealityToolkit-Unity/pull/3754
It sounds like this is still latent, but we have an assert that will trigger if it does become an issue. This is somewhat of a risky area to change because it affects a fundamental raycast codepath. We can definitely reopen if that assert starts hitting or if there's new data suggesting it needs to happen