Wanna Crash Unity?

I had just finished a round of refactoring, pushing some common event-handling code into a utility/manager layer, when all of a sudden, Unity starts crashing every time I enter Play mode. I went through dozens of crashes and restarts trying to narrow down the suspect code. I was convinced it was obviously related to the few files I had changed...and it was, though not directly. There was a ripple effect in which a null value made its way down to some code I hadn't even touched.

In one of my camera scripts I'm using Graphics.Blit() to compose multiple textures into a final image. This takes two parameters: a source Texture, and a destination RenderTexture. Oddly enough, the destination is allowed to be null...but as I found out, if source is null, Unity is going down hard. I think it's likely that Graphics.Blit() is a fairly thin wrapper around a more low-level, graphics-driverish function. It's pretty easy to jack things up when bad values are passed in, but they clearly check the destination parameter for null, because that value has special meaning in this context ("blit directly to screen"). Maybe it's fixed in a newer version, I dunno; bug report submitted.

Leave a comment

Log in with your itch.io account to leave a comment.