Web/main/_posts/2019-07-06-cross_platform_trainwreck.md
Ell 28e938feb6
All checks were successful
Web/pipeline/head This commit looks good
added emoji to the website because they look hella good
2021-11-10 23:18:12 +01:00

7.6 KiB

layout title summary tags discuss archived
blog 😔 About Cross-Platform and Motivation How moving from Java to C# taught me how horrible it is to create a cross-platform application with little to no knowledge or documentation
Programming
https://twitter.com/Ellpeck/status/1147502654236573697 true

As originally a java kid, I've never had much trouble with making any of my programs work on Windows, Linux and Mac. With Java, all you have to do is make a jar and then tell people to install Java on their machine. That's it. But oh boy, am I getting hit in the face hard now that I'm making a game with MonoGame and .NET Framework.

The story, with all its horrible parts

Imagine you're me. Imagine you're just happily making a game and eventually you decide that you want to distribute it to testers.

The documentation

So you check the documentation of the framework you're using: MonoGame, in my case. It advertises itself as being amazing at cross-platform, so I look around to find a simple tutorial on what to do to get my game working on Mac and Linux.

Mono is where it's at. Okay. An open source implementation of .NET (or something like that) that works on Linux and Mac. Great! Now I just need to find out how to easily package that with my game, so that people on those operating systems don't have to install it on their own.

Mono Kickstart

So there's a project on GitHub with a MonoGame fork (meaning they should work together flawlessly!) called Mono Kickstart. It says that you can just add the files to your project, rename a couple of them, change one or two lines in a bash script and then your game will run smoothly on Linux and Mac without having to install Mono.

Yea, no. Some random issue about System.Runtime.dll not being found, no trace of the issue online, no tutorials anywhere, the Kickstart repository doesn't have an Issues tab for some reason. Dead end.

mkbundle

Searching some more online, I found a tool contained in Mono called mkbundle, that, apparently, you can use to bundle standalone applications for Windows, Linux and Mac by just running a simple command. Seems easy enough.

Yea, no. Installing Mono on Windows is a huge pain. mkbundle's target downloading doesn't work on Windows, so I have to go into some obscure folders, download some obscure zips, rename them, move them around until it finally works.

Hah. For some reason, mkbundle now requires me to install Visual Studio. So I install their commandline build tools that, after asking in my Discord, are apparently what mkbundle wants to use for something.

So then it finally works, and I have a... yea, no. Apparently now, mkbundle can't find System.Runtime.dll, just like Mono Kickstart couldn't before. So I search around in some folders and notice that that dll is in a sub-folder instead of the main folder it tries to look for it in, so I tell mkbundle that it's in that subfolder through a long and annoying addition to the command, and now it finally works.

Yea, just kidding. Now it crashes because it can't find stdint.h. It's neither telling me where it's trying to look for it, nor why it even needs it, what it is or really anything of use at all. Dead end.

.NET Core

After some more looking, I find that .NET Core is basically a better version of .NET Framework (it's actually a lot different, but that doesn't matter in the scope of this post) that actually runs on multiple platforms natively.

So I go through the process of upgrading my game project from .NET Framework to .NET Core, and everything finally works. I can really easily use my IDE (Rider) to publish packaged builds of the game for Windows, Linux and Mac that don't even need the user to have .NET Core installed.

Except that it doesn't run on my Laptop for some strange reason. It runs fine on my PC, and it runs fine on my boyfriend's computer and his Linux VM, but my Laptop has some obscure issue about MonoGame not being able to load the shaders it requires. There are also no traces of the issue online, and after some looking around, I realize that MonoGame's .NET Core implementation is, according to the repository, just a hack that also hasn't been updated in over a year. Dead end.

(Also, I had a weird issue where, with the newest version of MonoGame for .NET Core, my game would randomly stutter, and while the MonoGame Discord was unhelpful and one person was frankly unreasonably rude in my opinion, I found out that it isn't the fault of my code (after plenty of profiling) and that the issue is easily fixed by downgrading to an earlier version. Why? Who even knows at this point.)

So I guess I'll just force the user to install Mono themselves then

I tested around a bit after going back to .NET Framework and it turns out that installing Mono on Linux isn't actually that bad, and after you installed it, you don't even have to run a special command to get the game to run. All you have to do is go into a terminal and run the game's normal exe, and apparently mono figures itself out without needing to specifically call it. So that's great!

Except that, on Mac, it seems to be a whole nother story altogether. The one person I asked to try it on Mac installed Mono, but then the system didn't seem to realize that it was actually installed, as the mono command didn't work, and just running the game's exe directly also didn't work.

Other stuff I tried

Because it's so fun, here's a list of other stuff that I tried to use:

  • Some obscure NuGet package that's supposed to make an easy msbuild command to bundle the game. Also didn't work, but at least I submitted an issue to the project's GitHub repository. We'll see what happens, maybe this will be the saving grace.
  • Some obscure program from three years ago, with outdated packages and outdated dependencies, that was supposed to make it really easy to bundle projects for all operating systems. It had the same System.Runtime.dll issue, but because it was so outdated anyway, I didn't even bother investigating why.

Conclusion?

Honestly, I don't know what to do at this point. After finding out how horrible it is to make anything work cross-platform, I'm genuinely considering just rewriting the entire game using libgdx (which is a game framework for Java), or something.

There's no real conclusion to this, other than that it took me a whole lot of my time and energy and that it made me buy and eat way too many tubs of Ben & Jerry's ice cream, which is way too expensive, by the way.

Also, the Multiplayer debacle

As a little side note, I recently added Online Multiplayer to the game in question, using the C# networking library Lidgren.

Its UPnP implementation doesn't seem to be with my router (or my something else), so I have to manually forward ports as if it were 2003.

Also, one of the testers has a completely different issue about incomplete packets that I have no idea about, and frankly, my energy to work on anything is so low at this point that I might as well just not care about it.

Conclusion

If you're thinking about becoming an indie developer, you'll have to deal with this sort of stuff. And honestly, it's going to bring you down. Quite a lot.

A couple weeks ago, I picked up this project again after taking a long break from it out of lack of motivation, and after picking it back up, I was so happy and energized. I reworked the art to make it look really great, I added more sounds, I hired a music artist, I started implementing online multiplayer, I set a personal roadmap for release on itch.io later this year.

And then this whole thing happened, and now my motivation is back to zero. It's just extra frustrating to me because I was so excited about finally getting back the motivation that I had previously lost.

So yea. Thanks for reading, I guess. <3