Tilt Interaction effect null pointer

9 posts, 0 answers
  1. Julio
    Julio avatar
    3 posts
    Member since:
    Mar 2012

    Posted 02 Apr 2012 Link to this post

    System.NullReferenceException was unhandled
      Message=NullReferenceException
      StackTrace:
           at Telerik.Windows.Controls.TiltInteractionInfo.Clear(Boolean animate)
           at Telerik.Windows.Controls.TiltInteractionEffect.EndTilting(Boolean animate)
           at Telerik.Windows.Controls.TiltInteractionEffect.OnElementManipulationCompleted(Object sender, RoutedEventArgs e)
           at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
           at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)


    I get this error sometimes when executing a call.
  2. Julio
    Julio avatar
    3 posts
    Member since:
    Mar 2012

    Posted 02 Apr 2012 Link to this post

       <controls:PivotItem x:Name="SearchPivot" Header="Search" Margin="0,0,0,-2" KeyDown="SearchPivot_KeyDown" 
    tc:InteractionEffectManager.IsInteractionEnabled="True"
    
    > <Grid x:Name="SearchGrid"> <TextBox x:Name="searchbox" TextWrapping="Wrap" VerticalAlignment="Top" Margin="0,8,96,0" Background="#5D000400"/> <tp:RadDataBoundListBox x:Name="searchlist" ItemsSource ="{Binding SearchCurrentForums}" IsSynchronizedWithCurrentItem="True" EmptyContent="No Forums to Display" ItemTemplate="{StaticResource ListBoxItemTemplate}"  Margin="0,80,0,0" ItemTap="searchlist_ItemTap" IsAsyncBalanceEnabled="True" RealizedItemsBufferScale="4"> <tp:RadDataBoundListBox.VirtualizationStrategyDefinition> <tp:StackVirtualizationStrategyDefinition Orientation="Vertical"/> </tp:RadDataBoundListBox.VirtualizationStrategyDefinition> </tp:RadDataBoundListBox> <Controls:RoundButton Content="" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,17,20,0" Foreground="Black" BorderBrush="Black" ImageSource="appbar.feature.search.rest.png" Tap="SearchButton_Tap"/> </Grid>
  3. DevCraft banner
  4. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 09 Apr 2012 Link to this post

    Hello Julio,

    Thank you for contacting us and sorry for the delayed reply. We've been experiencing some technical difficulties with our support system. 

    Now straight to the question at hand. I managed to reproduce the issue and can confirm that it occurs in our code. I've already implemented a fix which will be available with our next internal build. Give it a try and let me know if you still experience the same issue. I'd be glad to further assist you. In addition, I've updated your telerik points accordingly.

    Greetings,
    Kiril Stanoev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. Paul
    Paul avatar
    6 posts
    Member since:
    Dec 2011

    Posted 21 Jul 2012 Link to this post

    I just had a customer report this in  my app.  I am using version 2012.2.607.2040 of the controls.  Is this likely fixed in the internal build as well?

    Application_UnhandledException
    Type: System.NullReferenceException
    Message: NullReferenceException
       at Telerik.Windows.Controls.TiltInteractionEffect.ApplyTilt(FrameworkElement element, FrameworkElement container, Point manipulationPoint)
       at Telerik.Windows.Controls.TiltInteractionEffect.OnElementManipulationDelta(Object sender, RoutedEventArgs args)
       at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
       at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)
  6. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 23 Jul 2012 Link to this post

    Hello Paul,

    Thank you for reporting this issue. I've implemented a fix which will be available with the next internal build. Give it a try and let me know if it works for you. I'd be glad to further assist you. I've also updated your Telerik points accordingly.

    Regards,
    Kiril Stanoev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  7. Paul
    Paul avatar
    6 posts
    Member since:
    Dec 2011

    Posted 25 Jul 2012 Link to this post

    Thanks for the quick fix.  I am using it in my next build.  I only got the report from a user and don't know how to repro.  Hopefully, I will never need to know how now.
  8. Paul
    Paul avatar
    6 posts
    Member since:
    Dec 2011

    Posted 26 Aug 2012 Link to this post

    I am still getting reports of this exception:

    I am using build: 2012.2.724.2040. Does this build have your fix?


    ExceptionMessage:NullReferenceException
    StackTrace:
    at
    Telerik.Windows.Controls.TiltInteractionEffect.ApplyTilt(FrameworkElement
    element, FrameworkElement container, Point manipulationPoint)
    at
    Telerik.Windows.Controls.TiltInteractionEffect.OnElementManipulationDelta(Object
    sender, RoutedEventArgs args)
    at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex,
    Delegate handlerDelegate, Object sender, Object args)
    at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr
    unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String
    eventName)

  9. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 27 Aug 2012 Link to this post

    Hi Paul,

    The fix I implemented did reach the 2012.2.724.2040 version of our controls. As it turns out, this fix is not enough. 

    This is how initially, the ApplyTilt looked like:

    private void ApplyTilt(FrameworkElement element, FrameworkElement container, Point manipulationPoint)
    {
        Point normalizedPoint = new Point(
            Math.Min(Math.Max(manipulationPoint.X / element.ActualWidth, 0), 1),
            Math.Min(Math.Max(manipulationPoint.Y / element.ActualHeight, 0), 1));
     
        double xMagnitude = Math.Abs(normalizedPoint.X - 0.5);
        double yMagnitude = Math.Abs(normalizedPoint.Y - 0.5);
        double xDirection = -Math.Sign(normalizedPoint.X - 0.5);
        double yDirection = Math.Sign(normalizedPoint.Y - 0.5);
        double angleMagnitude = xMagnitude + yMagnitude;
        double xAngleContribution = xMagnitude + yMagnitude > 0 ? xMagnitude / (xMagnitude + yMagnitude) : 0;
     
        double angle = angleMagnitude * this.MaxRotationAngle * 180 / Math.PI;
        double depression = (1 - angleMagnitude) * this.MaxZOffset;
     
        PlaneProjection projection = element.Projection as PlaneProjection;
        projection.RotationY = angle * xAngleContribution * xDirection;
        projection.RotationX = angle * (1 - xAngleContribution) * yDirection;
        projection.GlobalOffsetZ = -depression;
    }

    My first thought was that either element or container must be throwing the NullReference exception. Since, container is not used in the method, all was left was element:

    private void ApplyTilt(FrameworkElement element, FrameworkElement container, Point manipulationPoint)
    {
        if(element == null)
        {
            return;
        }
     
        Point normalizedPoint = new Point(
            Math.Min(Math.Max(manipulationPoint.X / element.ActualWidth, 0), 1),
            Math.Min(Math.Max(manipulationPoint.Y / element.ActualHeight, 0), 1));
     
        double xMagnitude = Math.Abs(normalizedPoint.X - 0.5);
        double yMagnitude = Math.Abs(normalizedPoint.Y - 0.5);
        double xDirection = -Math.Sign(normalizedPoint.X - 0.5);
        double yDirection = Math.Sign(normalizedPoint.Y - 0.5);
        double angleMagnitude = xMagnitude + yMagnitude;
        double xAngleContribution = xMagnitude + yMagnitude > 0 ? xMagnitude / (xMagnitude + yMagnitude) : 0;
     
        double angle = angleMagnitude * this.MaxRotationAngle * 180 / Math.PI;
        double depression = (1 - angleMagnitude) * this.MaxZOffset;
     
        PlaneProjection projection = element.Projection as PlaneProjection;
        projection.RotationY = angle * xAngleContribution * xDirection;
        projection.RotationX = angle * (1 - xAngleContribution) * yDirection;
        projection.GlobalOffsetZ = -depression;
    }

    Looking closer, one can see the other soft spot (element.Projection as PlaneProjection). I've applied one additional null reference check:

    private void ApplyTilt(FrameworkElement element, FrameworkElement container, Point manipulationPoint)
    {
        if (element == null)
        {
            return;
        }
     
        Point normalizedPoint = new Point(
            Math.Min(Math.Max(manipulationPoint.X / element.ActualWidth, 0), 1),
            Math.Min(Math.Max(manipulationPoint.Y / element.ActualHeight, 0), 1));
     
        double xMagnitude = Math.Abs(normalizedPoint.X - 0.5);
        double yMagnitude = Math.Abs(normalizedPoint.Y - 0.5);
        double xDirection = -Math.Sign(normalizedPoint.X - 0.5);
        double yDirection = Math.Sign(normalizedPoint.Y - 0.5);
        double angleMagnitude = xMagnitude + yMagnitude;
        double xAngleContribution = xMagnitude + yMagnitude > 0 ? xMagnitude / (xMagnitude + yMagnitude) : 0;
     
        double angle = angleMagnitude * this.MaxRotationAngle * 180 / Math.PI;
        double depression = (1 - angleMagnitude) * this.MaxZOffset;
     
        PlaneProjection projection = element.Projection as PlaneProjection;
         
        if (projection != null)
        {
            projection.RotationY = angle * xAngleContribution * xDirection;
            projection.RotationX = angle * (1 - xAngleContribution) * yDirection;
            projection.GlobalOffsetZ = -depression;
        }
    }

    The fix will be available with this week's internal build. Give it a try and let me know how it goes. I'd be glad to further assist you.

    Kind regards,
    Kiril Stanoev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  10. Paul
    Paul avatar
    6 posts
    Member since:
    Dec 2011

    Posted 27 Aug 2012 Link to this post

    Thanks Kiril,

    I don't see this exception in a controled environment. Instead it gets reported by email and via flurry.com from users.  Relative to the number of uses, it happens very rarely (about 1 in 10,000 runs). You would think the property would be null or it wouldn't.  I am beginning to wonder if tilt is triggered on some UI element where I am not expecting it and the exception is triggered when users happen to tap that.

    Thanks for your help!  I am always working on updates to the app, and I will get your latest build into the next update.

    Paul
Back to Top
DevCraft banner