This is a migrated thread and some comments may be shown as answers.

Tilt Interaction effect null pointer

8 Answers 85 Views
DataBoundListBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Julio
Top achievements
Rank 1
Julio asked on 02 Apr 2012, 03:37 PM
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.

8 Answers, 1 is accepted

Sort by
0
Julio
Top achievements
Rank 1
answered on 02 Apr 2012, 03:49 PM
   <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>
0
Kiril Stanoev
Telerik team
answered on 09 Apr 2012, 01:25 PM
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 >>

0
Paul
Top achievements
Rank 1
answered on 21 Jul 2012, 07:03 PM
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)
0
Kiril Stanoev
Telerik team
answered on 23 Jul 2012, 08:09 AM
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.

0
Paul
Top achievements
Rank 1
answered on 26 Jul 2012, 02:35 AM
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.
0
Paul
Top achievements
Rank 1
answered on 26 Aug 2012, 04:01 PM
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)

0
Kiril Stanoev
Telerik team
answered on 27 Aug 2012, 09:46 AM
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.

0
Paul
Top achievements
Rank 1
answered on 27 Aug 2012, 02:34 PM
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
Tags
DataBoundListBox
Asked by
Julio
Top achievements
Rank 1
Answers by
Julio
Top achievements
Rank 1
Kiril Stanoev
Telerik team
Paul
Top achievements
Rank 1
Share this question
or