User avatar
matt.rudder
Topic Author
Posts: 21
Joined: 24 May 2013, 08:12
Location: San Francisco, CA
Contact:

Debugging crashes in Unity with NoesisGUI

31 May 2013, 18:23

Hey guys,

I'm running into a crash manipulating one of my UIs, and I'm trying find out what the issue is. It looks like the crash happens right after calling ScrollViewer.ScrollToHorizontalOffset. This makes me curious about a couple things.

First, is there anyway to shield Unity from errors in NoesisGUI? Right now a single binding or API getting invalid input takes down the entire editor process, which makes iteration a bit of a pain.

Second, I noticed a log file in the bin folder of the SDK. Is that from the runtime of NoesisGUI? I tried to get some information from that about my crash, but it doesn't look like it's plain text file. Do you have a custom application for viewing these logs? If so, are there plans to include this with the SDK so we can view them?

Here is stack trace that shows up in the Unity crash reporter logs:
(0x28333960) (Noesis): (filename not available): Noesis::Gui::ScrollContentPresenter::SetHorizontalOffset + 0x0
(0x1FAFC416) (Mono JIT code): (filename not available):  (wrapper delegate-invoke) Noesis.NoesisUnityPINVOKE/Point_SetXDelegate:invoke_void__this___HandleRef_single (System.Runtime.InteropServices.HandleRef,single) + 0x1ae (1FAFC268 1FAFC42D) [07EB6BD0 - Unity Child Domain] + 0x0
(0x1FAFD7E0) (Mono JIT code): (filename not available):  Noesis.NoesisUnityPINVOKE:ScrollViewer_ScrollToHorizontalOffset (System.Runtime.InteropServices.HandleRef,single) + 0x58 (1FAFD788 1FAFD7F7) [07EB6BD0 - Unity Child Domain] + 0x0
(0x1FAFD762) (Mono JIT code): (filename not available):  Noesis.ScrollViewer:ScrollToHorizontalOffset (single) + 0x52 (1FAFD710 1FAFD779) [07EB6BD0 - Unity Child Domain] + 0x0
(0x1FAFA92A) (Mono JIT code): (filename not available):  ScrollViewDragger:OnPreviewMouseMove (Noesis.BaseComponent,Noesis.MouseEventArgs) + 0x26a (1FAFA6C0 1FAFA941) [07EB6BD0 - Unity Child Domain] + 0x0
(0x1FAFA3AC) (Mono JIT code): (filename not available):  Noesis.UIElement:RaisePreviewMouseMove (intptr,intptr) + 0xbc (1FAFA2F0 1FAFA3C3) [07EB6BD0 - Unity Child Domain] + 0x0
(0x1A480170) (Mono JIT code): (filename not available):  (wrapper native-to-managed) Noesis.UIElement:RaisePreviewMouseMove (intptr,intptr) + 0xa0 (1A4800D0 1A480189) [07EB6BD0 - Unity Child Domain] + 0x0
(0x28481B84) (Noesis): (filename not available): CSharp_BindEventTimelineCompleted + 0x134
(0x28374659) (Noesis): (filename not available): Noesis::Gui::UIElement::TunnelingEvent + 0x49
(0x28371FB6) (Noesis): (filename not available): Noesis::Gui::UIElement::RaiseEvent + 0x36
(0x282F6D45) (Noesis): (filename not available): Noesis::Gui::Mouse::Move + 0x95
(0x284829E9) (Noesis): (filename not available): Noesis_MouseMove + 0x19
(0x1FAF67C9) (Mono JIT code): (filename not available):  (wrapper delegate-invoke) Noesis.UIRenderer/MouseMoveDelegate:invoke_void__this___intptr_single_single (intptr,single,single) + 0x159 (1FAF6670 1FAF67E0) [07EB6BD0 - Unity Child Domain] + 0x0
(0x1FAF6653) (Mono JIT code): (filename not available):  No
XAML:
<Border xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        VerticalAlignment="Stretch"
        HorizontalAlignment="Stretch">
  <Border.Resources>
    <ResourceDictionary>
      <!-- ListBox Style -->
      <Style TargetType="{x:Type ListBox}">
        <Setter Property="UseLayoutRounding" Value="true"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
        <Setter Property="Foreground" Value="Transparent"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate TargetType="{x:Type ListBox}">
              <Border
            Name="Border"
            Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            BorderThickness="{TemplateBinding BorderThickness}"
            Padding="1"
            CornerRadius="2"
            UseLayoutRounding="True">
                <ScrollViewer
              x:Name="Scroller"
              Margin="{TemplateBinding Padding}"
              Focusable="false"
              HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
              VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
              CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}">
                  <ItemsPresenter UseLayoutRounding="{TemplateBinding UseLayoutRounding}"/>
                </ScrollViewer>
              </Border>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
      </Style>

      <Style x:Key="SelectionItem" TargetType="{x:Type ListBoxItem}">
        <Style.Setters>
          <Setter Property="Template">
            <Setter.Value>
              <ControlTemplate TargetType="{x:Type ListBoxItem}">
                <DockPanel LastChildFill="True" Width="128" Height="128" Margin="8,0,0,0">
                  <ContentPresenter DockPanel.Dock="Bottom" HorizontalAlignment="Center" VerticalAlignment="Center" />
                  <Border Background="#F2B600">
                    <TextBlock Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="32">?</TextBlock>
                  </Border>
                </DockPanel>
              </ControlTemplate>
            </Setter.Value>
          </Setter>
        </Style.Setters>
      </Style>
    </ResourceDictionary>
  </Border.Resources>
  <ListBox x:Name="MyList">
    <ListBox.ItemsPanel>
      <ItemsPanelTemplate>
        <StackPanel Orientation="Horizontal" />
      </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="1" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="2" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="3" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="4" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="5" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="1" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="2" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="3" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="4" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="5" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="1" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="2" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="3" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="4" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="5" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="1" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="2" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="3" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="4" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="5" />
  </ListBox>
</Border>
ScrollViewDragger.cs:
using UnityEngine;
using Noesis;

public class ScrollViewDragger : MonoBehaviour
{
  public float m_friction = 0.2f;

  // Use this for initialization
  void Start()
  {
    m_scrollTarget = new Point();
    m_scrollStartPoint = new Pointi();
    m_scrollStartOffset = new Point();
    m_velocity = new Point();
    m_previousPos = new Pointi();

    var gui = GetComponent<NoesisGUIPanel>();
    m_grid = gui.GetRoot<Grid>();

    m_picker = m_grid.FindName<ListBox>("MyList");
    if (m_picker != null)
    {
      var template = m_picker.GetTemplate();
      var scroller = template.FindName("Scroller");
      m_scrollViewer = scroller.As<ScrollViewer>();

      m_picker.PreviewMouseDown += OnPreviewMouseDown;
      m_picker.PreviewMouseMove += OnPreviewMouseMove;
      m_picker.PreviewMouseUp += OnPreviewMouseUp;
    }
  }


  void OnPreviewMouseUp(BaseComponent sender, MouseButtonEventArgs e)
  {
    Debug.Log("OnPreviewMouseUp: IsMouseCaptured=" + m_grid.GetIsMouseCaptured());
    if (m_mouseCaptured)//m_grid.GetIsMouseCaptured())
    {
      m_mouseCaptured = false;
      //m_grid.ReleaseMouseCapture();
      Debug.Log("OnPreviewMouseUp: MouseCaptureReleased!");
    }
  }

  void OnPreviewMouseDown(BaseComponent sender, MouseButtonEventArgs e)
  {
    Debug.Log("OnPreviewMouseDown: mouse over=" + m_picker.GetIsMouseOver());
    if (m_picker.GetIsMouseOver())
    {
      m_scrollStartPoint = m_picker.GetMouse().GetPosition();

      m_scrollStartOffset.x = m_scrollViewer.GetHorizontalOffset();
      m_scrollStartOffset.y = m_scrollViewer.GetVerticalOffset();

      m_mouseCaptured = true;
      //if (m_grid.CaptureMouse())
      //     Debug.Log("OnPreviewMouseDown: Mouse captured!");
    }
  }

  void OnPreviewMouseMove(BaseComponent sender, MouseEventArgs e)
  {
    //Debug.Log("OnPreviewMouseMove: IsMouseCaptured=" + m_grid.GetIsMouseCaptured());
    if (m_mouseCaptured)//m_grid.GetIsMouseCaptured())
    {
      Point currentPoint = e.position;
      Point delta = new Point(m_scrollStartPoint.x - currentPoint.x, m_scrollStartPoint.y - currentPoint.y);

      m_scrollTarget.x = m_scrollStartOffset.x + delta.x;
      m_scrollTarget.y = m_scrollStartOffset.y + delta.y;

      Debug.Log(string.Format("OnPreviewMouseMove: scrollTarget.x={0}", m_scrollTarget.x));
      m_scrollViewer.ScrollToHorizontalOffset(Mathf.Clamp(m_scrollTarget.x, 0f, m_scrollViewer.GetExtentWidth() - m_scrollViewer.GetViewportWidth()));
    }
  }

  // Update is called once per frame
  void Update()
  {
    if (m_mouseCaptured)//m_grid.GetIsMouseCaptured())
    {
      Pointi currentPos = m_picker.GetMouse().GetPosition();
      //Vector3 currentPos = Input.mousePosition;
      m_velocity.x = m_previousPos.x - currentPos.x;
      m_velocity.y = m_previousPos.y - currentPos.y;
      m_previousPos = currentPos;
    }
    else
    {
      if (!Mathf.Approximately(m_velocity.x, 0.0f))
      {
        float friction = 1.0f - Mathf.Clamp(m_friction, 0f, 1f);
        m_scrollViewer.ScrollToHorizontalOffset(Mathf.Clamp(m_scrollTarget.x, 0f, m_scrollViewer.GetExtentWidth() - m_scrollViewer.GetViewportWidth()));
        m_scrollTarget.x += m_velocity.x;
        m_velocity.x *= friction;
        m_velocity.y *= friction;
      }
    }
  }

  ListBox m_picker;
  Pointi m_scrollStartPoint;
  Point m_scrollStartOffset;
  Point m_scrollTarget;
  Point m_velocity;
  Pointi m_previousPos;
  Grid m_grid;
  bool m_mouseCaptured;
  ScrollViewer m_scrollViewer;
}
 
User avatar
sfernandez
Site Admin
Posts: 1918
Joined: 22 Dec 2011, 19:20

Re: Debugging crashes in Unity with NoesisGUI

31 May 2013, 20:33

Hi,

Native unhandled exceptions are not being catched right now, and this could be the reason of Unity Editor process shutdown. We are working on this issue and expect to be fixed for the next release.

The log file you found in SDK bin path is generated when you execute any of the applications you find there (XamlPlayer, BuildTool, ..), it is not related with Unity playing NoesisGUI. We made changes recently to generate log files also when playing NoesisGUI in Unity, that will be found in the root directory of the Unity project being used (also available in next release). This log files can be opened with our NoesisConsole tool that will be distributed with professional versions. The tool includes memory and cpu profilers to detect bottlenecks in the user interfaces being drawn.

About the error you are suffering, it is obviously a bug in our code that we will try to fix as soon as possible. But there is something I don't understand in your code, or at least, I think it is not correct. You are getting the ScrollViewer from the Template of the ListBox like this:
var template = m_picker.GetTemplate();
var scroller = template.FindName("Scroller");
m_scrollViewer = scroller.As<ScrollViewer>();
That ScrollViewer object instance is part of the ListBox template VisualTree, but it is not the one that was generated for your ListBox instance. Any time a template is applied to a control, a new instantiation of the template VisualTree is done, and assigned to the control. You cannot access those objects via template.FindName. You must get control visual child (that would be the root of the VisualTree instantiation for that control), and perform the FindName there.
FrameworkElement child = VisualTreeHelper.GetChild(m_picker, 0).As<FrameworkElement>();
m_scrollViewer = child.FindName<ScrollViewer>("Scroller");
Maybe we could add some FindTemplateName() helper function to simplify this process.

If you don't understand this part don't hesitate to ask because it is a bit hard to explain :?
 
User avatar
matt.rudder
Topic Author
Posts: 21
Joined: 24 May 2013, 08:12
Location: San Francisco, CA
Contact:

Re: Debugging crashes in Unity with NoesisGUI

31 May 2013, 20:51

Ok, great. The profiling tool sounds particularly useful! :)

I believe I tried the VisualTreeHelper route initially before landing on the GetTemplate route. Calling VisualTreeHelper.GetChild results in a crash in my test scene, unfortunately.
(0x0ADC10C1) c:\buildagent\work\14c008c4a873643b\eglib\src\goutput.c (159 + 0x2): g_logv + 0x6f
(0x0ADC10E3) c:\buildagent\work\14c008c4a873643b\eglib\src\goutput.c (169 + 0x16): g_log + 0x16
(0x0C2E0066) ((module-name not available)): (filename not available): (function-name not available) + 0x0
(0x1DE2640F) (Mono JIT code): (filename not available):  (wrapper delegate-invoke) Noesis.NoesisUnityPINVOKE/VisualTreeHelper_GetChildDelegate:invoke_intptr__this___HandleRef_uint (System.Runtime.InteropServices.HandleRef,uint) + 0x19f (1DE26270 1DE26426) [081E6BD0 - Unity Child Domain] + 0x0
(0x1DE26252) (Mono JIT code): (filename not available):  Noesis.NoesisUnityPINVOKE:VisualTreeHelper_GetChild (System.Runtime.InteropServices.HandleRef,uint) + 0x5a (1DE261F8 1DE2626F) [081E6BD0 - Unity Child Domain] + 0x0
(0x1DE26048) (Mono JIT code): (filename not available):  Noesis.VisualTreeHelper:GetChild (Noesis.Visual,uint) + 0x58 (1DE25FF0 1DE260ED) [081E6BD0 - Unity Child Domain] + 0x0
(0x1DE24ADA) (Mono JIT code): (filename not available):  ScrollViewDragger:Start () + 0x212 (1DE248C8 1DE24C57) [081E6BD0 - Unity Child Domain] + 0x0
(0x0A18BE1F) (Mono JIT code): (filename not available):  (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr) + 0x8f (0A18BD90 0A18BEEA) [081E6BD0 - Unity Child Domain] + 0x0
(0x0AEAFF9C) c:\buildagent\work\14c008c4a873643b\mono\mini\mini.c (4889 + 0xc): mono_jit_runtime_invoke + 0x214
(0x0AE1EBBE) c:\buildagent\work\14c008c4a873643b\mono\metadata\object.c (2615 + 0x10): mono_runtime_invoke + 0x51
(0x00804386) c:\buildagent\work\7535de4ca26c26ac\runtime\mono\monoutility.h (448 + 0x10): mono_runtime_invoke_profiled_fast + 0x86
(0x0080616A) c:\buildagent\work\7535de4ca26c26ac\runtime\mono\monobehaviour.cpp (860 + 0xf): MonoBehaviour::InvokeMethodOrCoroutineChecked + 0x6a
(0x00806539) c:\buildagent\work\7535de4ca26c26ac\runtime\mono\monobehaviour.cpp (952 + 0x0): MonoBehaviour::InvokeMethodOrCoroutineChecked + 0x99
(0x00806DCB) c:\buildagent\work\7535de4ca26c26ac\runtime\mono\monobehaviour.cpp (559 + 0xa): MonoBehaviour::Start + 0xdb
(0x006ADD9E) c:\buildagent\work\7535de4ca26c26ac\runtime\gamecode\calldelayed.cpp (164 + 0xb): DelayedCallManager::Update + 0x16e
(0x00795DAD) c:\buildagent\work\7535de4ca26c26ac\runtime\misc\player.cpp (1605 + 0x0): PlayerLoop + 0x1cd
(0x00DDD156) c:\buildagent\work\7535de4ca26c26ac\editor\src\application.cpp (2167 + 0xb): Application::UpdateScene + 0x216
(0x00DE0DCF) c:\buildagent\work\7535de4ca26c26ac\editor\src\application.cpp (2341 + 0x0): Application::SetIsPlaying + 0x31f
(0x00DE61B3) c:\buildagent\work\7535de4ca26c26ac\editor\src\application.cpp (1274 + 0x0): Application::TickTimer + 0x773
(0x00E68AC2) c:\buildagent\work\7535de4ca26c26ac\editor\platform\windows\wineditormain.cpp (335 + 0x0): MainMessageLoop + 0x1c2
(0x00E699AC) c:\buildagent\work\7535de4ca26c26ac\editor\platform\windows\wineditormain.cpp (834 + 0x0): WinMain + 0xddc
(0x00F7374F) f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c (275 + 0x1c): __tmainCRTStartup + 0x11a
(0x76EC33AA) (kernel32): (filename not available): BaseThreadInitThunk + 0x12
(0x77C39EF2) (ntdll): (filename not available): RtlInitializeExceptionChain + 0x63
(0x77C39EC5) (ntdll): (filename not available): RtlInitializeExceptionChain + 0x36
 
User avatar
sfernandez
Site Admin
Posts: 1918
Joined: 22 Dec 2011, 19:20

Re: Debugging crashes in Unity with NoesisGUI

03 Jun 2013, 12:32

The VisualTreeHelper route is the correct way to access template children. We will solve this bug as soon as possible.
 
User avatar
sfernandez
Site Admin
Posts: 1918
Joined: 22 Dec 2011, 19:20

Re: Debugging crashes in Unity with NoesisGUI

03 Jun 2013, 17:48

The ScrollContentPresenter.SetHorizontalOffset() bug was found and solved ;)
Will be fixed in the following release.

About the VisualTreeHelper.GetChild() bug, I was unable to reproduce it. The code I posted:
FrameworkElement child = VisualTreeHelper.GetChild(m_picker, 0).As<FrameworkElement>();
m_scrollViewer = child.FindName<ScrollViewer>("Scroller");
...was working fine for me.

Could you post the script that produced the last error?
 
User avatar
matt.rudder
Topic Author
Posts: 21
Joined: 24 May 2013, 08:12
Location: San Francisco, CA
Contact:

Re: Debugging crashes in Unity with NoesisGUI

03 Jun 2013, 18:28

Sure, here it is. Still a bit in progress as I was debugging some issues with it. I couldn't get the mouse capture behavior working correctly either, but I might have been doing something wrong.
using UnityEngine;
using Noesis;

public class ScrollViewDragger : MonoBehaviour
{
  public float m_friction = 0.2f;
  public string m_listBoxName = "MyList";

  // Use this for initialization
  void Start()
  {
    m_scrollTarget = new Point();
    m_scrollStartPoint = new Pointi();
    m_scrollStartOffset = new Point();
    m_velocity = new Point();
    m_previousPos = new Pointi();

    var gui = GetComponent<NoesisGUIPanel>();
    m_grid = gui.GetRoot<Grid>();

    m_picker = m_grid.FindName<ListBox>(m_listBoxName);
    if (m_picker != null)
    {
      FrameworkElement child = VisualTreeHelper.GetChild(m_picker, 0).As<FrameworkElement>();
      m_scrollViewer = child.FindName<ScrollViewer>("Scroller");

      m_picker.PreviewMouseDown += OnPreviewMouseDown;
      m_picker.PreviewMouseMove += OnPreviewMouseMove;
      m_picker.PreviewMouseUp += OnPreviewMouseUp;
    }
  }


  void OnPreviewMouseUp(BaseComponent sender, MouseButtonEventArgs e)
  {
    Debug.Log("OnPreviewMouseUp: IsMouseCaptured=" + m_grid.GetIsMouseCaptured());
    if (m_mouseCaptured)//m_grid.GetIsMouseCaptured())
    {
      m_mouseCaptured = false;
      //m_grid.ReleaseMouseCapture();
      Debug.Log("OnPreviewMouseUp: MouseCaptureReleased!");
    }
  }

  void OnPreviewMouseDown(BaseComponent sender, MouseButtonEventArgs e)
  {
    Debug.Log("OnPreviewMouseDown: mouse over=" + m_picker.GetIsMouseOver());
    if (m_picker.GetIsMouseOver())
    {
      m_scrollStartPoint = m_picker.GetMouse().GetPosition();

      m_scrollStartOffset.x = m_scrollViewer.GetHorizontalOffset();
      m_scrollStartOffset.y = m_scrollViewer.GetVerticalOffset();

      m_mouseCaptured = true;
      //if (m_grid.CaptureMouse())
      //     Debug.Log("OnPreviewMouseDown: Mouse captured!");
    }
  }

  void OnPreviewMouseMove(BaseComponent sender, MouseEventArgs e)
  {
    //Debug.Log("OnPreviewMouseMove: IsMouseCaptured=" + m_grid.GetIsMouseCaptured());
    if (m_mouseCaptured)//m_grid.GetIsMouseCaptured())
    {
      Point currentPoint = e.position;
      Point delta = new Point(m_scrollStartPoint.x - currentPoint.x, m_scrollStartPoint.y - currentPoint.y);

      m_scrollTarget.x = m_scrollStartOffset.x + delta.x;
      m_scrollTarget.y = m_scrollStartOffset.y + delta.y;

      Debug.Log(string.Format("OnPreviewMouseMove: scrollTarget.x={0}", m_scrollTarget.x));
      //m_scrollViewer.SetBackground(Brushes.CornflowerBlue());
      m_scrollViewer.ScrollToHorizontalOffset(Mathf.Clamp(m_scrollTarget.x, 0f, m_scrollViewer.GetExtentWidth() - m_scrollViewer.GetViewportWidth()));
    }
  }

  // Update is called once per frame
  void Update()
  {
    if (m_mouseCaptured)//m_grid.GetIsMouseCaptured())
    {
      Pointi currentPos = m_picker.GetMouse().GetPosition();
      //Vector3 currentPos = Input.mousePosition;
      m_velocity.x = m_previousPos.x - currentPos.x;
      m_velocity.y = m_previousPos.y - currentPos.y;
      m_previousPos = currentPos;
    }
    else
    {
      if (!Mathf.Approximately(m_velocity.x, 0.0f))
      {
        float friction = 1.0f - Mathf.Clamp(m_friction, 0f, 1f);
        m_scrollViewer.ScrollToHorizontalOffset(Mathf.Clamp(m_scrollTarget.x, 0f, m_scrollViewer.GetExtentWidth() - m_scrollViewer.GetViewportWidth()));
        //m_scrollViewer.SetBackground(Brushes.Tomato());
        m_scrollTarget.x += m_velocity.x;
        m_velocity.x *= friction;
        m_velocity.y *= friction;
      }
    }
  }

  ListBox m_picker;
  Pointi m_scrollStartPoint;
  Point m_scrollStartOffset;
  Point m_scrollTarget;
  Point m_velocity;
  Pointi m_previousPos;
  Grid m_grid;
  bool m_mouseCaptured;
  ScrollViewer m_scrollViewer;
}
Here's the test XAML for it:
<Border xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        VerticalAlignment="Stretch"
        HorizontalAlignment="Stretch">
  <Border.Resources>
    <ResourceDictionary>
      <!-- ListBox Style -->
      <Style TargetType="{x:Type ListBox}">
        <Setter Property="UseLayoutRounding" Value="true"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
        <Setter Property="Foreground" Value="Transparent"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate TargetType="{x:Type ListBox}">
              <Border
            Name="Border"
            Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            BorderThickness="{TemplateBinding BorderThickness}"
            Padding="1"
            CornerRadius="2"
            UseLayoutRounding="True">
                <ScrollViewer
              x:Name="Scroller"
              Margin="{TemplateBinding Padding}"
              Focusable="false"
              HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
              VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
              CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}">
                  <ItemsPresenter UseLayoutRounding="{TemplateBinding UseLayoutRounding}"/>
                </ScrollViewer>
              </Border>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
      </Style>

      <Style x:Key="SelectionItem" TargetType="{x:Type ListBoxItem}">
        <Style.Setters>
          <Setter Property="Template">
            <Setter.Value>
              <ControlTemplate TargetType="{x:Type ListBoxItem}">
                <DockPanel LastChildFill="True" Width="128" Height="128" Margin="8,0,0,0">
                  <ContentPresenter DockPanel.Dock="Bottom" HorizontalAlignment="Center" VerticalAlignment="Center" />
                  <Border Background="#F2B600">
                    <TextBlock Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="32">?</TextBlock>
                  </Border>
                </DockPanel>
              </ControlTemplate>
            </Setter.Value>
          </Setter>
        </Style.Setters>
      </Style>
    </ResourceDictionary>
  </Border.Resources>
  <ListBox x:Name="MyList">
    <ListBox.ItemsPanel>
      <ItemsPanelTemplate>
        <StackPanel Orientation="Horizontal" />
      </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="1" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="2" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="3" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="4" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="5" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="1" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="2" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="3" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="4" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="5" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="1" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="2" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="3" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="4" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="5" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="1" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="2" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="3" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="4" />
    <ListBoxItem Style="{StaticResource SelectionItem}" Content="5" />
  </ListBox>
</Border>
 
User avatar
sfernandez
Site Admin
Posts: 1918
Joined: 22 Dec 2011, 19:20

Re: Debugging crashes in Unity with NoesisGUI

06 Jun 2013, 11:24

We found the bug that causes the crash with VisualTreeHelper::GetChild(). It was hard to track, but finally found it was related with mismatched calling conventions between native exported functions and imported function pointers in mono.

We are preparing a new release that patches this and other bugs, will be ready to download in a few hours.
 
User avatar
matt.rudder
Topic Author
Posts: 21
Joined: 24 May 2013, 08:12
Location: San Francisco, CA
Contact:

Re: Debugging crashes in Unity with NoesisGUI

06 Jun 2013, 17:30

That's encouraging. Seems like a bug like that could cause issues all throughout the library, so I hope my reproduction steps helped. :)

Thanks for the update!
 
User avatar
sfernandez
Site Admin
Posts: 1918
Joined: 22 Dec 2011, 19:20

Re: Debugging crashes in Unity with NoesisGUI

06 Jun 2013, 18:38

Any feedback you provide is very valuable to us. Without it we could not polish our product as we are. Thank you so much.

The new version is already updated, have a try ;)

Who is online

Users browsing this forum: No registered users and 1 guest