So I'm writing a terminal emulator using SpriteFonts for text rendering. It works perfectly on Windows, however on Linux I get a fair bit of graphical bugs.
We tested on two different distros. Arch Linux and Ubuntu 17.04. Both were running MonoGame 3.6 Stable with the
mesa video driver. The system running Arch uses
i3wm as a window manager. My Ubuntu system uses
compiz as a window manager. Both systems run with extreme reliability.
The developer running the Arch system reported hieroglyphics displaying in his terminal where text wasn't being rendered. He also reported the contents of other windows on the system being rendered in the game window anywhere where the terminal was supposed to be drawn. Finally, after a few consecutive launches of the game, his game failed to boot even after a clean rebuild of the entire solution.
This is a screenshot of the hieroglyphics he's talking about:
Note that everywhere where text IS rendered it is fine. It's just where it isn't rendered that it goes all Egyptian on us.
Although he reported other windows drawing inside the game window, he did not post a screenshot of it (possibly for security/privacy reasons in case really personal info would be captured.)
~~I also cannot post a screenshot of the effects on the Ubuntu system yet because it is not currently in front of me, but trust me - same build of the game, but the effects are way worse. And they're reproducible. When I get home I'll record a video of it in action and post it here.~~ EDIT: I can post the Ubuntu version of the glitch.
The graphical effects seem to depend on what windows are open and visible on-screen (i.e which ones are in the same desktop workspace as the game, and which ones are NOT minimized.) In this one I could see the game's console log (aka
gnome-terminal) rendering inside the game mixed in with the in-game terminal's text output.
Also, unlike the Arch screenshot above, this recording shows more severe layout bugs in the terminal - text simply does not get placed correctly. It seems to get shifted over by whatever outside window happens to render in the game.
Also, either my eyes were playing tricks on me or the Infobox that appeared to tell the user that the game uses cloud save features was also affected by the bug. If so, then this could be something even deeper than SpriteFonts as that message uses a different style of text rendering (
cairomm p-invoked by the game)
Here's the code for this terminal emulator: https://gitlab.com/watercolor-games/the-peacenet/blob/monogame/ShiftOS.Frontend/Apps/Terminal.cs
Your attention is specifically drawn to the
TerminalEmulator class where rendering actually takes place.
Are there any ways I can fix this issue? It seems to only be a thing on Linux. Any help would be greatly appreciated!
Edit 2: Worked around the bug slightly by drawing a box the same color as the current background color of the character in the terminal. I draw this box every time I come across a
\n in the standard output, and the box starts at the position of the
\n. It ends at the right edge of the terminal render area and is one char tall.
Edit 3: Considering renaming the thread to "Transparent textures aren't transparent in MonoGame on Linux". It seems that any time there's alpha transparency in a texture, issues like these arise. Heck, the various icons in my UI which are rasterized FontAwesome icons (with transparent BGs if I may add) draw with black backgrounds. This is undesired and doesn't happen at all on Windows.