Nir Hasson
Topic Author
Posts: 71
Joined: 10 Nov 2013, 21:20
Contact:

Resource Management

29 Apr 2015, 09:39

On our product we use multiple xaml files and renderes for each active state in the application (I.E Splash, Main Menu, "Game" etc).

When a state starts it loads all data, creates the xaml and renderer and when it ends it release it by resseting the main xaml FrameworkElement and the renderer.

On first run of the "Game" state everything runs as expected.
On the second run of the "Game" state I'm getting the follwoing error:
"NsCore/DelegateGeneratorSeveralParams.h line 411 Delegate already exists"
This happens when I try to add handler method to one of my Storyboards in the scene.

It looks like that on exit some of the xaml resources remains alive.
How can I verify that the Frameworkelement and the renderer a completely destroyed?
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Resource Management

30 Apr 2015, 10:56

Hi,

First thing I would recommend is to use a unique Renderer with a master XAML (a root Grid or Decorator) where you set the XAML tree you want to load (splash, main menu, ...). This way you can load your resources (styles, brushes, ...) and they will be shared and only created once for that main renderer.

About the error I guess that you are not unsubscribing from the Storyboard.Completed event before exiting the state, and unfortunately a new element could be created with the same pointer. Please create a ticket in our bugtracker because we should detect when the subscribed element gets destroyed to remove it from the event.

Meanwhile you have several options (if I am correct you are working with 1.1 version).
- Try to unsubscribe the elements from the Storyboard.Completed event.
- Or if the storyboard is defined in a ResourceDictionary XAML file, as they are cached in the ResourceSystem, try to clear the cache when exiting the state:
#include <NsGui/UIPtr.h>
#include <NsResource/IResourceSystem.h>
#include <NsResource/BaseResourceManager.h>
...
NsGetSystem<IResourceSystem>()->GetManager(UI::Id)->ClearCache(); 
I hope this helps.
 
Nir Hasson
Topic Author
Posts: 71
Joined: 10 Nov 2013, 21:20
Contact:

Re: Resource Management

03 May 2015, 08:37

I'll consider your recommendation for future releases, but since I don't have common resources between states I prefer to load and unload resources by demand.

The actual change that cause this issue to appear was that I've separated my Styles, Resources and Storyboard from the main XAML to different XAML files, that's the point where your cache system might be involved in.
I've added unsubscribing calls for all Storyboards and that fixed the issue.

I'll open a ticket anyway for the scenario you've described.

On a related subject, is there any official doc that specifies the steps needed to be taken in order to move from 1.1 to 1.2+? I've noticed that the build tool is different and that there are no tbb dlls..
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Resource Management

06 May 2015, 16:40

Apart from performance improvements and the new BuildTool, the most important changes affect the C# API. If you take a look at the 1.2.0 changelog you will find what is new in the C++ API:
  • NoesisGUI.h, a header with all the API (under Noesis namespace). To be used as Precompiled Header.
  • We have reduced the exposed API. All integration functionality is under Noesis::GUI.
  • XCode library built with RTTI enabled.
  • Dependency properties of type NsString are now set and get using const char*.
  • ObservableCollection implemented in C++ (for symmetry with C#).
Then you should read the new tutorials available on the online documentation.

And as always, if you find trouble doing anything, you can ask here in the forums and we will be glad to answer ;)
 
Nir Hasson
Topic Author
Posts: 71
Joined: 10 Nov 2013, 21:20
Contact:

Re: Resource Management

07 May 2015, 17:03

Sounds good :)
We will integrate it and test in the next couple of weeks.
Thanks !

Who is online

Users browsing this forum: Ahrefs [Bot], Semrush [Bot] and 53 guests