Wednesday, September 30, 2015

How to fix Cocos2.1 shader crash on iOS 9

We have been using Cocos2D 2.1 for our game Monster Math.  Recently we decided to release an update to the game by compiling it against iOS 9.  To our surprise the game started crashing right at the launch with the following error.

A little investigation showed that it was crashing while creating OpenGL shaders.  A little googling proved that others were facing the same issue (more details here and here).

Whats the Fix - How Do They Do It! 

To fix the crash, I had to modify code in file CCGLProgram.m of Cocos2D and change the method compileShader as follows.

Once I made the change, the crash disappeared and it stared launching the game without any problems.

After this change we released an update of our game to AppStore.  We did however see a few crash reports around this very same issue from devices that were running iOS 7.

Will have to investigate further and fix it for iOS 7 devices as well.  Will keep you guys posted on what we did to fix it for iOS 7 devices, till then, have fun!
Have some Fun!