Search Unity

Android crash: "call to OpenGL ES API with no current context (logged once per thread)"

Discussion in 'Android' started by ted-gamaya, Nov 16, 2015.

  1. ted-gamaya

    ted-gamaya

    Joined:
    Apr 16, 2013
    Posts:
    6
    I wanted to post this for others who have this problem. We are on Unity 5.0.2 (and 5.2.2). The Android tablets were all working. However, all Android mobile phones were crashing on load with the "no current context" error.

    We tracked it down to "landscape" and "portrait" issues. From what we gathered, if you override the Manifest file, then in "Build Settings" -> "Player Settings" -> "Resolution and Presentation" -> "Default Orientation", these settings don't really matter. What I *believe* is happening is that Unity uses these settings when they generate their own Manifest file. But when you override the Manifest file, you have to do it manually.

    The reason we figured this out was that all mobile phones start in portrait first (and tablets landscape) and only the mobile phones were crashing with this error.

    So if you having the same issue here are some places to look:

    1) AndroidManifest.xml: We have our own Manifest file because of a few plugins (OpenIAB, OBB Downloader and BTLE). This means that we have overridden the default Unity Manifest and so we put these on all our <activity> tags.

    <activity android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="landscape">

    2) We set our "Default Orientation" to "Auto Rotation" and chose "Landscape Right" and "Landscape Left". Picking "Landscape Right" or "Landscape Left" instead of "Auto Rotation" crashes with this error. Again, I'm not sure what Unity internally does with these settings, but we use NGUI and so we wanted third party code to know which orientation we wanted (in case they read these settings).


    I hope this help others cause it took us about a week of making small changes, build, test, repeat. And the Android builds are VERY VERY VERY VERY slow. If you are getting crashes, I highly recommend making a new Android project with a very simple scene and make sure that runs on the hardware. If that works, copy your project, remove as much as you can and get a very simple scene working. This saved us countless hours on the build. By the way, if a simple project runs on the mobile phone, then it's probably a setting in "Build Settings" or your "AndroidManifest.xml"

    Ted

    PS: If any Unity folks are reading this, please give us more information on the following:

    1) Why does the Android build take so long? And what can we do to make it faster? Why is there no caching/obj/incremental build/etc being done? Clicking "Build" right after a previously succeeded build re-builds the entire apk again. Please look into some kind of incremental build. It pains me to imagine all our countless hours wasted on waiting for the Android build to complete.

    2) What does all the settings under "Settings for Android" do? Which Android/OpenGL settings/variables/etc is it changing? And when we override the Manifest files ourselves, which ones should we be looking out for?

    In another words, what additional changes are made to "\Unity\Editor\Data\PlaybackEngines\androidplayer\AndroidManifest.xml" when these settings change?

    3) PLEASE check for the keystore password BEFORE you start the compile. I've lost countless hours because I had to reopen the project and the keystore password was nulled out.
     
    ab_random_new likes this.
  2. KevinLegendre

    KevinLegendre

    Joined:
    Mar 16, 2015
    Posts:
    8
    Hi Ted,
    Tanks a lot for your post. I experienced the same issue and you save me a lot of time!!!
    Do you have some answer about your point 2 :
    I still have some crashes. When I don't override the Manifest file myself there are no more crashes.
    I think we will have to do all the player setting by ourself on our own manifest.

    Thank again.