AndreiMisiukevich / TouchEffect

UI-responsive touch effects for Xamarin.Forms
MIT License
195 stars 33 forks source link

Null reference exception when command displays another view #44

Closed bohbra closed 4 years ago

bohbra commented 4 years ago

I get the following error when handler for TouchEff.Command changes the current screen.

{System.NullReferenceException: Object reference not set to an instance of an object
  at TouchEffect.TouchEff.GetCommandParameter (Xamarin.Forms.BindableObject bindable) [0x00000] in C:\GitHub\TouchEffectFork\TouchEffect\TouchEff.cs:427 
  at TouchEffect.TouchEff.get_CommandParameter () [0x00000] in C:\GitHub\TouchEffectFork\TouchEffect\TouchEff.cs:706 
  at TouchEffect.TouchEff.RaiseCompleted () [0x00000] in C:\GitHub\TouchEffectFork\TouchEffect\TouchEff.cs:863 
  at TouchEffect.TouchVisualManager.OnTapped (TouchEffect.TouchEff sender) [0x0002a] in C:\GitHub\TouchEffectFork\TouchEffect\TouchVisualManager.cs:183 
  at TouchEffect.TouchVisualManager.HandleTouch (TouchEffect.TouchEff sender, TouchEffect.Enums.TouchStatus status) [0x00184] in C:\GitHub\TouchEffectFork\TouchEffect\TouchVisualManager.cs:94 
  at TouchEffect.TouchEff.HandleTouch (TouchEffect.Enums.TouchStatus status) [0x00000] in C:\GitHub\TouchEffectFork\TouchEffect\TouchEff.cs:839 
  at TouchEffect.iOS.TouchUITapGestureRecognizer.HandleTouch (TouchEffect.Enums.TouchStatus status) [0x0000e] in C:\GitHub\TouchEffectFork\TouchEffect.iOS\PlatformTouchEff.cs:101 
  at TouchEffect.iOS.TouchUITapGestureRecognizer.TouchesEnded (Foundation.NSSet touches, UIKit.UIEvent evt) [0x00001] in C:\GitHub\TouchEffectFork\TouchEffect.iOS\PlatformTouchEff.cs:65 
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.10.0.17/src/Xamarin.iOS/UIKit/UIApplication.cs:86 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.10.0.17/src/Xamarin.iOS/UIKit/UIApplication.cs:65 
  at App.iOS.Application.Main (System.String[] args) [0x00001] in C:\GitHub\TouchEffectFork\App\App.iOS\Main.cs:17 }

I have an example in the fork here.

AndreiMisiukevich commented 4 years ago

Try to remove redundant handler (leave just Command)

bohbra commented 4 years ago

I got a different exception when I remove the handler (_effect is null):

{System.NullReferenceException: Object reference not set to an instance of an object
  at TouchEffect.iOS.TouchUITapGestureRecognizer.HandleTouch (TouchEffect.Enums.TouchStatus status) [0x0001b] in C:\GitHub\TouchEffectFork\TouchEffect.iOS\PlatformTouchEff.cs:102 
  at TouchEffect.iOS.TouchUITapGestureRecognizer.TouchesEnded (Foundation.NSSet touches, UIKit.UIEvent evt) [0x00001] in C:\GitHub\TouchEffectFork\TouchEffect.iOS\PlatformTouchEff.cs:65 
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.10.0.17/src/Xamarin.iOS/UIKit/UIApplication.cs:86 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.10.0.17/src/Xamarin.iOS/UIKit/UIApplication.cs:65 
  at App.iOS.Application.Main (System.String[] args) [0x00001] in C:\GitHub\TouchEffectFork\App\App.iOS\Main.cs:17 }
bohbra commented 4 years ago

Note that this issue only occurs in iOS

AndreiMisiukevich commented 4 years ago

Checking)