wckdspn
Topic Author
Posts: 67
Joined: 18 Aug 2012, 23:14

Math types classes instead of structs

05 Feb 2014, 20:48

I noticed a while ago, though was less concerned (I could work around it fairly easily), that types such as Point, Rect, and Color, which are structs in WPF/SL/RT are classes in Noesis's C# bindings. This can inadvertently create garbage, which I generally try to avoid (since the GC in Unity's mono RT is so absolutely terrible). It's pretty easy to see the Spaceboy sample, while dragging the window around.

To this point, I've just worked around it (as I am used to doing with Unity), but as I am currently advocating possibly utilizing Noesis for a project at work, I've determined that it is likely to become an issue. Many of the engineers have never used a flavor XAML, and would likely look to existing sources to learn from. If doing simple things like manipulating colors and points generates garbage, it's going to become ugly, very quick (for me especially, as I'm usually the one cleaning that up).

I realise a lot of it has to do with SWIG (which I have a separate rant on... not in your use, but SWIG in general), but there doesn't appear to be any reason for those types to be classes. Rather than binding them directly to native with pointers, there really is no issue I can see in just making a struct copy (the ability to modify them by reference is a functional change from WPF anyway).

So far, Noesis seems to be good about avoiding unexpected C# heap allocations (mostly due to it being native), which is a big deal to me. Unity itself is pretty bad about it (notice that accessing the GameObject transform property allocates memory in the rotate calls in Spaceboy), but that doesn't mean we need to sink to its level :P.
 
User avatar
jsantos
Site Admin
Posts: 2903
Joined: 20 Jan 2012, 17:18
Contact:

Re: Math types classes instead of structs

06 Feb 2014, 10:25

We are fully aware of this problem. It will be solved in 1.2.x. It is one of the improvements we want to do to the c# api.
I realise a lot of it has to do with SWIG (which I have a separate rant on... not in your use, but SWIG in general),
I would be glad to hear your opinion about SWIG. We have been very tempted to stop using it, problem is that we don't have yet resources to do it.

Thanks for your comments!

Who is online

Users browsing this forum: No registered users and 0 guests