NullReferenceException in WPF player

Hi

We just recently started to get an exception within the WPF player without any major changes in code. One customer had 5 such incidents during the weekend. We are using MIPSDK 23.2.1 in a standalone component integration. The exception is thrown when “maximizing” a player, i.e. taking a smaller player and replacing it with a new larger player with the same setup. I think the exception is thrown when the new player that is being constructed.

Attaching callstack from one such incident. The camera in this case is a Bosch FLEXIDOME IP starlight 6000 VR (CPP7).

The player is created something like this:

var imageViewerControl = new ImageViewerWpfControl
{
   EnableVisibleHeader = false,
   EnableMouseControlledPtz = true,
   EnableMousePtzEmbeddedHandler = false,
   EnableDigitalZoom = true,
   MaintainImageAspectRatio = true,
   Selected = IsSelected
};
 
imageViewerControl.CameraFQID = item.FQID;
imageViewerControl.Initialize();
imageViewerControl.Connect();

The callstack:

2024-10-26 15:05:45,881 [134:1] DEBUG Tennotech.Hilding.Watchman.App - Stacktrace:
   vid VideoOS.Platform.SDK.UI.PlatformImageViewerWpfControl.get_DoMouseControlledPTZ()
   vid VideoOS.Platform.SDK.UI.PlatformImageViewerWpfControl._smartClientVideoPlayer_PtzCenterPerformed(Object sender, PtzCenterEventArgs e)
   vid System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   vid System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   vid System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   vid VideoOS.UI.Common.WPF.VideoPlayer.Model.PtzModel.HandleCenterOperation(Point relativePoint)
   vid VideoOS.UI.Common.WPF.VideoPlayer.Control.UI.PTZOverlay.Handlers.RectanglePtzModeHandler.RectangleHandler_OnMouseLeftButtonUp(Object sender, MouseButtonEventArgs e)
   vid System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   vid System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   vid System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   vid System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   vid System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
   vid System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   vid System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   vid System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   vid System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   vid System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   vid System.Windows.Input.InputManager.ProcessStagingArea()
   vid System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   vid System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   vid System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   vid System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   vid System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   vid MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   vid MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   vid System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   vid System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

The NullReferenceException is thrown from PlatformImageViewerWpfControl.DoMouseControlledPTZ. Any ideas?

Best regards,

Ola Nygren, Tennotech

Just as I posted this I noticed the OnLeftButtonUp in the callstack. A player can be maximized by doubleclicking the player. The exception is probably thrown from the first player instead. It is probably already destructed when you are trying to do some PTZ-handling and that is causing the exception. I think I might be able to solve this now on my side, but maybe you could add some null-checks on you side as well to provide some extra stability.

/Ola

I have reported this to Milestone Development. Thank you for the post.

Milestone Development was not able to act on this, add some null checks is what you suggested, a developer asked me:

Could you ask them to provide some reproduction code based on their flow? Or a video recording of how this is supposed to work?

If you submit more information I will make sure to pass it to Development.