# Native meshing not working

**URL:** <https://forum.magicleap.cloud/t/native-meshing-not-working/2034>\
**Category:** Native Development\
**Tags:** development\
**Created:** [June 6, 2023, 3:35pm UTC](https://forum.magicleap.cloud/t/native-meshing-not-working/2034 "2023-06-06T15:35:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rp1](https://avatars.discourse-cdn.com/v4/letter/r/13edae/32.png) [@rp1](https://forum.magicleap.cloud/u/rp1)\
**Post date:** [June 6, 2023, 3:35pm UTC](https://forum.magicleap.cloud/t/native-meshing-not-working/2034/1 "2023-06-06T15:35:19Z")

</div>

Hi,

We have problems retrieving MLMeshingMeshInfo with MLMeshingGetMeshInfoResult().  
The MLMeshingGetMeshInfoResult() method returns MLResult\_Ok, but out\_info.data\_count is set to zero. We have ensured that subsequent calls are made in the same way as in the sample app.  
We have made sure that each call returns MLResult\_Ok.  
Do you have an idea why data\_count is zero even though MLResult\_Ok is returned.  
Especially as the documentation mentions MLResult\_Ok is returned when the data was populated.  
quote:

```auto
\retval MLResult_Ok Mesh Info was populated successfully.

```

ML2 OS version 1.3.0-dev1(secure)  
MLSDK version v1.2.0-dev2

Thanks in advance,  
Richard

---

<div class="post-metadata">

**Author:** ![ejurinsky](https://avatars.discourse-cdn.com/v4/letter/e/8e7dd6/32.png) [@ejurinsky](https://forum.magicleap.cloud/u/ejurinsky)\
**Post date:** [June 6, 2023, 6:10pm UTC](https://forum.magicleap.cloud/t/native-meshing-not-working/2034/3 "2023-06-06T18:10:50Z")

</div>

Richard, did you try running meshing sample app? Does it work for you?

---

<div class="post-metadata">

**Author:** ![rp1](https://avatars.discourse-cdn.com/v4/letter/r/13edae/32.png) [@rp1](https://forum.magicleap.cloud/u/rp1)\
**Post date:** [June 7, 2023, 12:59pm UTC](https://forum.magicleap.cloud/t/native-meshing-not-working/2034/4 "2023-06-07T12:59:07Z")

</div>

Hi @ejurinsky,

Yes, the sample is working.  
We granted all permissions, using the code from the sample and also starting perception with MLPerceptionStartup().

We tried to test meshing using minimal code now. Our source looks like this:

```auto
At startup:
// initialize perception system
MLPerceptionSettings perceptionSettings = {};
MLResult result = MLPerceptionInitSettings(&perceptionSettings); // result = MLResult_Ok
result = MLPerceptionStartup(&perceptionSettings); // result = MLResult_Ok
result = MLMeshingCreateClient(&meshing_client_, &meshing_settings_); // result = MLResult_Ok
result = MLHeadTrackingCreate(&head_tracker_); // result = MLResult_Ok
result = MLHeadTrackingGetStaticData(head_tracker_, &head_static_data_); // result = MLResult_Ok

onUpdate() {
  if (!MLHandleIsValid(current_mesh_info_request_)) {
    MLResult result = MLMeshingRequestMeshInfo(meshing_client_, &request_extents_, &current_mesh_info_request_); // result = MLResult_Ok
  } else {
    MLMeshingMeshInfo mesh_info = {};
    MLResult result = MLMeshingGetMeshInfoResult(meshing_client_, current_mesh_info_request_, &mesh_info); // result = MLResult_Ok
    // result = MLResult_Ok, mesh_info.data_count=0, mesh_info.data->state=0 //
    switch (result) {
        case MLResult_Ok:
            LOGAR_DEBUG<<"##### mesh data count = " << mesh_info.data_count << " timestamp: " << mesh_info.timestamp << " state: " << mesh_info.data->state;
            break;
        case MLResult_Pending:
            LOGAR_DEBUG<<"##### meshinfo pending”; // never comes in here
            break;
        case MLResult_PerceptionSystemNotStarted:
            LOGAR_DEBUG << "##### MLResult_PerceptionSystemNotStarted”; // never comes in here
            break;
        case MLResult_InvalidParam:
            LOGAR_DEBUG << "##### MLMeshingGetMeshInfoResult MLResult_InvalidParam”; // never comes in here
            break;
        default:
            LOGAR_DEBUG << "##### MLMeshingGetMeshInfoResult default”; // never comes in here
  }
}

```

- All the Magic Leap calls are returning MLResult\_Ok.
- It looks like MLMeshingGetMeshInfoResult() does not return/update mesh\_info at all.
- In contrast to the meshing sample, MLMeshingRequestMeshInfo() never returns MLResult\_Pending for us.
- Nor does it update the result.

I’m sure we are missing something.

Thanks,  
Richard

---

<div class="post-metadata">

**Author:** ![rp1](https://avatars.discourse-cdn.com/v4/letter/r/13edae/32.png) [@rp1](https://forum.magicleap.cloud/u/rp1)\
**Post date:** [June 7, 2023, 2:40pm UTC](https://forum.magicleap.cloud/t/native-meshing-not-working/2034/5 "2023-06-07T14:40:51Z")

</div>

Hi,

I found the issue:  
We forgot to initialise request\_extents\_, which is used by  
`MLMeshingRequestMeshInfo(meshing_client_, &request_extents_, &current_mesh_info_request_);`

When initialising it properly, it’s working!

Thanks,  
Richard

---

<div class="post-metadata">

**Author:** ![kdowney](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kdowney/32/481_2.png) [@kdowney](https://forum.magicleap.cloud/u/kdowney)\
**Post date:** [June 7, 2023, 8:51pm UTC](https://forum.magicleap.cloud/t/native-meshing-not-working/2034/6 "2023-06-07T20:51:44Z")

</div>

Glad to hear @rp1. Best of luck with your project.
