unitycoder / UnityPointCloudViewer

Point Cloud Viewer and Tools for Unity
https://assetstore.unity.com/packages/tools/utilities/point-cloud-viewer-and-tools-16019?aid=1101lGti
128 stars 15 forks source link

use native arrays crash with v3 tiles #143

Closed GISnick closed 5 months ago

GISnick commented 7 months ago

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>
unitycoder commented 7 months ago

ok i'll check!

unitycoder commented 7 months ago

@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

GISnick commented 7 months ago

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

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

unitycoder commented 7 months ago

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.

unitycoder commented 7 months ago

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);
GISnick commented 7 months ago

yes sir!! thanks working great now

unitycoder commented 5 months ago

fixed in v2.90 asset store version also.