Specialization

Crash Handler for proprietary engine

Motivation

For my specialization I choose to do a crash handler for my group's proprietary engine. The reason is that before my time at TGA I studied software testing in Malmö therefore I have a special interest in testing and tools to facilitate testing. Already in our first group project I noticed as everyone had their assigned tasks and there was a lack of time and interest in testing the games. So I wanted to make a tool that makes testing and gathering the relevant information easier.

Goal

My goal with this specialization was to make my own version of The Unreal Crash Reporter. I wanted it to pop up when the engine crashed so the user could write a description of what they were doing when the engine crashed. On top of that I wanted the engine to make and save the console log, screenshot and a dump file. Last part of my specialization was to make it possible to send the previously mentioned files over the internet in zip format with a click of a button. How and to what exactly I did not know when I started. I used the unreal crash reporter as a mockup.

The Unreal Crash Reporter

Generating crash files

The first thing I started to work on was making and saving the different crash files when the engine crashed. I wrapped the main loop in a try except so I could catch a crash. When I caught a crash I started by making a dump file using Microsoft's debughelp library (dbghelp.lib). Then I saved the last frame from the swapchains back buffer if possible. In other words I saved the last frame before the crash as a jpg picture. Generating the console log was a bit tricky since I have to save everything that is written in the console since the start of the program. My solution was to have a text file open all the time and close it when the program crashes, by doing this I avoid opening and closing the file everytime I write to it which saves a lot of performance.

These are debug files that are saved from a crash if possible

These are the debug files that are saved from a crash.

One of the most important parts of my specialization was to get the user to describe what they were doing when the engine crashed. To make this possible I had to make a user-interface that could survive the crash. My solution was to make a separate application that starts the engine and catches the exit code if the exit code wasn't 0, which means the engine has crashed. Then the first application pops up and asks the user to write a description of what they were doing before the crash. To make the user-interface I used ImGui library (ImGui.lib) which saved a lot of time since I didn't need to make new graphics.

My copy of the Unreal crash reporter

Sending the files

The greatest challenge of my spezilastion was to send the files over the internet. In the beginning I had no idea of what I would use to send the files. Knowing that I purposely planned for research at the end of my project so I could cut it if needed. After my research I decided to send the files using the Perforce API. My reasoning was that my group projects already used a perforce server for version control and we had a Discord bot that pinged every time someone pushed to the server. Therefore everyone in the group had access to the bug files and got a notification when a new bug was reported.

An example of how a discord notification looks when a crash is reported.

The result

I'm happy with the result of my specialization. I managed to make every feature I planned. One thing I failed to anticipate was how hard it would be to catch all crashes. The solution I came up with was to make a separate application that watches the engine and reacts to the exit code. This makes my crash handler able to detect all crashes although it's not possible to make all the debug files on certain crashes. Sending the files with the Perforce API was by far the hardest part of my specialization, since I have never worked with an API before. The Perforce API also used a lot of command lines and C style programming, which I'm not very confident with but it was a lot of fun to learn. If I had more time I would like to make the tool into a bug reporter, not just a crash reporter. With a press of a button the user-interface pops up and you can report a bug with a description, screenshot and console log and send it to perforce. Another thing that would be really fun is to make the tool able to send bug reports to a real issue handler like Jira.