{"id":2181,"date":"2010-05-18T14:47:22","date_gmt":"2010-05-18T19:47:22","guid":{"rendered":"http:\/\/www.hemispheregames.com\/?p=2181"},"modified":"2015-02-04T06:45:17","modified_gmt":"2015-02-04T06:45:17","slug":"porting-osmos-to-linux-a-post-mortem-part-23","status":"publish","type":"post","link":"https:\/\/www.hemispheregames.com\/new_blog\/2010\/05\/18\/porting-osmos-to-linux-a-post-mortem-part-23\/","title":{"rendered":"Porting Osmos to Linux: A Post-Mortem (part 2\/3)"},"content":{"rendered":"<p>Welcome to the second installment of our three-part Linux post-mortem. <a href=\"\/2010\/05\/17\/porting-osmos-to-linux-a-post-mortem-part-13\/\">Part 1<\/a> lay the foundations for the article and where we&#8217;re coming from.  Today&#8217;s post directly addresses the question &#8220;What worked and what didn&#8217;t?&#8221; with a set of &#8216;pros and cons&#8217; that cropped up during the port.  The final post will offer a more nuanced set of reflections on these experiences, their implications for game development, and my advice for moving Linux forward as a gaming platform.<\/p>\n<h1>Porting Osmos to Linux: What I Loved<\/h1>\n<p>Let&#8217;s start with an account of the stuff that stands out as having worked really well &#8212; things that were well designed, pleasant to use, and easy to learn.<\/p>\n<h1>Love: Live discs and bootable USBs<\/h1>\n<p>Being able to boot into an OS from USB without having to first install to the HD is fab, and the various Linux distros have for the most part done a good job of supporting this behaviour.  During development, live discs were helpful in two main ways.  Firstly, when I was starting out, they made it easy for me to poke around and find a distro to use as my &#8216;core&#8217; Linux install (i.e. the install on which to do the bulk of my Linux development; I settled for Ubuntu 9.04).  Secondly, live discs made it easier to do quick first-blush tests of cross-distro\/DE\/WM compatibility for my executables and packages without having to first fully install and configure every OS.<\/p>\n<p>One wish for the live discs would be for the OS versions they contain to have more robust HW drivers, particularly for video.  I realize drivers are a tricky issue in Linux and hard to support generically out-of-the-box, especially on a live OS (where, for example, rebooting to install a better driver isn&#8217;t in the cards), but for game development it would be great to have decent video performance when booting from a live disc.<\/p>\n<h1>Love: Code::Blocks<\/h1>\n<p>I was looking for a simple, light-weight, easy-to-use C++ IDE that was easy to find in binary form for several distributions (I didn&#8217;t want to have to compile an IDE myself) and that had some kind of interface sitting on top of gdb.  <a href=\"http:\/\/www.codeblocks.org\/\">Code::Blocks<\/a> was the answer.  It wasn&#8217;t bug free, mind you, and crashed on me once or twice per day (at times to great frustration because of state loss&#8230; but nothing reliably reproducable, I&#8217;m afraid, hence no bug reports filed).  But, critically, it provided a simple project system, a simple-yet-powerful set of compiler\/linker options, the essential find\/error\/debug\/bookmark interactions, and a basic gdb front-end.  Essentially everything I needed was there, it was simple to use, and it was available and (relatively) stable cross-distro.<\/p>\n<h1>Love: The Linux Package Manager<\/h1>\n<p>Linux&#8217;s package system may not have been easy-breezy to support (more on this below), but it sure was easy-breezy to use.  It was straightforward to find the developer libs\/headers I needed and get them automatically installed into the right places.  It was fantastic that dependencies are automatically tracked and installed, and that headers\/libs install to central and standard places for trivial inclusion\/linkage into the project.<\/p>\n<p>Two footnotes: firstly, this smoothness of experience was conditioned in part by the legwork that went into ensuring Osmos relied only on the most core of libs (libs\/packages that ought to play nice and be easily found on any distro; GL\/GLX, X11, FreeType, OpenAL, libogg\/libvorbis, etc).  Secondly, a couple of the enterprise-oriented distros seemed to require a prohibitive amount of leg-work to configure for engineering purposes; this makes sense if the distro is targeted towards the consumer\/office end of the market spectrum rather than the engineer, but for someone new to development on Linux, it&#8217;s painful if you don&#8217;t do your homework ahead of time.<\/p>\n<h1>Love: Support from the Linux Community and our Beta-Testers<\/h1>\n<p>It&#8217;s great to see how keen Linux users are to help support software on Linux.  The average Linux user is on-the-ball and really encouraging in terms of their enthusiasm for Linux and their appreciation of our efforts to get Osmos on Linux.  Post-launch, we&#8217;ve been getting great feedback and PR support from a few key folks in particular.<\/p>\n<p>When the Linux port went into beta I issued a public call for testers and recruited about 50 people.  Each one was top-notch in terms of being observant while playing the game.  They were all helpful with their detective work, and the average level of technical savy-ness was very high when it came to sniffing out audio and WM\/X issues for repro.  Folks were keen to try the game on as many machine specs as they could, and were keen to volunteer information and &#8220;run with&#8221; the testing on their own.  All this resulted in a very short beta period (less than two weeks) in which a lot of solid testing occurred very quickly, and with only a single patch being required to hammer out all known issues.<\/p>\n<h1>Love: Cross-Platform Compatibility is Good for your Code<\/h1>\n<p>While not a Linux-specific observation, there&#8217;s no doubt that developing multiplatform software is always beneficial for the code.  Each platform has different analysis tools, compilers that issue different warnings and generate different code, and video drivers with different behaviour; all of these serve to highlight any underlying issues in your project, and so the work invested on one platform has benefits for the other platforms too.  For the sake quality and stability, cross-platform compatibility has been a good thing for Osmos.<\/p>\n<h1>What I Didn&#8217;t Love<\/h1>\n<p>Let&#8217;s move on to the stuff that was less easy to love; things that stood out as being frustrating, difficult to use, and in some cases broken.<\/p>\n<h1>Didn&#8217;t Love: Supporting multiple Distros\/DEs\/WMs\/drivers\/etc.<\/h1>\n<p>The #1 obstacle to getting more games on Linux is that it&#8217;s very difficult to get your game working correctly and acceptably on all machines.  It&#8217;s really hard to guarantee a smooth experience for all players when there&#8217;s a combinatorial explosion of possible distributions, desktop environments, window managers, driver\/hardware versions &#8212; each with their own unique foibles, bugs, and undocumented behaviours.  It&#8217;s the classic PC gaming problem, but magnified.  Linux loves freedom and choice, which I applaud &#8212; but some amount of standardization, collaboration and &#8220;Let&#8217;s work together&#8221;-ness is required for the platform to be friendly to application developers.<\/p>\n<h1>Didn&#8217;t Love: Audio<\/h1>\n<p>Brace yourselves, folks, because I&#8217;m going to put it bluntly: audio in Linux is a mess.  The audio situation is another  major obstacle to game development on Linux.  It&#8217;s 2010; audio is a solved problem.  And yet on Linux, it&#8217;s shocking that you cannot count on something as simple as non-streaming playback, never mind any kind of processing (which most games are wont to do!)  There are a variety of standards (ALSA, OSS, PulseAudio, Phonon, &#8230;) &#8212; which one to choose?  Each standard has different problems on different machines.  For a given standard, some drivers are buggy and poorly configured by default, while others do horrible thinks like block on open when another process opened the device.  This is all another way of saying that there are no audio standards.  What is a developer to do?<\/p>\n<p>&#8220;But doesn&#8217;t OpenAL hide all the mess behind a single stable API?  Ideally you&#8217;d write the audio code once in OpenAL and then walk away.&#8221;  This isn&#8217;t how it happens in practice, because the fact of the matter is that the mess is still there.  Simply wrapping another software layer around the underlying problem doesn&#8217;t make it go away.  Using OpenAL for audio doesn&#8217;t all-of-a-sudden mean I can count on anything runtime-behavior-wise.  I write my code in OpenAL (rather than having to write directly in ALSA, PulseAudio, etc), but at runtime I still need to make choices &#8212; for example, by saying which underlying audio layer I want to use &#8212; and different people&#8217;s machine\/lib\/driver combos will do different things.  Simply using the local machine&#8217;s default audio device doesn&#8217;t guarantee anything about what&#8217;s going to work and what doesn&#8217;t, and a game needs guarantees in order to work correctly.  The audio situation is quite horrible I&#8217;m afraid.<\/p>\n<h1>Didn&#8217;t Love: Lack of Documentation and Consensus<\/h1>\n<p>In the Linux world there is so much choice and non-standardization, and it&#8217;s really hard to find out about things.  Documentation is sorely lacking, and it&#8217;s hard to find solutions because when a question is asked, people don&#8217;t agree on the answer.  Forum threads aren&#8217;t a good substitute for proper documentation, because forum threads can quickly become historical and fall out of date, meaning folks looking for answers spend a lot of time chasing down false-leads and asking themselves &#8220;Is this forum thread relevant to me?  Is it really what I&#8217;m looking for?&#8221; In the Linux world, it seems to take a great deal of detective work and reverse engineering to get things done; the plethora of choice means that the newcomer is never certain about their choices &#8212; and there will always be someone who disagrees with you (often vocally).<\/p>\n<h1>Didn&#8217;t Love: Drivers and Hardware Support<\/h1>\n<p>My main development machines are two off-the-shelf laptops with mainstream components, and neither of them had WiFi or video that worked out-of-the-box on any distribution I installed.  It took many hours to get decent hardware performance.  Proprietary drivers, open source drivers&#8230; which do I chose?  Do I really have to compile a driver for myself?  What&#8217;s more, when a new Linux user inquires about driver problems on a forum, the standard line of defense is to blame the problems on hardware manufacturers.  Whether or not the manufacturers deserve blame, the Linux platform folks need to step up, acknowledge the reality of the situation, and try to work to improve the platform.  The chipsets that didn&#8217;t work for me (without great effort) were nowhere close to bleeding edge (ATI and Intel graphics, Broadcom Wifi; some models dating back to 2007) and all are widely available on a large segment of the consumer-level market.  Linux needs better support for its HW; if I can&#8217;t walk into BestBuy, pick up a run-of-the-mill laptop and have my video and networking hardware work, then the platform is troubled.<\/p>\n<h1>Didn&#8217;t Love: Packaging the Game<\/h1>\n<p>It took days of effort to create the binary packages for Osmos (I&#8217;m happy to say that it&#8217;s looking like we don&#8217;t have to patch!)  How should an app be packaged in Linux?  Should I build my own libs and package them with my game, or rely on package dependency info and hope the distros have the right versions in their package repositories?  Which package formats do I choose (.deb, .rpm, .tar.gz, others)?  Do any of the package formats have naming conventions I need to follow?  What do you need to do to support both 32bit and 64bit?  What are the standard practices for where\/how my game is layed out on the filesystem?  What goes where and where do you commonly put softlinks?  How do I represent softlinks in the various package systems?  Do architecture-specific files belong in special places?  Are there any standards for what&#8217;s in the environment path?  How do I integrate my app into the desktop environment?  What DEs are worth supporting?  Do I need to do separate things to support separate DEs?<\/p>\n<p>There are no standards or clear answers to any of these questions.  There&#8217;s no documentation for this stuff!  Asking on the forums will typically net you a spectrum of answers with no consensus answer and lots of little side arguments.  I basically reverse engineered what I saw other apps doing (which sadly was of little comfort because everyone does it differently).  I settled on supporting .deb\/.rpm\/.tar.gz with explicit 32bit and 64bit executables for both the demo and retail versions of Osmos, with no redistributed libs and instead relying on package dependency info.  So far, this has worked out for nearly all distros except CentOS which has an archaic version of libvorbis and nothing new in the standard repositories.<\/p>\n<p>Side-note for those interested: I didn&#8217;t venture anywhere near cross-compilation and instead simply built the 32bit and 64bit executables on separate 32bit and 64bit Ubuntu installs (which, interestingly enough, both displayed unique and undocumented WM\/Xserver interactions, despite being the same version of Ubuntu!)<\/p>\n<h1>Didn&#8217;t Love: No OS-level GUI layer for simple dialogs<\/h1>\n<p>This is something of a minor point compared to the above, but I want to mention it because it comes up often enough in cross-platform development.  Because Linux has no OS-level GUI layer, games that need any kind of UI must link against heavy-weight UI libraries (GTK, QT, etc) which typically impose some kind of application framework.  Common examples of the usage of UI in the gaming world would be a dialog that prompts the user for input the first time a game is run (e.g. &#8220;Launch in fullscreen?&#8221;) or that displays a message when an app terminates unexpectedly.  For Osmos, I had to cut such user-friendly elements because I didn&#8217;t want the game to have any but the most basic of dependencies.<br \/>\n<br \/>\nWhew!  Alright: in part 3, I&#8217;m going present a more general discussion of the implications of some of these issues for game developers, and reflect on ways to improve matters.  Stay tuned&#8230;<\/p>\n<p>Dave<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to the second installment of our three-part Linux post-mortem. Part 1 lay the foundations for the article and where we&#8217;re coming from. Today&#8217;s post directly addresses the question &#8220;What worked and what didn&#8217;t?&#8221; with a set of &#8216;pros and cons&#8217; that cropped up during the port. The final post will offer a more nuanced [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,7,11],"tags":[],"class_list":["post-2181","post","type-post","status-publish","format-standard","hentry","category-dev","category-linux","category-osmos"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p5C9wi-zb","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hemispheregames.com\/new_blog\/wp-json\/wp\/v2\/posts\/2181","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hemispheregames.com\/new_blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hemispheregames.com\/new_blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hemispheregames.com\/new_blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hemispheregames.com\/new_blog\/wp-json\/wp\/v2\/comments?post=2181"}],"version-history":[{"count":1,"href":"https:\/\/www.hemispheregames.com\/new_blog\/wp-json\/wp\/v2\/posts\/2181\/revisions"}],"predecessor-version":[{"id":4470,"href":"https:\/\/www.hemispheregames.com\/new_blog\/wp-json\/wp\/v2\/posts\/2181\/revisions\/4470"}],"wp:attachment":[{"href":"https:\/\/www.hemispheregames.com\/new_blog\/wp-json\/wp\/v2\/media?parent=2181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hemispheregames.com\/new_blog\/wp-json\/wp\/v2\/categories?post=2181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hemispheregames.com\/new_blog\/wp-json\/wp\/v2\/tags?post=2181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}