Unity Android and OpenGL ES 2.0 – another cautionary tale…

In my previous post I mentioned how excited I was to finally get over a huge crashing issue I had with Zombie Room AR. While that post is still completely accurate, my total celebration was a little premature. A couple of days after pushing out the latest fixes I got another email from a user experiencing a crash… Seriously!? I just.. but I… come on…

So here I sat with ANOTHER crash happening – this one was crashing in the exact same way, and once again it wasn’t putting together a report of a stack trace for me to find the underlying problem. Whiskey sure is tasty!

This user gave me their device specs, and of course it’s a device I do not own. I was super lucky though because a colleague of mine did! We flashed his phone to the stock rom the user was reporting and downloading Zombie Room AR’s Demo version. We sat in wait until the game installed – we fired it up and… BOOM! CRASH! Finally I was able to reproduce a customer crashing issue! Huzzah!  I hook up ADB logcat and reproduce the error… unfortunately I’m not really seeing anything except the PID dying… no stack trace or anything.  That’s when I remembered that You have to Enable ‘logcat’ Profiler in Unity’s Player Settings.

I quickly do this and throw a build onto the phone. Once again I run logcat and then I actually get to see the stack trace:

82b057bc /system/lib/egl/libGLESv2_POWERVR_SGX540_120.so

Now here’s the fun part – I already opened a ticket with Unity about this problem 8 months ago. They promised me that they had fixed it in the latest version (which I’m using) [At the time of writing this is both 3.4.2 and 3.5] and since I hadn’t seen this again I thought they were right. This is (obviously) the OpenGL ES 2.0 library, and it’s the reason that clicking any menu button crashes the game out. I decided I wanted to run through a series of tests to see what’s actually happening.

I’ll skip all the boring stuff and just throw this out there – if you’re using Qualcomm’s SDK or any Plugin that’s going to hook into the UnityPlayer Activity, OpenGL ES 2.0 will crash the Unity Player on Android 2.3.3+. Once you get to 3.0 you’re fine… I’ve opened another ticket with Unity but I honestly don’t expect them to care about it at this point. They’ll consider this an edge case and I know they’ve got bigger problems to fix first.

Qualcomm isn’t to blame here either – it’s technically a Unity bug, which is technically an Android bug… so that’s just where we sit. So what’s a dev to do about it? Well the answer is quite simple, change to OpenGL ES 1.x. Luckily I wasn’t really using any of the advanced shader features and lighting that 2.0 has – after all I need as much processing power as I can get for the Target Image mapping, so I updated my Pro and Demo versions and put them up on the market (now called Play Store for some stupid reason).

I now know better and won’t be celebrating just yet – I’ll just be  happy to not get any crash emails for a day or two!

3 Responses to “Unity Android and OpenGL ES 2.0 – another cautionary tale…”

  1. 1 Ryan W. March 9, 2012 at 6:11 pm

    Thanks for the info. Given that this is a blog post, why not explicitly include your current version of Unity. 3.5 I presume?

  2. 3 Gianluca June 10, 2012 at 6:20 pm

    Thank you again, very useful piece of information here. I think i will keep reading this blog for a long time!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: