qian256 / HoloLensARToolKit

Marker tracking using the front-facing camera of HoloLens (both 1 and 2) and Unity, with a wrapper of ARToolKit built for UWP (Windows Universal Platform)
GNU Lesser General Public License v3.0
349 stars 92 forks source link

Got NullReferenceException error with XR Plugin Management #55

Closed foungyu closed 3 years ago

foungyu commented 4 years ago

Thanks for sharing this project, it works well with 2019.4.6f1 Unity XR Legacy, however when I switch to XR Plugin Management. it throws exception. Do you have any thoughts on what might cause this issue? Thanks.

Exception thrown at 0x00007FFB728839EC in HoloLensARToolKit.exe: Microsoft C++ exception: Il2CppExceptionWrapper at memory location 0x0000000E1DEFDD00.
NullReferenceException: Object reference not set to an instance of an object.
  at ARUWP+LogCallback..ctor (System.Object object, System.IntPtr method) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Array.UnsafeStore[T] (T[] array, System.Int32 index, T value) [0x00000] in <00000000000000000000000000000000>:0 
  at ARUWPVideo.InitializeMediaCaptureAsyncTask () [0x00000] in <00000000000000000000000000000000>:0 
  at ARUWP+LogCallback..ctor (System.Object object, System.IntPtr method) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Array.UnsafeStore[T] (T[] array, System.Int32 index, T value) [0x00000] in <00000000000000000000000000000000>:0 
  at ARUWPController.InitAsync () [0x00000] in <00000000000000000000000000000000>:0 
  at ARUWPController.LateUpdate () [0x00000] in <00000000000000000000000000000000>:0 
qian256 commented 4 years ago

Honestly, I never tried it with the new XR Plugin Management. If it is complaining about logging, you can try disable the log from native, just uncomment the part related to setting up the log callback.

foungyu commented 3 years ago

Hi Qian, thanks for your reply. It turns out the issue in XR plug-in system is WorldManager.GetNativeISpatialCoordinateSystemPtr in ARUWPVideo, it returns null Ptr if you use XR plugin system, check Unity doc link here . So using WindowsMREnvironment.OriginSpatialCoordinateSystem instead of GetNativeISpatialCoordinateSystemPtr fixes the issue.

soudehchegini commented 3 years ago

@foungyu Thankyou for your post- what is the full line you replaced the error script line with please?