monstercho
Topic Author
Posts: 20
Joined: 26 Jan 2016, 19:54

Noesis 2 theme crash

02 Mar 2017, 22:10

Hi, something I noticed while adapting to Noesis 2.0 - the order of tags in the theme ResourceDictionary matter (doesn't in Noesis 1.2x).

So If you select in NoesisSettings default theme like this one (theme_crash.xaml):
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:sys="clr-namespace:System;assembly=mscorlib">
    <SolidColorBrush x:Key="PhoneTextBoxEditBorderBrush" Color="{StaticResource PhoneAccentColor}" />
    <Color x:Key="PhoneAccentColor">#FFE51400</Color>
</ResourceDictionary>

and try to import xaml that uses it by dragging it into some folder in Unity editor (test_theme.xaml):
<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">
    <Grid Background="PhoneAccentColor}"/>
</UserControl>
Unity editor will hang and crash if you try to interact with it (only the menu reacts).
If you restart Unity it will crash again each time you try.

No problem with theme like this (theme_ok.xaml):
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:sys="clr-namespace:System;assembly=mscorlib">
    <Color x:Key="PhoneAccentColor">#FFE51400</Color>
    <SolidColorBrush x:Key="PhoneTextBoxEditBorderBrush" Color="{StaticResource PhoneAccentColor}" />
</ResourceDictionary>
Only difference is tag order - color is defined before the brush that uses it.

It is easy to avoid issue, but took me some time to realize why all the crashes.
 
User avatar
sfernandez
Site Admin
Posts: 1911
Joined: 22 Dec 2011, 19:20

Re: Noesis 2 theme crash

03 Mar 2017, 06:02

Hi,

We were able to reproduce and fix the bug.
It will be solved in the next release.

Sorry for the inconvenience.
 
User avatar
sfernandez
Site Admin
Posts: 1911
Joined: 22 Dec 2011, 19:20

Re: Noesis 2 theme crash

03 Mar 2017, 06:24

Just a clarification, the declaration order of resources is important.
A StaticResource can only be resolved if it refers to a previously defined resource.
This is the same behavior you would find in WPF.
 
User avatar
jsantos
Site Admin
Posts: 2903
Joined: 20 Jan 2012, 17:18
Contact:

Re: Noesis 2 theme crash

03 Mar 2017, 06:35

Extra clarification: This was incorrectly working in 1.X because our implementation of static resources was not very efficient (they were very similar to dynamic resources)
 
monstercho
Topic Author
Posts: 20
Joined: 26 Jan 2016, 19:54

Re: Noesis 2 theme crash

03 Mar 2017, 06:46

Thanks

Who is online

Users browsing this forum: No registered users and 0 guests