Demigiant / dotween

A Unity C# animation engine. HOTween v2
http://dotween.demigiant.com
Other
2.3k stars 346 forks source link

Non-fatal Exception: NullReferenceException on firebase crashlytics #603

Open AnPK193 opened 1 year ago

AnPK193 commented 1 year ago

I got this issue from firebase crashlytics and not sure where this log came from:

Non-fatal Exception: NullReferenceException 0 ??? 0x0 set_localPosition (UnityEngine.Transform) 1 ??? 0x0 Invoke (DG.Tweening.Core.DOSetter1[T]) 2 ??? 0x0 ApplyTween (DG.Tweening.Core.TweenerCore3[T1,T2,TPlugOptions]) 3 ??? 0x0 DoGoto (DG.Tweening.Tween) 4 ??? 0x0 Update (DG.Tweening.Core.TweenManager) 5 ??? 0x0 Update (DG.Tweening.Core.TweenManager) 6 ??? 0x0 Update (DG.Tweening.Core.DOTweenComponent)

I can not reproduce this bug. The game object seemed destroyed when a tween was in sequence. I enabled safe mode.

I used Unity 2019.4.38f1 and DOTWeen version v1.2.632 Any suggestions for me? Thanks!

Demigiant commented 1 year ago

Ahoy!

That indeed means that a tween's target was NULL when trying to set its position. Safe mode will capture that and prevent the error, but on iOS safe mode works only if stripping level is set to Strip Assemblies or Script Call Optimization is set to Slow and Safe (because otherwise try-catch calls are disabled).

AnPK193 commented 1 year ago

Thanks, @Demigiant for your response! I rechecked and found out that the log just happen on iOS only, but the setting was: Managed Stripping Level: Low Script Call Optimization: Slow and Safe like this screenshot: Screenshot 2022-10-14 at 9 32 32 AM Is any wrong setting here or other settings to make Safe mode on iOS disabled?

AnPK193 commented 1 year ago

UPDATE: I found that the bug still happens on Android. The safe mode still enable on iOS (I tried to add a bug something like the object target was destroyed while tween playing. I made an iOS build with this bug but no error happen)

AnPK193 commented 1 year ago

stack trace error I found on Android crashlystic: Non-fatal Exception: java.lang.Exception: NullReferenceException : Object reference not set to an instance of an object. at UnityEngine.Transform.set_localPosition(UnityEngine.Transform) at DG.Tweening.Core.DOSetter1[T].Invoke(DG.Tweening.Core.DOSetter1[T]) at DG.Tweening.Core.TweenerCore3[T1,T2,TPlugOptions].ApplyTween(DG.Tweening.Core.TweenerCore3[T1,T2,TPlugOptions]) at DG.Tweening.Tween.DoGoto(DG.Tweening.Tween) at DG.Tweening.Core.TweenManager.Update(DG.Tweening.Core.TweenManager) at DG.Tweening.Core.TweenManager.Update(DG.Tweening.Core.TweenManager) at DG.Tweening.Core.DOTweenComponent.Update(DG.Tweening.Core.DOTweenComponent)

Demigiant commented 1 year ago

I'm very puzzled. I just checked the code and that part is indeed inside a safe mode try-catch (if enabled), so it should be captured no matter what happens. The only possibility is that for some reason safe mode is indeed not enabled, but on iOS your settings look good. I see this Unity bug related to try-catches, but your version should be ok and it seems unrelated anyway (if confusedly). Could you try updating to DOTween's last version (API is the same so no problems there) and see if something changes?

P.S. I'm not familiar with Crashlytics, but is it possible that it reports exceptions even if they're try-caught?

AnPK193 commented 1 year ago

Thanks, @Demigiant we decided to use SetLink() API to put on some suspect points and keep modifying the metrics