Tuesday, September 18, 2018

Avoiding 3rd Party Bugs

So.. one of the recurrent issues, and one I may have mentioned in passing was the game's tendency to throw SystemAccessViolations, particularly when I was trying to do anything with changing the Direct2D brushes (which was a bit of an issue, since I was creating new brushes every time the screen changed.)  This wasn't as noticeable on high-end machines, but particularly on old, slower machines, the game crashed a lot.

As that particular violation is an unmanaged code violation (i.e. not something C# can generate) I couldn't really go deal with the problem directly (I guess it's something in the SharpDX code)  However, I got around it by just keeping a collection of brushes (Since I'm only altering the color) and only creating brushes if a combination doesn't match existing brushes.

This appears to have completely eliminated the problem, or at least made it very rare.  While there's nothing quite as infuriating as the very rare crash, at least in that case I should be able to emergency save to prevent the player from losing progress (as only the rendering is corrupt, at that point.)

No illustrative GIF on this one, the rendered result is the same as before (although faster on older computers)

No comments:

Post a Comment