FindResource no longer goes up the visual tree?
We just upgraded to 1.2.4 and now we're getting a huge breaking change. Whenever we call "FindResource" from a custom control, it no longer returns the resource defined at the root level that contains the custom control. We then tried to work around this by using VisualTreeHelper.GetParent to climb up the tree to find the root control from the custom control, but that doesn't work either. GetParent() will return null once it reaches the topmost element within the custom control.
This is causing a lot of problems with our theming, and our MultiStyle attached property (since we can't do BasedOn from different .xaml files). Is this the intended behaviour of the FindResource now? If so, how would I either get the root view's resources ?
This is causing a lot of problems with our theming, and our MultiStyle attached property (since we can't do BasedOn from different .xaml files). Is this the intended behaviour of the FindResource now? If so, how would I either get the root view's resources ?
Re: FindResource no longer goes up the visual tree?
We are able to find out more information regarding this. If we do the FindResource in a Loaded event, the resource is found. It probably has to do with the control not actually being in the tree yet when OnPostInit() is fired.
In our case, we have an attached property called MultiStyle that combines multiple styles into a single style. Because it's an AP, the dependency property's changed handler is firing before Loaded() is fired. So now our AP needs to add a Loaded event to the control using it... which kind of sucks. However, it works for now...
The problem now, however, is that I'm getting an exception when I stop the game.
Here's the exception:
Unhandled exception at 0x1EEDFA73: Access Violation reading location 0x00000008
[ 0] [0x1EEDFA73] Noesis.dll!SWIG_CSharpSetPendingExceptionArgument + 0x483 bytes
[ 1] [0x1EEDF91B] Noesis.dll!SWIG_CSharpSetPendingExceptionArgument + 0x32b bytes
[ 2] [0x1EF32993] Noesis.dll!Box_Bool + 0x83 bytes
[ 3] [0x0BE93DD0] mono.dll!mono_profiler_install_class + 0x1af bytes
[ 4] [0x1EE2F46E] Noesis.dll!MouseState_leftButton_get + 0x8884e bytes
[ 5] [0x0BE57B94] mono.dll!mono_domain_get + 0xc bytes
[ 6] [0x1EEE7610] Noesis.dll!SWIG_CSharpSetPendingExceptionArgument + 0x8020 bytes
In our case, we have an attached property called MultiStyle that combines multiple styles into a single style. Because it's an AP, the dependency property's changed handler is firing before Loaded() is fired. So now our AP needs to add a Loaded event to the control using it... which kind of sucks. However, it works for now...
The problem now, however, is that I'm getting an exception when I stop the game.
Here's the exception:
Unhandled exception at 0x1EEDFA73: Access Violation reading location 0x00000008
[ 0] [0x1EEDFA73] Noesis.dll!SWIG_CSharpSetPendingExceptionArgument + 0x483 bytes
[ 1] [0x1EEDF91B] Noesis.dll!SWIG_CSharpSetPendingExceptionArgument + 0x32b bytes
[ 2] [0x1EF32993] Noesis.dll!Box_Bool + 0x83 bytes
[ 3] [0x0BE93DD0] mono.dll!mono_profiler_install_class + 0x1af bytes
[ 4] [0x1EE2F46E] Noesis.dll!MouseState_leftButton_get + 0x8884e bytes
[ 5] [0x0BE57B94] mono.dll!mono_domain_get + 0xc bytes
[ 6] [0x1EEE7610] Noesis.dll!SWIG_CSharpSetPendingExceptionArgument + 0x8020 bytes
Re: FindResource no longer goes up the visual tree?
Found out more information. Managed to fix the cause of the crash, which was caused by one of our controls binding to an ObservableCollection<bool>(). Is this not allowed? Wrapping the boolean in a class and using that in the observable collection seems to be fine and the exception no longer occurs.
Lastly, we found a bug with Noesis.dll not being unloaded properly. It was weird that some of our views were getting unloaded fine, but for some reason, this does not. We've narrowed it down to our custom ScrollViewer that we built. We override the styling for the existing scroll viewer for our own, and whenever we show this custom scroll viewer, if we stop the unity game using the play button, it would not let go of Noesis.dll. We have a feeling it might be related to:
This is what the noesis.log shows:
It looks like it's not finding a resource, which doesn't exist because we've overridden the template.
Lastly, we found a bug with Noesis.dll not being unloaded properly. It was weird that some of our views were getting unloaded fine, but for some reason, this does not. We've narrowed it down to our custom ScrollViewer that we built. We override the styling for the existing scroll viewer for our own, and whenever we show this custom scroll viewer, if we stop the unity game using the play button, it would not let go of Noesis.dll. We have a feeling it might be related to:
from the changelogs.Fixed ScrollViewer scrollbars not hiding or showing when content changed its size.
This is what the noesis.log shows:
Code: Select all
00:15.9000PÛ General > Kernel::Shutdown
00:15.9000PÛ Kernel > Shutting down kernel systems
00:15.9000PÛ Kernel ! > System Shut Down [UISystem]
00:15.9038
PÛ NS_ERROR ' Resource 'TrackBgBrush' not found
00:15.9058PÛ General < _NT_SYMBOL_PATH not set. Stack traces may be incorrect
00:15.9171¼Â OuputDebugString ! Resource 'TrackBgBrush' not found
00:15.9171¼Â OuputDebugString 5 UnityEngine.Debug:Internal_Log(Int32, String, Object)
00:15.9171¼Â OuputDebugString " UnityEngine.Debug:LogError(Object)
00:15.9171¼Â OuputDebugString \ NoesisGUISystem:Shutdown() (at Assets\Plugins\NoesisGUI\Scripts\Core\NoesisGUISystem.cs:233)
00:15.9171¼Â OuputDebugString ' NoesisGUISystem:OnDisable() (at Assets\
00:15.9525¼Â OuputDebugString d Forcing unload of D:/Dev/iQmetrix/XQ.Shelf/UnityProject/Assets/Editor/NoesisGUI/BuildTool/Noesis.dll
00:15.9525¼Â OuputDebugString 5 UnityEngine.Debug:Internal_Log(Int32, String, Object)
00:15.9525¼Â OuputDebugString $ UnityEngine.Debug:LogWarning(Object)
00:15.9525¼Â OuputDebugString ? Noesis.Debug:LogWarning(String) (at Assets\Plugins\NoesisGUI\Sc
00:15.9560¼Â OuputDebugString z Unable to unload D:/Dev/iQmetrix/XQ.Shelf/UnityProject/Assets/Editor/NoesisGUI/BuildTool/Noesis.dll. Please, restart Unity
00:15.9560¼Â OuputDebugString 5 UnityEngine.Debug:Internal_Log(Int32, String, Object)
00:15.9560¼Â OuputDebugString $ UnityEngine.Debug:LogWarning(Object)
Re: FindResource no longer goes up the visual tree?
Confirmed that this is caused by the scroll viewer's scrollbar. If I don't use my scrollbar's custom style, it no longer holds onto the Noesis.dll.
Here's my style for the scrollbar.
Here's my style for the scrollbar.
Code: Select all
<Style x:Key="ScrollBarBaseStyle"
TargetType="{x:Type ScrollBar}">
<Setter Property="Foreground"
Value="{DynamicResource ComponentBrush_IconNavigation}" />
<Setter Property="Background"
Value="Transparent" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border x:Name="BorderRoot"
BorderThickness="1"
CornerRadius="10"
BorderBrush="{TemplateBinding Foreground}"
Background="{TemplateBinding Background}"
Height="{TemplateBinding Height}"
Width="{TemplateBinding Width}">
<Track x:Name="PART_Track"
Focusable="false"
IsDirectionReversed="true">
<Track.Thumb>
<Thumb x:Name="Thumb"
Background="{TemplateBinding Foreground}" />
</Track.Thumb>
</Track>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled"
Value="false">
<Setter TargetName="Thumb"
Property="Visibility"
Value="Collapsed" />
</Trigger>
<Trigger Property="ScrollBar.Orientation"
Value="Vertical">
<Setter TargetName="Thumb"
Property="Style"
Value="{StaticResource VerticalScrollThumbStyle}" />
</Trigger>
<Trigger Property="ScrollBar.Orientation"
Value="Horizontal">
<Setter TargetName="Thumb"
Property="Style"
Value="{StaticResource HorizontalScrollThumbStyle}" />
<Setter TargetName="PART_Track"
Property="IsDirectionReversed"
Value="false" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
-
sfernandez
Site Admin
- Posts: 3188
- Joined:
Re: FindResource no longer goes up the visual tree?
We are looking at all this issues right now. Will answer to every individual question when we have more information.
For the crashes it would help us a lot if you create a ticket in the bugtracker attaching the dump and logs, thanks.
Sorry for the inconveniences
For the crashes it would help us a lot if you create a ticket in the bugtracker attaching the dump and logs, thanks.
Sorry for the inconveniences
Re: FindResource no longer goes up the visual tree?
For now, we need a workaround for the TrackBgBrush issue because we can't release a feature without the Loading bug discussed in the forums before, and the workaround for that doesn't work. Now this bug is preventing us from finishing this feature as well. Perhaps posting the template that noesis uses internally will help us find a workaround.
-
sfernandez
Site Admin
- Posts: 3188
- Joined:
Re: FindResource no longer goes up the visual tree?
I created a ticket in our bugtracker to follow the ScrollBar issue:
http://www.noesisengine.com/bugs/view.php?id=708
http://www.noesisengine.com/bugs/view.php?id=708
-
sfernandez
Site Admin
- Posts: 3188
- Joined:
Re: FindResource no longer goes up the visual tree?
No, this is not the intended behavior. It was a bug and we fixed it, thanks for your feedback. So for next release you will be able to call FindResource in the Initialized (OnPostInit) event, and Logical tree should also be ready (Parent property should return the logical parent).We just upgraded to 1.2.4 and now we're getting a huge breaking change. Whenever we call "FindResource" from a custom control, it no longer returns the resource defined at the root level that contains the custom control. We then tried to work around this by using VisualTreeHelper.GetParent to climb up the tree to find the root control from the custom control, but that doesn't work either. GetParent() will return null once it reaches the topmost element within the custom control.
This is causing a lot of problems with our theming, and our MultiStyle attached property (since we can't do BasedOn from different .xaml files). Is this the intended behaviour of the FindResource now? If so, how would I either get the root view's resources ?
Thanks to your collaboration we found the source of this problem. It turns out that one of your custom ItemsControl, with the Style set as a DynamicResource, was alive after NoesisGUI was shut down (because of a circular reference).The problem now, however, is that I'm getting an exception when I stop the game.
Here's the exception:
Unhandled exception at 0x1EEDFA73: Access Violation reading location 0x00000008
[ 0] [0x1EEDFA73] Noesis.dll!SWIG_CSharpSetPendingExceptionArgument + 0x483 bytes
[ 1] [0x1EEDF91B] Noesis.dll!SWIG_CSharpSetPendingExceptionArgument + 0x32b bytes
[ 2] [0x1EF32993] Noesis.dll!Box_Bool + 0x83 bytes
[ 3] [0x0BE93DD0] mono.dll!mono_profiler_install_class + 0x1af bytes
[ 4] [0x1EE2F46E] Noesis.dll!MouseState_leftButton_get + 0x8884e bytes
[ 5] [0x0BE57B94] mono.dll!mono_domain_get + 0xc bytes
[ 6] [0x1EEE7610] Noesis.dll!SWIG_CSharpSetPendingExceptionArgument + 0x8020 bytes
Found out more information. Managed to fix the cause of the crash, which was caused by one of our controls binding to an ObservableCollection<bool>(). Is this not allowed? Wrapping the boolean in a class and using that in the observable collection seems to be fine and the exception no longer occurs.
In that scenario we were trying to access some internal structs that were already destroyed during shut down. We fixed this issue for the next release too
This problem was related with the previous scenario too: a control that lives after NoesisGUI shut down. We fixed the problem that prevents Noesis.dll be unloaded or made Unity Editor crash, when a NoesisGUI error occurred during shut down.Lastly, we found a bug with Noesis.dll not being unloaded properly. It was weird that some of our views were getting unloaded fine, but for some reason, this does not. We've narrowed it down to our custom ScrollViewer that we built. We override the styling for the existing scroll viewer for our own, and whenever we show this custom scroll viewer, if we stop the unity game using the play button, it would not let go of Noesis.dll.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 6 guests