Ultra Hat Dimension crash-on-startup issues resolved

Posted by (twitter: @enichan)
May 3rd, 2015 11:50 am

Ultra Hat DimensionIf you haven’t already you can now try Ultra Hat Dimension — the premier hat-based puzzle game — more easily than ever. I’ve updated the latest build to automatically work around two crash-on-startup issues the game had. I’ll explain the problems and the solutions in more detail below if you’re interested in learning from my mistakes.

The Problem

Right after submitting UHD the reports of crashes when trying to run the game started flooding in. This was 4 am my time, so I was quite annoyed. I wound up staying up til 6.30 am trying to fix the issue. It turned out there were two problems:

  1. Windows was marking the zip as a file “not from this computer” and blocking files. Blocked files can be unblocked by right clicking on the file, selecting Properties, and clicking “Unblock” in the general tab.

    ClearScript, which I used for Javascript scripting, has an interesting way of loading its dependencies, so it can load either 32-bit or 64-bit on demand. One of the dlls being blocked caused ClearScript’s loading to fail and crash with an unhelpful TypeLoadException error. I’d never noticed the blocking behaviour on Windows before, and I’d never heard of it causing crashes with my other games.

  2. ClearScript also had a dependency on the Microsoft Visual C++ 2013 Redistributable (x86). This was easy to reproduce on my laptop.

The Solution

Eventually I figured out what was happening was that Windows Explorer’s built-in zip support propagates the file zone information (which indicates it came from another computer) and because I use 7Zip to extract files myself, I could not replicate that behaviour. Basically, any program that unpacks zips doesn’t have this problem, only the Windows built-in.

Since it only causes a crash with ClearScript’s dlls which are loaded at runtime, I rolled up a bin file format that packs multiple files in one. Now my framework checks for ClearScriptXX.bin (either 32 or 64) and if it finds them extracts the files from that before running the game. That creates the dll files, which won’t be blocked by Windows, and so won’t crash.

I also bundled vcredist_x86.exe with the game. The framework checks if this file exists and checks the registry* to see if the redistributable is installed. If it’s not it runs it with /passive /norestart arguments, which means no user input is required to complete the install and the user won’t be prompted to restart. After installing the redistributable, the game loads up as expected.

* The registry entries for the 2013 VC++ Redistributable to the best of my knowledge can be found here

Tags: , , , , , , , ,

Leave a Reply

You must be logged in to post a comment.

[cache: storing page]