Meshing broken in latest dev2 updates

I really need help on this. As per release notes:

** Before meshing begins, make sure to call SetCustomMeshBlockRequests to set the callback, as there is a known issue currently that could cause a crash If this callback is not set, even if it is not being used. An example of how to do this is shown in the meshing sample provided.*

  • I looked at the example and did exactly how its done by setting the callback in the awake method on my meshing controller script. Everything is pretty much the exact same as the example but yet it still doesn't work.

  • When I make a build, nothing such as like my normal UIs etc are showing. If I turn on the objects that does the meshing with a delay, all the UI will disappear. I simply believe the app is just crashing.

  • If I run it in device simulator, Unity crashes.

  • If I completely disable Meshing, everything runs fine. However I need Meshing for my app so without this its pretty useless.

Unity Editor version: 2022.2.0b14
ML2 OS version: 1.1.0-dev2
MLSDK version: 1.1.0-dev2
Host OS: (Windows/MacOS): Windows 11

Uploaded the logs:
Logs.txt (1.0 MB)

1 Like

@jc1 Can you try removing any custom scripts that enable meshing and try to do the following:

1.Create Mesh Root

  1. Create a new GameObject and name it "Mesh Root"
  2. Make sure that it is positioned at 0,0,0 and has the scale set to 1,1,1

2.Create Mesh Graphic

  1. Create an empty game object and name it "Mesh"
    2.Add A mesh Renderer Component to it
    3.Create a new material and assign it under the Materials Tab
  2. Add a Mesh Collider (if you are using collisions)
  3. Add a Mesh filter
  4. Drag it into your assets folder to create a prefab

2.Configure the Meshing Subsystem Component

  1. Next, Create a new GameObject and name it "Meshing Subsystem"
  2. Add the Meshing Subsystem Component to the "Meshing Subsystem" GameObject
  3. Set the scale of the "Meshing Subsystem" to 10,10,10
  4. Then Set the Mesh Parent to the Mesh Root GameObject
  5. Set the Mesh Prefab to the Mesh prefab that you created in the previous step


  1. After the components are configured, make sure you have enabled Spatial Mapping in the Permission Settings.
  2. Since this is a dangerous permission, you will need to request it at runtime. To do this create a new script and name it something like "MeshingPermissionRequester"
  3. Add it to the Mesh Root GameObject
  4. Open the script and add the following line of code
using UnityEngine;
using UnityEngine.XR.MagicLeap;

public class MeshingPermissionRequester : MonoBehaviour
    private MeshingSubsystemComponent _meshManager;

    private readonly MLPermissions.Callbacks _permissionCallbacks = new MLPermissions.Callbacks();

    private void Awake()
        _permissionCallbacks.OnPermissionGranted += OnPermissionGranted;
        _permissionCallbacks.OnPermissionDenied += OnPermissionDenied;
    private void OnDestroy()
        _permissionCallbacks.OnPermissionGranted -= OnPermissionGranted;
        _permissionCallbacks.OnPermissionDenied -= OnPermissionDenied;

    private void Start()
        _meshManager = FindObjectOfType<MeshingSubsystemComponent>();
        if (_meshManager == null)
            Debug.LogError("Failed to find MeshingSubsystemComponent in scene. Disabling Script");
            enabled = false;
            _meshManager.enabled = false;
        MLPermissions.RequestPermission(MLPermission.SpatialMapping, _permissionCallbacks);
    private void OnPermissionGranted(string permission)
        _meshManager.enabled = true;
    private void OnPermissionDenied(string permission)
        Debug.LogError($"Failed to create Mesh Subsystem due to missing or denied {MLPermission.SpatialMapping} permission. Please add to manifest. Disabling script.");
        enabled = false;

1 Like

I implemented it as you shared but it did not work. At first, nothing was displayed when the MeshingSubsystemComponent was active. The next time I ran it with the MeshingSubsystemComponent deactivated, nothing was displayed at the time I executed _meshManager.enabled = true; in OnPermissionGranted.

Did you set a mesh graphic?

1 Like

The mesh is of course invisible, but I have added XR Rig controllers and also displayed the UI, but these are not visible at all. If I intentionally comment out the _meshManager.enabled = true process, the red lines and UI of the XR Rig controllers show up fine.
I have previously posted about meshing problems, but I am experiencing the same problem.

Hi, this doesn't work for me either, I have the same problem but only when I am using MRTK.

Also I added the following piece of code:

In Awake:


And the method

MeshingSubsystem.Extensions.MLMeshing.MeshBlockRequest[] CustomBlockRequests(MeshingSubsystem.Extensions.MLMeshing.MeshBlockInfo[] blockInfos)
            var blockRequests = new MeshingSubsystem.Extensions.MLMeshing.MeshBlockRequest[blockInfos.Length];
            for (int i = 0; i < blockInfos.Length; ++i)
                var blockInfo = blockInfos[i];
                var distanceFromCamera = Vector3.Distance(_camera.transform.position, blockInfo.pose.position);
                if (distanceFromCamera > 1)
                    blockRequests[i] = new MeshingSubsystem.Extensions.MLMeshing.MeshBlockRequest(, MeshingSubsystem.Extensions.MLMeshing.LevelOfDetail.Minimum);
                    blockRequests[i] = new MeshingSubsystem.Extensions.MLMeshing.MeshBlockRequest(, MeshingSubsystem.Extensions.MLMeshing.LevelOfDetail.Maximum);

            return blockRequests;

but the crash still occurs however the issues is not 100% repro, I would say 8/10. I have a feeling this has to do with the fact that I am using MRTK as it works fine in the example scene which does not use MRTK and the code that I am using is exactly the same which also includes that example you provided.

I then tried to use spatial mapping directly form the MRTK toolkit module and this also does not work

I'm looking into this. Thank you for the heads up. I haven't ran into this problem myself so I'll try to get more information about this for you.

1 Like

cc @kbabilinski
I have added the Awake process you shared and verified it. The event of nothing being displayed was improved, but no mesh was generated at all in the crucial space. 1.1.0-dev2 makes Meshing risky to use, I think.

Hey, thanks for checking it. Yer at first I though it was due to MRTK in conjunction but I tried it without MRTK and I am getting the issue but its not 100% repro (it worked only about 2/10 times) which then made me think it could be a script execution order issue so I did some tweaks to that but I am still getting the issue.

I have also encountered the issue directly within the example scene provided by ML2 without any modification. (again the issue was not 100% repro)

Due to this my team have reverted all our current project to dev1 and OS back to dev1. Meshing for dev2 is just not stable, hopefully the next update will fix this.