It has been a little while now that Wonderboy 3 was released for Linux and Mac, thanks to Ethan Lee’s porting efforts, and while you will get to see our review pretty soon, we have some more details to share about how the porting efforts went. This is somewhat of a special project to me, since I met with Omar during the course of the game’s development, well before its release on the multiple platforms it now supports.
But first things first. The original plan by Omar was to release the game at the same time on Windows/Mac and Linux, but things did not turn as he expected, for various reasons:
Omar Cornut: I would probably have aimed to release Linux/Mac simultaneously with the Windows release. That was my intent but then I became surprisingly overwhelmed with preparing the Steam release (adding options which led to new ui, controls remapping, fixing compatibility issues, optimizing for older cards) and didn’t have the bandwidth to even consider talking to someone to make Linux/Mac happen. So next time we’ll tackle that earlier… I now also have more experience with shipping for PC in general so presumably it’ll be easier.
When Ethan took over the porting efforts, he did not start from nothing. There was already some prior work done by Omar on the OpenGL backend and the Mac version. But first you may wonder… why didn’t they just build a single OpenGL version that would run on all platforms, instead of using DirectX on Windows? Actually, that was the original plan.
Omar: The game was initially developed for OpenGL, I used the OpenGL backend for a year. I only switched to DirectX11 because too many drivers have OpenGL issues and I personally kept having the infamous diagonal-tearing-issue on my laptop which made playing the game very depressing, so I ported it to DX11. OpenGL just has too many problems (on every platform).
We may be used (and spoiled) by having reasonably good OpenGL drivers on our platform, but indeed on Windows OpenGL is often a lower priority for hardware vendors focusing most of their resources in efficient DirectX drivers. In any case, Ethan Lee did not start from scratch:
Ethan Lee: Linux/Mac backends existed but they were both really old and totally separate from one another, so I started from scratch to make a generic SDL backend. Some SDL stuff existed in the Linux subsystem but I didn’t use it. The new backend works on Linux/macOS and Windows would probably take an afternoon to get working.
The SDL backend was pretty easy, but hooking it up had a handful of challenges – wiring up a new PC platform without clobbering #if ENGINE_WINDOWS defs isn’t new for me though! Keeping the build together was probably most of the work, with some odd jobs for the filesystem and the graphics subsystem happening every now and then. Their OpenGL support was already in place, it just needed some optimizations for the desktop (a lot of it was either modern GL by accident or GL that worked a whole lot better on mobile than on desktop).
The filesystem oddities mentioned by Ethan Lee made the file listing break in some specific conditions in the Linux port, until he could figure out what was causing this strange behavior:
Ethan: Part of the new backend was a file manager. Basically, all the file I/O calls are done in here. For us, that’s a whole bunch of stuff from unistd/dirent/etc. I had this and I’ve done it like this for a while:
bool isDirectory = dir->d_type == DT_DIR;
Turns out this actually doesn’t work, and we had no real way of telling until I got _everything_ about this person’s setup and we printf’d the everloving crap out of the filetree that the engine was getting back. As it turns out, XFS and ReiserFS don’t support this, but it’s still a part of the struct either way so you just silently get a bad value, leading to the game’s file tree being totally incomplete and leading to lots of missing files and eventually some hard crashes. It took a solid week of trial and error with one other person to figure out what the problem was.
This is what you actually have to do instead:
struct stat info; stat(fullPath, &info); bool isDirectory = S_ISDIR(info.st_mode);
The port was well received, and to date there were very few bugs reported to Ethan. In case you have issues with the game please don’t forget to let him know!
Ethan: It did pretty good in reviews, though it was so quiet in the support forums I couldn’t be entirely sure how everyone else felt about it! I think I got 2 [bug reports] in total across both Linux/macOS in the opening week… one was filesystem related and one was Mesa related. If there were any more I’ve already forgotten because they were all so quick to fix.
When it comes to how well the title did in terms of sales on the Linux platform, it’s kind of unclear, while it seems the console versions did much better than the computer ones:
Omar: I have no idea to be honest, I don’t think Steam provide platform information connected to sales? (I don’t have direct access to the sales data). The Steam sales in general have been a little lackluster compared to the consoles, but it’s also because our game was released on consoles earlier, and it’s a very consoley game in general.
On the other hand, Omar is pretty positive about such ports to Mac and Linux. They should all be “worth it” in the long run, while highlighting it’s going to be a case-by-case approach for every game they make:
Omar: I’m happy of the ports. Sales wise, even though we missed the launch window, I suppose having Linux/Mac available is probably worth it for the long tail. Porting future games – pragmatically speaking I think it often comes down to how much resources, energy and bandwidth we have at a certain moment. Ideally I want our games to be on every platforms and I like the idea of supporting Linux. But some games may be more complex to port, if the porting cost (either the financial or mental cost) gets higher and we’re insecure about the success of a game or short of money it could be tempting to bail out. We’ll definitively consider it for every game, but I can’t promise it’ll happen every time!
As you may all know, the GOG version was late to the party, and not available at the same time as the Steam release. It is now available on their platform, DRM-Free, in case you were waiting for such a release. The reasons involved in such a delay a quite interesting, since most of us are not familiar with the constraints leading to gaps in availability:
Ethan: I did have to spend some time getting Galaxy SDK access but that won’t be an issue going forward… for their older contracts I think they have to amend them to add Linux/macOS as platforms they can distribute for, but I don’t know if their newer deals have that problem. There’s also the process of repackaging which can take some time, but they are starting to develop tools similar to SteamPipe to remove themselves from that process.
Omar: I support GOG and love the idea of GOG but their process are still very manual, sometimes cumbersome. It wasn’t clear on our side what were the steps to move forward with adding Mac/Linux there so it sorts of went lower in the priority list and then it was too late to release on the same day. Likewise, we should have planned that a little ahead.
Many thanks to Omar and Ethan for their availability to talk about the port – and for making the port to Linux happen!Don’t forget you can support them by buying the game on Steam or GOG.
There will be more to come from us in the review of Wonderboy 3 on Linux, and of course we plan to bring you more development stories in the near future as well.
You might want to check out the following articles too!
BoilingSteam lets you access our content for free, but writing articles is a constant investment. We don't use ads or sponsporship, help us make our activities sustainable by donating via Patreon or LiberaPay if you prefer it anonymous. You can follow what we do via our newsletter, our RSS feed, our Mastodon profile or our Twitter feed. We also have Peertube, Youtube and LBRY channels. If you'd like to chat, you can also find us on #boilingsteam:matrix.org. (what is Matrix?)
Interesting. It seems having an experienced Linux programmer and beta testers works to prevent the “Linux is 1% of the sales and 50% of the support costs” phenomenon some have complained about!
It’s too bad neither the C standard library nor SDL2 have an API to browse files and directories… (No idea which technology Wonderboy 3 uses.)
and the best part is experienced linux programmers are completely free to employ!
This is probably true if your project is reasonable in size (for the Linux programmer part of your comment), for anything very large like any AAA title it’s going to require a lot more resources to port and test, whether externally or internally, I think.
I’m convinced the person responsible for the “50% support” complaint just pushed the “export to linux” button in Unity without checking if it worked. If you do a good job then you don’t get many bug reports, as this article illustrates.
A cool chat. Thanks to all involved!
I also recently had to deal with dir->d_type not being populated on certain file systems with a project I was working on. As Ethan says, it’s a nasty one to come across since there are no obvious indicators of something going wrong (beyond users filing bug reports that are hard to identify/reproduce).
If such an issue is reported to the maintainers of such problematic file systems, do you think it would at least improve the debugging process?
No, I don’t think it’s an oversight with those file systems – they’re intentionally the way they are. It’s also not a problem with dirent, etc., since they are doing what they advertise.
The layer of abstraction above those is where this needs to get “fixed”, and that is either file handling libraries/middleware or our own codebases if we’re not using third party abstractions.
If there is a problem, it’s that it’s easy for developers to not be aware that the dirent struct’s d_type property isn’t reliably useful, buuuuuuut it *is* documented http://man7.org/linux/man-pages/man3/readdir.3.html