arfoundation-samples icon indicating copy to clipboard operation
arfoundation-samples copied to clipboard

[Bug] Enabling/Disabling (with DestroyAllMeshes) ARMeshManager causes crashes

Open AdrienMgm opened this issue 5 years ago • 2 comments

Unity bug report case number 1307393

Describe the bug We need to enable/disable the feature of ARMeshManager several times in our app. When only disabling ARMeshManager, all previously created meshes stay in the scene, which is not a wanted behaviour. So right before disabling ARMeshManager we're calling DestroyAllMeshes() and all meshes are effectively cleared. But when re-enabling the ARMeshManager gameObject, the app instantly crashes.

To Reproduce

  1. Create an AR project or start from the ARFoundation sample project
  2. Add the ARMeshManager as a child of ARSessionOrigin
  3. Add a MeshFilter to it that contains a MeshRenderer and a Material to debug the enable/disable of meshing.
  4. Create a button to Enable and Disable ARMeshManager. When disabling this component call DestroyAllMeshes() from ARMeshManager right before disabling it.
  5. Launch the app and scan your environment
  6. Disable the meshing and see that all meshes are cleared.
  7. Re-enable the meshing and see that the app crashes

Expected behavior The app should not crash when destroying all meshes and trying to re-scan your environment within the same session

Actual behavior The app crashes at the moment we re-enable the scanning (after being disabled and cleared)

Smartphone

  • Device: iPhone 12 Pro
  • OS: iOS 14.3
  • Unity version 2019.4.17f1
  • ARFoundation version 4.1.1
  • ARKit XRPlugin version 4.1.1

How to fix it This bug can be fixed by adding the following lines of code in the DestroyAllMeshes() function : m_Added.Clear(); m_Updated.Clear(); m_Removed.Clear(); I can't do it permanently because everytime I reopen the project, it seems that all packages are reimported, so it cleans any modifications.

AdrienMgm avatar Jan 19 '21 11:01 AdrienMgm

Have you got a callstack for the crash? The Xcode console might be useful, too.

tdmowrer avatar Jan 20 '21 00:01 tdmowrer

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 30 '21 10:01 stale[bot]