ExtendRealityLtd / Zinnia.Unity

A collection of design patterns for solving common problems.
http://vrtk.io
MIT License
319 stars 38 forks source link

On Unpause (5/5 runs) - StraightLineCast has 0 length array #557

Closed studentutu closed 2 years ago

studentutu commented 2 years ago

Environment

Unity 2020.3.16f1

Steps to reproduce

1) Create simple rig with CameraRigs.TrackedAlias and 2 interactable pointers 2) Add Straight Pointers for left/right hand. Make it always visible. Set activations so that the activation event is always processed (pointer is always active) 4) Build Android Project and run on Pico 5) Launch App 6) Press Home button to navigate to Pico Quick System Menu. Wait for few seconds. 6) Go back to your app ( continue your app) 7) Sometimes it will throw out of boundary exceptions. ( 5/5) tries

This is also reproducible on Quest 1.

Expected behavior

It should have a check for length before using indecies.

Current behavior

ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index ?, line 0, in System.ThrowHelper.ThrowArgumentOutOfRangeException ?, line 0, in System.ThrowHelper.ThrowArgumentOutOfRangeException ?, line 0, in System.Collections.Generic.List`1[T].set_Item ?, line 0, in Zinnia.Cast.StraightLineCast.GeneratePoints ?, line 0, in Zinnia.Cast.StraightLineCast.DoCastPoints ?, line 0, in Zinnia.Process.Moment.MomentProcess.ProcessNow ?, line 0, in Zinnia.Process.Moment.MomentProcessor.Process ?, line 0, in UnityEngine.Camera+CameraCallback.Invoke

Briefly describe what is actually happening. image

studentutu commented 2 years ago

as well as this issue :

NullReferenceException: Object reference not set to an instance of an object
  File "<03c4cef74c314705b9055b51c799ab32>", line 0, in Zinnia.Cast.PointsCast.OnAfterTargetHitChange
  File "<03c4cef74c314705b9055b51c799ab32>", line 0, in Zinnia.Cast.PointsCast.OnEnable
  File "<03c4cef74c314705b9055b51c799ab32>", line 0, in Zinnia.Cast.StraightLineCast.OnEnable

image

studentutu commented 2 years ago

@thestonefox found out the cause - public RaycastHit? TargetHit - is not being cleared on disable.

thestonefox commented 2 years ago

So we should probably guard against the null's anyway, but also clear the TargetHit on disable too

studentutu commented 2 years ago

maybe there are other places that should clear the state/object in onDisable?

thestonefox commented 2 years ago

If you find anywhere else then list it here.

I can try create a test to replicate the issue so it can be run in the test suite to prove any fixes applied cause the test to pass

studentutu commented 2 years ago

Also, I can now check it reliable:

Put Enabling of the Whole Straight Pointer GameObject onto TrackedAlias.[Right|Left]ControllerTrackingBegun events

studentutu commented 2 years ago

@thestonefox So far - only this is the biggest cause of issues. When running app in kiosk mode (launcher mode) -> it is only 1 place that we have encountered such errors

studentutu commented 2 years ago

This one is the main cause for the errors - so if StraightLineCast will clear TargetHit -> we should not have other issues

NullReferenceException: Object reference not set to an instance of an object
  File "<3a45b3222c88403089655c9337569bae>", line 0, in Zinnia.Cast.PointsCast.OnAfterTargetHitChange
  File "<3a45b3222c88403089655c9337569bae>", line 0, in Zinnia.Cast.PointsCast.OnEnable
  File "<3a45b3222c88403089655c9337569bae>", line 0, in Zinnia.Cast.StraightLineCast.OnEnable
thestonefox commented 2 years ago

PR with fix https://github.com/ExtendRealityLtd/Zinnia.Unity/pull/560

ExtendReality-Bot commented 2 years ago

:tada: This issue has been resolved in version 1.45.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: