View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001538 | NoesisGUI | Unity | public | 2019-08-16 00:30 | 2019-09-27 17:47 |
| Reporter | stonstad | Assigned To | sfernandez | ||
| Priority | normal | Severity | crash | ||
| Status | resolved | Resolution | fixed | ||
| Product Version | 2.2.3 | ||||
| Target Version | 2.2.5 | Fixed in Version | 2.2.5 | ||
| Summary | 0001538: Unity Crash on Project Load | ||||
| Description | I'm getting a repeatable crash on Unity editor startup ... during project load. It appears to be related to an assertion from Noesis. Editor.Log: Assertion failed on expression: 'g_ThreadedGfxDevice' [C:\buildslave\unity\build\Runtime/GfxDevice/GfxDevice.cpp line 148] The offending line of code is this: If I move the line of code the stack trace line number changes, too. So I think this is the line. I am attaching log, dump files, and the Noesis user control that seems to cause the crash. I am going to look to see if I can stop the crash. I might be doing something crazy -- I'll take a look. I thought this might be useful since it's a fatal editor crash. | ||||
| Attached Files | ViewBoxGridControl.cs (2,102 bytes)
using Noesis;
using System.Collections.Generic;
using Vector2 = UnityEngine.Vector2;
using Grid = Noesis.Grid;
namespace StellarConquest.Presentation.Unity.UI
{
public partial class ViewboxGridControl : Grid
{
public static readonly DependencyProperty ScalingEnabledProperty = DependencyProperty.Register("ScalingEnabled", typeof(bool), typeof(ViewboxGridControl), new PropertyMetadata(true));
public static readonly List<Vector2> AspectRatios = new List<Vector2>()
{
new Vector2(7680, 4320), // 0
new Vector2(3840, 2160), // 1
new Vector2(2560, 1440), // 2
new Vector2(1920, 1080), // 3
new Vector2(1600, 900), // 4
new Vector2(1366, 768), // 5
new Vector2(1280, 720), // 6
new Vector2(1152, 648), // 7
new Vector2(1024, 576), // 8
};
public static int DefaultAspectRatioIndex = 5;
public ViewboxGridControl()
{
Loaded += (sender, e) =>
{
if (PlayerPreferences.Instance != null)
SetScale(PlayerPreferences.Instance.UserInterfaceSize);
else
SetScale(DefaultAspectRatioIndex);
};
}
public void SetScale(int index)
{
if (ScalingEnabled)
{
Width = AspectRatios[index].x;
Height = AspectRatios[index].y;
}
}
public Vector2 GetViewboxScale()
{
Viewbox viewbox = this.Parent as Viewbox;
if (viewbox == null)
return new Vector2(1, 1);
float x = viewbox.ActualWidth / ActualWidth;
float y = viewbox.ActualHeight / ActualHeight;
return new Vector2(x, y);
}
public bool ScalingEnabled
{
get { return (bool)GetValue(ScalingEnabledProperty); }
set { SetValue(ScalingEnabledProperty, value); }
}
}
}
ViewboxGridControl.xaml (401 bytes)
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
x:Class="ViewboxGridControl"
d:DesignWidth="1280" d:DesignHeight="720">
</UserControl> | ||||
| Platform | Any | ||||
|
Commenting out the dependency property and turning the property setter/getter to no-ops resolves the behavior. I'm investigating further... |
|
|
Things I tried to prevent crash that does not work Things I tried that does prevent the crash What is strange is that this worked fine for several days (2+ weeks?) and now it is happening every time I load/start Unity. My only workaround right now is to remove the DependencyProperty ScalingEnabledProperty. Works.cs (2,243 bytes)
using Noesis;
using System.Collections.Generic;
using UnityEngine;
using Grid = Noesis.Grid;
using Vector2 = UnityEngine.Vector2;
namespace StellarConquest.Presentation.Unity.UI
{
public partial class ViewboxGridControl : Grid
{
//public static readonly DependencyProperty ScalingEnabledProperty = DependencyProperty.Register("ScalingEnabled", typeof(bool), typeof(ViewboxGridControl), new PropertyMetadata(true));
public static readonly List<Vector2> AspectRatios = new List<Vector2>()
{
new Vector2(7680, 4320), // 0
new Vector2(3840, 2160), // 1
new Vector2(2560, 1440), // 2
new Vector2(1920, 1080), // 3
new Vector2(1600, 900), // 4
new Vector2(1366, 768), // 5
new Vector2(1280, 720), // 6
new Vector2(1152, 648), // 7
new Vector2(1024, 576), // 8
};
public static int DefaultAspectRatioIndex = 5;
public ViewboxGridControl()
{
Loaded += (sender, e) =>
{
if (PlayerPreferences.Instance != null)
SetScale(PlayerPreferences.Instance.UserInterfaceSize);
else
SetScale(DefaultAspectRatioIndex);
};
}
public void SetScale(int index)
{
if (ScalingEnabled)
{
Width = AspectRatios[index].x;
Height = AspectRatios[index].y;
}
}
public Vector2 GetViewboxScale()
{
Viewbox viewbox = this.Parent as Viewbox;
if (viewbox == null)
return new Vector2(1, 1);
float x = viewbox.ActualWidth / ActualWidth;
float y = viewbox.ActualHeight / ActualHeight;
return new Vector2(x, y);
}
public bool ScalingEnabled
{
get
{
//return (bool)GetValue(ScalingEnabledProperty);
return false;
}
set
{
//SetValue(ScalingEnabledProperty, value);
}
}
}
}
|
|
|
Maybe bool needs to be added as a valid property type? |
|
|
It seems a problem with the loading of Noesis library while starting Unity. Could you please try the following code for your ViewboxGridControl? using Noesis; If this fixes the problem then I need to understand why this class is used without Noesis being initialized. Are you using that class from code in a MonoBehavior? |
|
|
OK, perfect. Your analysis is spot on. The change worked, and helped me identify the cause. The class contains a static property, ViewBoxGridControl.DefaultAspectRatioIndex. MonoBehavior code referred to this variable which, when accessed, caused the static initializer for ViewBoxGridControl to be called, which includes initialization of the dependency property. I moved the constant to a better location and all is well. Candidate for closure -- thank you for helping me understand this. |
|
|
Thanks for the feedback stonstad. I wonder if we could detect this scenario sergio, like having asserts if Noesis API is trying to be used without initialization. Not sure how many entries and how many asserts would be needed. And we don't want this code to be present in the non-editor build. |
|
|
Yes, we should be more robust against this scenario. |
|
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2019-08-16 00:30 | stonstad | New Issue | |
| 2019-08-16 00:30 | stonstad | File Added: Crash_2019-08-15_222455133.zip | |
| 2019-08-16 00:30 | stonstad | File Added: ViewBoxGridControl.cs | |
| 2019-08-16 00:30 | stonstad | File Added: ViewboxGridControl.xaml | |
| 2019-08-16 00:33 | stonstad | Note Added: 0005923 | |
| 2019-08-16 00:45 | stonstad | File Added: Works.cs | |
| 2019-08-16 00:45 | stonstad | Note Added: 0005924 | |
| 2019-08-16 00:54 | stonstad | Note Edited: 0005924 | |
| 2019-08-16 00:59 | stonstad | Note Edited: 0005924 | |
| 2019-08-16 01:00 | stonstad | Note Added: 0005926 | |
| 2019-08-19 16:41 | sfernandez | Assigned To | => sfernandez |
| 2019-08-19 16:41 | sfernandez | Status | new => assigned |
| 2019-08-19 16:41 | sfernandez | Product Version | 2.2.4 => 2.2.3 |
| 2019-08-19 16:41 | sfernandez | Target Version | => 2.2.4 |
| 2019-08-19 16:41 | sfernandez | Description Updated | |
| 2019-08-21 14:33 | sfernandez | Status | assigned => feedback |
| 2019-08-21 14:33 | sfernandez | Note Added: 0005932 | |
| 2019-08-21 14:39 | sfernandez | Note Edited: 0005932 | |
| 2019-08-21 20:56 | stonstad | Note Added: 0005933 | |
| 2019-08-21 20:56 | stonstad | Status | feedback => assigned |
| 2019-08-22 01:25 | jsantos | Note Added: 0005934 | |
| 2019-08-23 01:13 | sfernandez | Target Version | 2.2.4 => 2.2.5 |
| 2019-08-23 01:13 | sfernandez | Note Added: 0005937 | |
| 2019-09-27 17:47 | sfernandez | Status | assigned => resolved |
| 2019-09-27 17:47 | sfernandez | Resolution | open => fixed |
| 2019-09-27 17:47 | sfernandez | Fixed in Version | => 2.2.5 |
| 2025-10-10 13:29 | jsantos | Category | Unity3D => Unity |