jijgyarto
Topic Author
Posts: 2
Joined: 12 Mar 2025, 17:48

Long stall when loading XAML

21 May 2026, 14:36

We're running into a problem while loading some of our custom UserControl classes. Each of our menu pages is a subclass of Noesis::UserControl, usually Noesis::Page. When the user wants to open a menu, we load it from the source XAML and add it to a parent element to be displayed. When the user closes the menu, we remove it from the parent element and destroy the object.

Loading and parsing the XAML, then loading the Components causes a very long stall, sometimes multiple seconds, before the UI is fully loaded and the game is able to continue.

I wrote a snippet below to illustrate the process we use:
Noesis::Canvas* canvas; // This is what we use as the parent element for our menus

Noesis::Uri uri = /* Retrieve our URI from our lookup table */;
MyCustomUserControl* control = Noesis::GUI::LoadXaml<MyCustomUserControl>(uri);
control->LoadComponent(uri);

canvas->GetChildren()->Add((Noesis::UIElement *)control);
We did some profiling and the following stood out:
  • Noesis::ViewLayout::ProcessLayout takes up a lot of time when we do this. It seems to be doing a lot of measuring (possibly having to recalculate the positions of all the UI elements?)
  • canvas->GetChildren()->Add(...) in the above example also takes a lot of time, it seems to kick off a lot of initialization logic in all the sub-objects
It's very likely that we're doing something in a sub-optimal way. At the moment we are really strict and destroy UI elements that we could probably keep around and just add/remove from the Canvas. However, the bigger issue is that there doesn't seem to be any way to asynchronously perform either the XAML load and parse, or adding/removing UI elements to/from a parent. Both of these are blocking operations, and I can't tell whether Noesis allows them to be called from other threads, or if there's a way to "pre-load" any of these steps. Our only idea was to try and "stagger" the process across multiple frames, but that would make the code a lot more complex.

Is there anything you can recommend? Thanks in advance!
 
User avatar
jsantos
Site Admin
Posts: 4822
Joined: 20 Jan 2012, 17:18
Contact:

Re: Long stall when loading XAML

22 May 2026, 19:17

I’m pretty sure the parsing is not causing the stall.

Do these UserControls contain merged dictionaries? We recommend moving as many templates, styles, and resources as possible to the global dictionary.

Could that be the cause of the problem?
 
jijgyarto
Topic Author
Posts: 2
Joined: 12 Mar 2025, 17:48

Re: Long stall when loading XAML

25 May 2026, 16:13

I’m pretty sure the parsing is not causing the stall.

Do these UserControls contain merged dictionaries? We recommend moving as many templates, styles, and resources as possible to the global dictionary.

Could that be the cause of the problem?
May have been a false alarm, was due to a setup on our end. Seems to work OK in our release builds.
 
User avatar
jsantos
Site Admin
Posts: 4822
Joined: 20 Jan 2012, 17:18
Contact:

Re: Long stall when loading XAML

26 May 2026, 12:05

Thanks for the feedback! Please keep us posted.

Who is online

Users browsing this forum: No registered users and 6 guests