View Issue Details

IDProjectCategoryView StatusLast Update
0002210NoesisGUIC++ SDKpublic2021-12-20 21:27
Reporterasusralis Assigned Tosfernandez  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.1.1 
Target Version3.1.2Fixed in Version3.1.2 
Summary0002210: Hot reloading a control, losing focus of Unity, and going back into Unity reimports files again and breaks the UI
DescriptionHot reloading works, but once I tab out and back into Unity, importing will happen again. This will always make my UI disappear, making hot reloading unusable for some controls. This does not happen with all controls.
Steps To Reproducehttps://files.catbox.moe/45oh9s.mp4

Once I do the hot reload I then tab out and back into unity, triggering another import.
TagsNo tags attached.
PlatformAny

Activities

asusralis

asusralis

2021-12-15 04:49

reporter   ~0007674

Is there any info on this? It actually gets really bad in larger projects. Changing a single value in an XAML forces the import for 10 - 15 files, and then losing and gaining focus of Unity does this again. This exactly project had none of these issues in 2.x.

https://files.catbox.moe/378irf.mp4
sfernandez

sfernandez

2021-12-16 12:05

manager   ~0007680

Hi, we are currently studying this problem as we still have access to your project.

The first thing I noticed is that you have a folder named Unused with lots of xamls that are giving errors, and from the name of the folder it seems to me those are old files, couldn't you take them outside Assets to avoid getting undesired error messages?

Regarding the modification of CustomViews.xaml that triggers the import of the rest of xamls, that is happening because that xaml is a dependency of your ApplicationResources (Resources.xaml), and whenever that xaml gets reimported, all xamls need to be reimported as it is a dependency of all of them. The imports occurring after you regain focus on Unity is because Unity processes the import of dependencies in background processes when it determines it is appropriate.

Anyway, we'll investigate the hot-reloading of xamls after the reimport because we should be able to restore the state of the game without breaking things.
sfernandez

sfernandez

2021-12-17 14:18

manager   ~0007681

We fixed a problem with hot-reloading initializing elements before setting its properties.

Apart from that your game logic is adding elements in code that get destroyed when xaml is reloaded.
For example, your MainGameBehavior is adding the MainMenu to the View on Start. You can hook to the Reloaded event there to add the menu again:
            if (MainView?.Content != null)
            {
                MainView.Content.Reloaded += (s, e) =>
                {
                    FrameManager.Get("Main").Push("MainMenu", new NavParams(hasAnimation: false, canBack: false));
                };
            }


And those dynamic elements added to the NavFrame, when that control gets reloaded will also be removed them from the "ContentRoot" grid because it gets filled with the "Overlay" button defined in the xaml. Wouldn't be better in that control to add the dynamic elements to a sibling of the "Overlay" button, something like this:
        <Grid>
            <Button
                x:Name="Overlay"
                Click="Overlay_Click"
                Visibility="Collapsed">
                <Button.Style>
                    <Style BasedOn="{StaticResource {x:Type Button}}" TargetType="Button">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="Button">
                                    <Grid Background="{TemplateBinding Background}" />
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Button.Style>
                <Button.Background>
                    <SolidColorBrush Opacity=".4" Color="Black" />
                </Button.Background>
            </Button>
            <Grid x:Name="ContentRoot"/>
        </Grid>

This way you don't even need to change the ZIndex of the Overlay button because the dynamic elements will always be added on top.
jsantos

jsantos

2021-12-17 15:17

manager   ~0007682

One of the things we have new in 3.X is that when the Application resources is modified (or any of its dependencies) *ALL* xamls are reimported (to get errors and thumbnails).

I don't know if we should consider having a way to disable this...
asusralis

asusralis

2021-12-17 15:20

reporter   ~0007683

Sorry, I wasn't sure how to reply without reopening this ticket.

Thanks for the help! I didn't know about Reloaded, I will try to implement this for NavFrame to automatically recreate the page stack.

About the overlay, it is possible for some pages to behind the overlay. For example, if there are three pages and the top page has an overlay, the overlay would have to be between the second and third page. This is why I found it easier to set the ZIndex in the code behind. If this doesn't relate to what you were suggesting, can you explain how your example would be different? Thanks again!
jsantos

jsantos

2021-12-17 15:46

manager   ~0007684

We are measuring times again, probably reloading all XAMLs when the global dictionary changes was not a good idea...
jsantos

jsantos

2021-12-20 21:27

manager   ~0007690

Reloading of Xamls, including dependencies from Application resources should be now much faster.

Thanks for your feedback. Please, let us know about all issues you find with hot-reloading.

Issue History

Date Modified Username Field Change
2021-12-06 14:39 asusralis New Issue
2021-12-06 14:41 jsantos Assigned To => sfernandez
2021-12-06 14:41 jsantos Status new => assigned
2021-12-06 14:41 jsantos Target Version => 3.1.2
2021-12-08 20:28 jsantos Summary Hot reloading a control, losing focus of Unity, and going back into Unity reimports files again and breaks the UI. => Hot reloading a control, losing focus of Unity, and going back into Unity reimports files again and breaks the UI
2021-12-15 04:49 asusralis Note Added: 0007674
2021-12-16 12:05 sfernandez Status assigned => feedback
2021-12-16 12:05 sfernandez Note Added: 0007680
2021-12-17 14:18 sfernandez Status feedback => resolved
2021-12-17 14:18 sfernandez Resolution open => fixed
2021-12-17 14:18 sfernandez Fixed in Version => 3.1.2
2021-12-17 14:18 sfernandez Note Added: 0007681
2021-12-17 15:14 jsantos Status resolved => assigned
2021-12-17 15:17 jsantos Note Added: 0007682
2021-12-17 15:17 jsantos Status assigned => feedback
2021-12-17 15:20 asusralis Note Added: 0007683
2021-12-17 15:20 asusralis Status feedback => assigned
2021-12-17 15:46 jsantos Note Added: 0007684
2021-12-20 21:27 jsantos Status assigned => resolved
2021-12-20 21:27 jsantos Note Added: 0007690