News for hackers. Stuff that matters.
Re:Mono for Unreal Engine by thehardsphere on Friday August 04, 2017 @02:26PM (#14930760)
I would certainly hope not. C# implementations are terrible for lots of games on not-Windows. The version of Mono that has been included with Unity is particularly bad with respect to stop-the-world garbage collection pauses.
Re:Mono for Unreal Engine by hacker_9 on Friday August 04, 2017 @04:21PM (#14931894)
Pros:

1. The GC provides a huge time-saving net over a ton of possible memory errors. Not to mention the code is so much easier to read when you aren't having to deal with memory on every line.

2. The debugging experience is brilliant - because there is always metadata available, you can literally inspect everything.

3. Compilation time is super fast.

4. Code samples are available for pretty much everything. And when there aren't, you can always interop into C++ or whatever else.

Cons:

People unfamiliar with the language forget about the GC and let it do all their dirty work. They then get angry when it bites back because of all the allocations they are doing each frame. The answer is to use pooling, and structure your code in a way that works with the GC (not against it), and all these problems go away.

Re:Mono for Unreal Engine by kuschku on Friday August 04, 2017 @04:58PM (#14932190)
But that's not the issue - any other GC'd language has a much faster and better GC than this ancient mono version. That was the issue mentioned.
Re:Mono for Unreal Engine by socialist_coder on Friday August 04, 2017 @05:07PM (#14932270)
Yes, and that complaint is specific to Unity's current GC. They will update it eventually, and it will no longer suck.

Does the GC in Unreal-mono have the same problems? If not, it's a non-issue.

Re:Mono for Unreal Engine by tracker1 on Friday August 04, 2017 @06:18PM (#14932833)
It should be significantly better, but can still pause. Beyond this, it really depends on how you are allocating/using/reusing objects... There are techniques you can use that aren't too painful to overcome some of the issues.
Re:Mono for Unreal Engine by kevingadd on Friday August 04, 2017 @06:16PM (#14932818)
Unity has a specific situation with Mono that doesn't apply to anything else. It won't apply here, something like this can use the latest Mono.
Re:Mono for Unreal Engine by hacker_9 on Friday August 04, 2017 @05:10PM (#14932299)
The concurrent GC in the latest .Net still requires pausing (though the time is less), because the heap still requires compacting, and no code can run while that operation happens.

Invoking the GC constantly on a frame by frame basis can quickly lead to heap fragmentation, resulting in pausing, because that is considered 'working against' the GC (both stop the world and concurrent). This is where custom solutions, such as pooling, should be used to mitigate these issues.

Re:Mono for Unreal Engine by xenadu02 on Friday August 04, 2017 @04:00PM (#14931683)
Like every other language used for game development: you don't allocate objects in the render loop. All objects are re-used and go into pools. Malloc isn't free (heh): maintaining the free lists can kill FPS just as quickly as anything else.

As others have pointed out: the CLR has had a concurrent low-latency GC for a long time now and now that it's all open-source there is nothing preventing Unity from adopting it.

Re:Mono for Unreal Engine by penetrarthur on Saturday August 05, 2017 @06:39AM (#14935108)
Yeah, I am also surprised by the fact that people are constantly nagging about GC. In real gamedev on Unity, memory management is very serious and everything gets pooled. If GC is a problem, you rewrite the code so that it isn't.
Re:Mono for Unreal Engine by joveian on Friday August 04, 2017 @09:55PM (#14933835)
I hope so, although I particularly hope that more game designers build games such that the windows distribution can be directly run by mono on not-windows. That is the way the game is most likely to stay working for an long time and under multiple operating systems. I'm no fan of Microsoft, but compatibility over time is one thing they do better than anyone else and games are the one kind of application where that is particularly important. Plus Mono is excellent. There are other ways game designers could try to make their applications more likely to work for a long time, but in practice they don't do that.

I haven't noticed garbage collector related issues with mono, although I don't play the type of games where that would be most noticible. I have seen a number of games with memory leaks that require a restart after a while, but that is the case under windows as well. I've recently stopped buying Daedalic games because they can't manage to make a simple adventure game with almost no movement work on a system with 4GB memory, but they are by no means the only ones with this problem.

C# on top of C++ might not help that much other than encouraging more game designers to use C#.

Re:Mono for Unreal Engine by girvo on Monday August 07, 2017 @05:48PM (#14951548)
Maybe I'm getting old, but you saying Microsoft is brilliant at compatibility made me smile ruefully
Re:Mono for Unreal Engine by mwkaufma on Friday August 04, 2017 @02:38PM (#14930868)
Unity 5.x only uses Mono for the editor. On non-Windows platforms they use their own AoT .Net implementation, IL2CPP.
Re:Mono for Unreal Engine by migueldeicaza on Friday August 04, 2017 @04:23PM (#14931907)
The code generator is indeed different, the runtime is still Mono.

Mono today has two code generators: Mono's built it one, and an LLVM one. Both generate code after Mono loads and processes the assembly.

Unity developed a different front end to the runtime that does the compilation from IL to C++, the result still requires the Mono runtime to provide services at execution time.

They are currently upgrading their Runtime and are making a version with all the greatest features available coming.

Re:Mono for Unreal Engine by mwkaufma on Friday August 04, 2017 @04:47PM (#14932104)
Oh wow! Hey Miguel! Thanks for the info. Parenthetically: you're a pretty hep cat. Thanks for all your hard work on these projects :)
Re:Mono for Unreal Engine by nialo on Friday August 04, 2017 @02:30PM (#14930795)
Do you know if this is still true with the newer "concurrent" garbage collector in more recent Mono versions? I work on an audio player app rather than games, but also have problems with the GC in Mono on IOS. We're hopeful that eventually they'll go away, but haven't tried again recently.
Re:Mono for Unreal Engine by thehardsphere on Friday August 04, 2017 @02:37PM (#14930867)
I am not certain. Theoretically, it should be better, because I think they implemented a GC algorithm similar to the one on Windows. But I have never actually run it.

It's hard to emphasize how bad the Unity Mono GC is. It's a Mark-and-Sweep garbage collector, which is like the simplest-yet-least performant approach to GC there is. Nearly every other GC in production use in other stacks is better.

Re:Mono for Unreal Engine by danbolt on Friday August 04, 2017 @03:39PM (#14931433)
I'm willing to bet that Mono GC has improved a lot, but I don't think that Unity frequently updates the runtime. It's kind of painful, from what I've been told.
Re:Mono for Unreal Engine by migueldeicaza on Friday August 04, 2017 @04:26PM (#14931929)
We are collaborating with Unity to assist on upgrading not only their runtime but also to adopt the latest and greatest GC.

Additionally in C# 7, 7.1 and the upcoming 7.x series there are many improvements that reduce object allocation (like ref structs, value type tasks and others)

Re:Mono for Unreal Engine by atomicrat2552 on Friday August 04, 2017 @04:24PM (#14931915)
Unity is just now updating the runtime for the first time in seven years. I think only the 2017.x releases have the new Mono, and most platforms use their IL2CPP AoT compiler I believe
Re:Mono for Unreal Engine by littlehood on Friday August 04, 2017 @03:53PM (#14931589)
It is an experimental option for Xamarin. Though haven't played with it.
Re:Mono for Unreal Engine by oblio on Friday August 04, 2017 @03:41PM (#14931454)
Shouldn't this stop being an issue under Microsoft's patronage? .NET definitely doesn't have a stop-the-world garbage collector and this should trickle to Mono, if it hasn't already.
Re:Mono for Unreal Engine by thehardsphere on Friday August 04, 2017 @03:48PM (#14931541)
I believe it has stopped, or it had stopped a little bit before the acquisition. Other commentors indicated it has not trickled to Unity yet.

I am not up to date on the state of this in the latest Unity releases, I just know games I play on PS4 and OSX made with Unity stutter in places where they don't stutter on Windows.

Re:Mono for Unreal Engine by carussell on Friday August 04, 2017 @04:02PM (#14931697)
Here's Miguel's blog post from a couple years ago (before the Microsoft acquisition) when their cooperative mode GC first landed:

http://tirania.org/blog/archive/2015/Dec-22.html

Re:Mono for Unreal Engine by migueldeicaza on Friday August 04, 2017 @04:24PM (#14931911)
That effort continues, we have an update in Mono's blog and we are about to share details on our next concurrent/parallel milestone soon.
Re:Mono for Unreal Engine by tinco on Friday August 04, 2017 @02:35PM (#14930848)
The version of Mono that is shipped with Unity is bad specifically for licensing reasons, there is no technical cause.
Re:Mono for Unreal Engine by thehardsphere on Friday August 04, 2017 @02:41PM (#14930897)
What's wrong with the licensing? Not disagreeing with you; this is just the first I've heard of it.
Re:Mono for Unreal Engine by carussell on Friday August 04, 2017 @03:15PM (#14931198)
The popular telling of the story is that the team behind Mono asked for too much money to allow the Unity3D team to have a commercial license exception to newer versions of Mono.

(This comes from the Unity team's explanation to the Unity community about why their runtime remains out of date. It's since become a meme to paint the Mono folks as a bunch of jerks over this. This endured for a few years. In the meantime, however, Microsoft has released .NET under permissive terms that would allow Unity to use Microsoft's own runtime royalty-free—no need for a commercial license exception. Despite the opportunity it presented, an upgraded runtime failed to materialize from Unity. Maybe the transition from Mono to .NET Core was too big of a leap? Fair point. Thing is, Mono itself is now also relicensed under MIT, by way of Microsoft's acquisition of Xamarin, so Unity is free to make commercial use of newer Mono versions on proprietary platforms, just like Unity always wanted. Still, no upgrade to the Unity runtime.)

Re:Mono for Unreal Engine by ljmeijer on Friday August 04, 2017 @04:18PM (#14931868)
Ola, Lucas from Unity here,

Xamarin and Unity never did a renewed licensing deal. That doesn't make the lovely xamarin people nor us jerks :)

Licensing issues aside, for an ecosystem like Unity to upgrade its runtime, c# language, and base class libraries is an enormous undertaking. While we are not perfect, we take backward compatibility very seriously. All of mono and coreclr has been available under MIT licensing for a very long time now. In Unity2017.1 we now ship an experimental option to use modern .net. this uses a new mono (not using sgen), new c# compiler (still mcs for now, so c#6, not c#7, and .net4.6 class libraries).

In a future unity version (won't burn my fingers on exactly which one) this new .net experience will become default. (depends on how many problems you find! :)

the xamarin (and microsoft .net) team are wonderful folks, and it's great to work closely with them to make .net in unity, and .net in general solid.

next up on the list is improving the garbage collection story, which is in the works, but we're first focussing on shipping a new runtime+c#+.net base class libraries.

While there are some very valid areas to point out that make c# challenging to be "the language of an entire game", we believe that c# is a great controlling language for Unity. We're working on some really interesting (imho) compilation pipeline for a restricted compute subset of c# that I think will completely turn around people's expectations and opinions of c# in gaming. stay tuned, this is one of the most interesting projects happnening inside of Unity today.

Re:Mono for Unreal Engine by migueldeicaza on Friday August 04, 2017 @04:28PM (#14931955)
Just want to say, working with Unity and their team is a delight.

And they have given great feedback on the future of the language and framework that Microsoft is going to fully embrace to make Unity users happy.

Hugs and love Lucas!

Re:Mono for Unreal Engine by socialist_coder on Friday August 04, 2017 @05:11PM (#14932308)
That is awesome! Can't wait to see this stuff get released.
Re:Mono for Unreal Engine by BigChiefSmokem on Friday August 04, 2017 @04:46PM (#14932099)
Keep up the great work!
Re:Mono for Unreal Engine by tezza on Friday August 04, 2017 @03:52PM (#14931579)
Unity v2017.1 released for general access a few days ago has the possibility of .Net 4.6.

it is marked as experimental for now, but their release notes say it will become the new default soon

I am evaluating 4.6 support now and it works okay so far for my VR Game

Re:Mono for Unreal Engine by s73ver on Friday August 04, 2017 @03:06PM (#14931119)
It's just a really old version.
Re:Mono for Unreal Engine by pjmlp on Saturday August 05, 2017 @05:23AM (#14934922)
Implementations is the keyword here, it doesn't have anything to do with the language itself.

GCC was for almost twenty years quite bad versus other commercial compilers, yet it is worshipped nowadays for its performance.

Re:Mono for Unreal Engine by kevingadd on Friday August 04, 2017 @06:16PM (#14932822)
This isn't Unity. Why does Unity's version of Mono matter here?