View Issue Details

IDProjectCategoryView StatusLast Update
0001538NoesisGUIUnity3Dpublic2019-08-23 01:13
ReporterstonstadAssigned Tosfernandez 
PrioritynormalSeveritycrashReproducibilityalways
Status assignedResolutionopen 
Product Version2.2.3 
Target Version2.2.5Fixed in Version 
Summary0001538: Unity Crash on Project Load
DescriptionI'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'
Noesis.PropertyMetadata:.ctor(Object) (at Assets\NoesisGUI\Plugins\API\Proxies\PropertyMetadataExtend.cs:33)
StellarConquest.Presentation.Unity.UI.ViewboxGridControl:.cctor() (at Assets\User Interface\Controls\Viewbox Grid Control\ViewBoxGridControl.cs:10)

[C:\buildslave\unity\build\Runtime/GfxDevice/GfxDevice.cpp line 148]
(Filename: Assets/NoesisGUI/Plugins/API/Proxies/PropertyMetadataExtend.cs Line: 33)


The offending line of code is this:
   public static readonly DependencyProperty ScalingEnabledProperty = DependencyProperty.Register("ScalingEnabled", typeof(bool), typeof(ViewboxGridControl), new PropertyMetadata(true));

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.

TagsNo tags attached.
PlatformAny

Activities

stonstad

stonstad

2019-08-16 00:30

reporter  

Crash_2019-08-15_222455133.zip (138,372 bytes)
ViewBoxGridControl.cs (2,102 bytes)
ViewboxGridControl.xaml (401 bytes)
stonstad

stonstad

2019-08-16 00:33

reporter   ~0005923

Commenting out the dependency property and turning the property setter/getter to no-ops resolves the behavior. I'm investigating further...
stonstad

stonstad

2019-08-16 00:45

reporter   ~0005924

Last edited: 2019-08-16 00:59

View 3 revisions

Things I tried to prevent crash that does *not* work
1) comment out all code in constructor, including loaded event.
2) make get/set no-op.
3) rename to ScalingEnabledProperty to ScalingEnabled2Property.
4) use different constructor for dependency property to avoid using PropertyMetadata(true) parameter. Result: crash occurs in DependencyPropertyExtend, Line 13 instead.

Things I tried that *does* prevent the crash
1) comment out the dependency property, ScalingEnabledProperty. See works.cs for what code looks like that does work every time.

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)
stonstad

stonstad

2019-08-16 01:00

reporter   ~0005926

Maybe bool needs to be added as a valid property type?
sfernandez

sfernandez

2019-08-21 14:33

manager   ~0005932

Last edited: 2019-08-21 14:39

View 2 revisions

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;
using System.Collections.Generic;
using Vector2 = UnityEngine.Vector2;
using Grid = Noesis.Grid;

namespace StellarConquest.Presentation.Unity.UI
{
    public partial class ViewboxGridControl : Grid
    {
        static ViewboxGridControl()
        {
            Noesis.GUI.Init();

            ScalingEnabledProperty = DependencyProperty.Register("ScalingEnabled", typeof(bool), typeof(ViewboxGridControl), new PropertyMetadata(true));
        }

        public static readonly DependencyProperty ScalingEnabledProperty = null; // DependencyProperty.Register("ScalingEnabled", typeof(bool), typeof(ViewboxGridControl), new PropertyMetadata(true));
        ...
    }
}

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?

stonstad

stonstad

2019-08-21 20:56

reporter   ~0005933

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.
jsantos

jsantos

2019-08-22 01:25

manager   ~0005934

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.
sfernandez

sfernandez

2019-08-23 01:13

manager   ~0005937

Yes, we should be more robust against this scenario.
I'll move this ticket for the next release so we can think about how to solve it.

Issue History

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 View Revisions
2019-08-16 00:59 stonstad Note Edited: 0005924 View Revisions
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 View Revisions
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 View Revisions
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