asusralis
Topic Author
Posts: 142
Joined: 30 Jul 2018, 05:03

XAML freezes Unity on Begin MonoManager ReloadAssembly

08 Jan 2019, 21:23

After dealing with random freezing in Unity for a week, we think we've pinned it down to an XAML change.
<ItemsControl Grid.Row="2" Grid.RowSpan="2" ItemsSource="{Binding Character.Specialty.Skills}">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Image Source="{Binding Icon}" Margin="5"/>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
Code:
[JsonIgnore]
        public Noesis.TextureSource Icon
        {
            get
            {
                return new Noesis.TextureSource(Resources.Load<Texture2D>("Icons/Icon.1_01"));
            }
        }
        
The icon shows, but after the instance of the game in the editor is closed and then opened again, it freezes before it can start. The last lines in the editor logs reads:
Reloading assemblies for play mode.
Begin MonoManager ReloadAssembly

The engine will also not compile after the game has played once. It will also get stuck on Begin MonoManager ReloadAssembly. Calling the Icon property anywhere else will not freeze the editor - only after the binding is binded to the Icon property. The freeze will also not happen if the texture itself is null.

Are we using TextureSource wrong? We're on Unity 2018.3.02f, but this also was happening on 2018.2.20.
 
User avatar
sfernandez
Site Admin
Posts: 2991
Joined: 22 Dec 2011, 19:20

Re: XAML freezes Unity on Begin MonoManager ReloadAssembly

09 Jan 2019, 12:38

Are you able to reproduce this with a small sample on an empty project? If you could do that and attach it to a ticket in our bugtracker it will help us track the problem, thanks.

In the meantime, could you please try the following: instead of creating a TextureSource each time the Icon getter is called, return a member of the view model.
private Noesis.TextureSource _icon;
public Noesis.TextureSource Icon
{
  get
  {
    if (_icon == null)
    {
      _icon = new Noesis.TextureSource(Resources.Load<Texture2D>("Icons/Icon.1_01"));
    }
    return _icon;
  }
}
Does this solve the problem?
 
asusralis
Topic Author
Posts: 142
Joined: 30 Jul 2018, 05:03

Re: XAML freezes Unity on Begin MonoManager ReloadAssembly

09 Jan 2019, 16:00

I think it did solve the problem, yes. How do you figure why that fixed it?

Edit: Nevermind. After I restarted Unity and reopened it, it started to freeze like how it was before.

I tried to replicate it in another project, but I cannot. The weird part is that the bug doesn't instantly happen. We have to go through the game and load other views before the bug happens.

Edit 2: Another developer had it freeze after simply seeing the view in question. It doesn't seem to freeze if the TextureSource returns null. Only when an actual TextureSource is created with a Texture2D does it freeze. Also, putting the texture source in a field makes it not freeze for the most part. I've just had it freeze once since I've done that.
 
User avatar
jsantos
Site Admin
Posts: 3918
Joined: 20 Jan 2012, 17:18
Contact:

Re: XAML freezes Unity on Begin MonoManager ReloadAssembly

10 Jan 2019, 11:44

Could you please file a report about this? Let's move the discussion there. We are actively working these days in the new Unity package and this must be solved. Thanks!
 
 
User avatar
jsantos
Site Admin
Posts: 3918
Joined: 20 Jan 2012, 17:18
Contact:

Re: XAML freezes Unity on Begin MonoManager ReloadAssembly

15 Jan 2019, 17:02

Thanks!

Who is online

Users browsing this forum: Bing [Bot] and 56 guests