Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mono C# WinForms -> Serious performance problems when running on Mac OSX

I have a question regarding C#, Mono and OSX. I have created a Program in C# using Windows Forms and am trying to make it usable on a Mac.

Problem is, that the performance is extremely poor on OSX and I just can´t find a way to speed it up. The program itself is quite simple actually: A Client Server System using just two DataGridViews, a few ComboBoxes and Buttons, a TabControl, a few SplitContainers - and thats it! Works fine on Windows and has no speed problems whatsoever.

When I open the program on a Mac (MacBook Air, OSX Version 10.8.3) it takes ages to load the GUI. Building it up takes about 0.5sec on WIndows and nearly a Minute on a Mac(!). All the controls are built up very slow and most of the time when interacting with the program by clicking on something it takes another minimum of 10secs to respond.

I´ve learned that Mono natively builds up the GUI using Windows.System.Drawing. Is that a possible reason for the extremely slow response of the program? What can I do to speed up the programm? There must be some way, as Mono would be fairly useless if it´s not even usable for such a simple program...

I have spent hours trying to google an answer to my issue and just can´t find anything usefull: AheadOfTime-Compiling, LLVM - nothing improves the performance.

Thanks a lot for your answers in advance!

Chris

UPDATE: I´ve decreased the perfomance issue a bit now. Mono seems to have problems with the CellFormating of Gridviews. I changed the code in the applicable parts and it´s running faster now.

Nevertheless it still takes ages to build up the GUI. You can literally watch it build the GUI. Any suggestions on that?

like image 524
Chris Avatar asked Apr 03 '13 18:04

Chris


People also ask

What is Mono C#?

Mono allows C# developers to write cross platform code targeting Windows, macOS, Linux, Android, and iOS. What this means for Rhino plugin developers is that they can - if written properly - run the same RhinoCommon plugin in both Rhino for Windows and Rhino for Mac…

Is Mono Windows installer a virus?

I can confirm that it is a virus, it has infected me too, luckily I have not installed it, it is a program that if installed, in turn installs other viruses, I recommend deleting the program and all the folders created by it without installing it, as I did, subsequently to check your security with an antivirus, which ...

What version of C# does Mono use?

The Mono C# compiler is considered feature complete for C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0 and C# 6.0 (ECMA) and it has partial support for C# 7.

Is Mono discontinued?

Support for Mono versions 3.0 and 2.10 is been discontinued. No further development of bug fixing is planned for those branches.

Is Mono still supported?

In addition to the officially supported configurations from Microsoft, Mono (as an open source project), still supports the ".


2 Answers

The loading time is likely the JIT compiling your code for the first time (takes my assemblies about 30-60 seconds to boot up the first time too); running your program a second time should load much faster. On Windows, Visual Studio will AOT your assembly as part of the compilation, so the first boot up is fast. The slow control performance I believe is due to the font-rendering (it's not even good looking rendering either). On top of that, keyboard handling is wrongly implemented and since Mountain Lion, you'll also need users to download XQuartz.

Mono is useful, but its WinForms implementation isn't. If OS X support is important to you, your options are as follows:

  1. Use a different toolkit (GTK#, WX.Net, etc).
  2. Build a Cocoa Library DLL using XCode and PInvoke it from C#.

The safest bet is the latter, but if your needs are simple, it might be easier to just use a different toolkit.

like image 162
Mr. Smith Avatar answered Oct 10 '22 03:10

Mr. Smith


You will have to debug on a Mac or Linux to find what exactly is running so poorly. Mono has some implementations that are surprisingly slow. While you see the symptom of slow UI, the cause may be something else entirely.

For example, in a similar situation, I found that XmlDocument was very slow because I was researching why the UI was so sluggish. If you are using XmlDocument to store the data from the server, it could cause your UI to be slow and barely responsive.

like image 30
Fruity Geek Avatar answered Oct 10 '22 04:10

Fruity Geek