unitycoder/UnityPointCloudViewer

use native arrays crash with v3 tiles

GISnick opened this issue · 7 comments

In the latest version of the point cloud reader, i ran the Tiles-viewerV3 demo scene and unity editor crashes on loading of the point cloud if i enable use native arrays
If i do not use this option, everything works as expected.

I will provide more info if you are unable to reproduce the issue.

Point cloud viewer and tools
version: 2.80
Latest release date: Oct 11, 2023

Unity 2022.3.12f1
URP

custom point cloud converted from your converter that works in the previous version ok with native arrays

piece of editor.log



=================================================================
	Native Crash Reporting
=================================================================
Got a UNKNOWN while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
	Managed Stacktrace:
=================================================================
	  at <unknown> <0xffffffff>
	  at Unity.Collections.LowLevel.Unsafe.UnsafeUtility:MemCpy <0x00097>
	  at PointCloudHelpers.PointCloudMath:MoveFromByteArray <0x001f2>
	  at unitycodercom_PointCloudBinaryViewer.PointCloudViewerTilesDX11:ReadPointCloudThreaded <0x003a2>
	  at unitycodercom_PointCloudBinaryViewer.PointCloudViewerTilesDX11:LoaderWorkerThread <0x00162>
	  at System.Threading.ThreadHelper:ThreadStart_Context <0x000e1>
	  at System.Threading.ExecutionContext:RunInternal <0x001b5>
	  at System.Threading.ExecutionContext:Run <0x0002a>
	  at System.Threading.ExecutionContext:Run <0x0005a>
	  at System.Threading.ThreadHelper:ThreadStart <0x0004a>
	  at <Module>:runtime_invoke_void__this___object <0x000c9>

ok i'll check!

@GISnick didnt seemto happen on 2019.4.19f1 or 2023.3.0a13, 2022.3.7f1 (birp),
going to test URP next, but if you happen to have screenshot of your V3 viewer settings, i can check those also. (in case anything is different)

no URP issues, also tested converting small cloud with the latest external converter
https://github.com/unitycoder/PointCloudConverter/releases

if you can share some small sample where it crashes, can email me,
image

will do thanks! so on further inspection, it happens only when i use:

  • native arrays / true
  • release tile memory / true
  • limit tile points / true

native arrays works if limit tile points = false, and limit tile points works if native arrays = false.

but together they crash the editor

this is a very large cloud. ill do some messing around, maybe generate a new cloud with the newer converter and see if i can reproduce and give you a small example. may have to do with my massive dense cloud
image

Ah ok, must be related to that setting then, no need to send data i'll test those first.
*yes got crash when limit was enabled.

ok simple bug, i'll upload the fix in asset store in few days or so.. but you can fix it at:

// open PointCloudMath.cs
// find line
UnsafeUtility.MemCpy(&dstAddr[0], &srcAddr[0], src.Length);

// replace that 1 line with these 2 lines
long size = src.Length < dst.Length ? src.Length : dst.Length;
UnsafeUtility.MemCpy(&dstAddr[0], &srcAddr[0], size);

yes sir!! thanks working great now