OpenGL error 0x0502 in CCRenderer.cpp and CCTextureAtlas.cpp

Hey all
I’ve encountered the following issue when debugging my game on Android with the Emulator.
I get a black screen while the application actually running but nothing is displayed on screen. Funny thing, I do manage to see ads - interstitials.
I managed to found the following errors:

I/OpenGLRenderer: Davey! duration=1868ms; Flags=1, IntendedVsync=2695875256932, Vsync=2696125256922, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=2696141389100, AnimationStart=2696141457600, PerformTraversalsStart=2696141495900, DrawStart=2697411835000, SyncQueued=2697416715100, SyncStart=2697722473300, IssueDrawCommandsStart=2697725437800, SwapBuffers=2697929896100, FrameCompleted=2698049618100, DequeueBufferDuration=55777000, QueueBufferDuration=1216000,
D/Cocos2dxActivity: onWindowFocusChanged() hasFocus=true
I/FA-Ads: App measurement is starting up, version: 19025
To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
I/WebViewFactory: Loading com.android.chrome version 69.0.3497.100 (code 349710017)
I/m.reilak.dejav: The ClassLoaderContext is a special shared library.
I/FA-Ads: Tag Manager is not found and thus will not be used
D/cocos2d-x debug info: create rendererRecreatedListener for GLProgramState
I/chatty: uid=10086(com.reilak.myGameProject) GLThread 422 identical 1 line
D/cocos2d-x debug info: create rendererRecreatedListener for GLProgramState
D/eglCodecCommon: setVertexArrayObject: set vao to 2 (2) 0 0
setVertexArrayObject: set vao to 0 (0) 3 0
E/eglCodecCommon: removeVertexArrayObject: ERROR: cannot delete VAO 0!
D/eglCodecCommon: setVertexArrayObject: set vao to 3 (3) 0 0
setVertexArrayObject: set vao to 0 (0) 5 0
D/eglCodecCommon: setVertexArrayObject: set vao to 4 (4) 0 0
D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 7 0
D/cocos2d-x debug info: OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCTextureAtlas.cpp drawNumberOfQuads 699
OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCTextureAtlas.cpp drawNumberOfQuads 699
OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCRenderer.cpp restoreRenderState 189
W/SoundPool: Use of stream types is deprecated for operations other than volume control
See the documentation of SoundPool() for what to use instead with android.media.AudioAttributes to qualify your playback use case
D/cocos2d-x debug info: OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCTextureAtlas.cpp drawNumberOfQuads 699
D/cocos2d-x debug info: OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCTextureAtlas.cpp drawNumberOfQuads 699
OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCRenderer.cpp restoreRenderState 189
D/cocos2d-x debug info: OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCTextureAtlas.cpp drawNumberOfQuads 699
OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCTextureAtlas.cpp drawNumberOfQuads 699
D/cocos2d-x debug info: OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCRenderer.cpp restoreRenderState 189
D/cocos2d-x debug info: OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCTextureAtlas.cpp drawNumberOfQuads 699
OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCTextureAtlas.cpp drawNumberOfQuads 699
D/cocos2d-x debug info: OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCRenderer.cpp restoreRenderState 189
D/cocos2d-x debug info: OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCTextureAtlas.cpp drawNumberOfQuads 699
D/cocos2d-x debug info: OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCTextureAtlas.cpp drawNumberOfQuads 699
D/cocos2d-x debug info: OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCRenderer.cpp restoreRenderState 189
D/cocos2d-x debug info: OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCTextureAtlas.cpp drawNumberOfQuads 699
OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCTextureAtlas.cpp drawNumberOfQuads 699
OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCRenderer.cpp restoreRenderState 189
D/cocos2d-x debug info: OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCTextureAtlas.cpp drawNumberOfQuads 699
D/cocos2d-x debug info: OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCTextureAtlas.cpp drawNumberOfQuads 699
OpenGL error 0x0502 in D:\Projects\myGameProject\cocos2d\cocos\renderer\CCRenderer.cpp restoreRenderState 189

And it keeps going like that.
I found a topic that says this error (OpenGL error 0x0502) has been solved in cocos2dx 3.17 (Android emulator black screen), but I’m using 3.17.2 with PROP_APP_ABI=armeabi-v7a:arm64-v8a:x86 and still get this issue for some reason.
Found a doc (https://drive.google.com/file/d/1ChY7c1xSnKmu_vTuEoseshHBzvivlVqB/view) that suggests to edit CCGLProgram.cpp, I did tried that but the issue still persists.

One thing to note is that the first error on the log is actually:

E/eglCodecCommon: removeVertexArrayObject: ERROR: cannot delete VAO 0!

And then we get to see the OpenGL error 0x0502 error in CCRenderer.cpp and CCTextureAtlas.cpp
Is this a new face of an old problem?

Hi , currently I’m facing the same problem as above . Did you resolve this problem ?

Hey @dragon0962
I tried multiple changes and eventually debug did work. I was trying to reproduce the issue today to have a more exact answer but with no success.
Please check the items below:

  1. Make sure PROP_APP_ABI is configured the right way for you. (See Android emulator black screen).
  2. Check Application configuration
    • Open Edit Configurations window - Run => Edit Configurations…
    • Locate your app on the left pane, under Android App category and select it.
    • Go to Debugger tab
    • Set Debug Type to be Dual (Java + Native)
    • In Symbol Directories add the following path:
    [project root folder]\cocos2dx\cocos\platform\android
    • Apply the changes.
    • Run Gradle clean (on Gradle panel => [app name] => Tasks => build => clean) to clean any previously built libs and code.
    • Switch to application configuration, it is probably been set to clean.
    Start debug, this will initiate a long build.

Let me know is any of the above helped, :crossed_fingers:

Hi thanks for your help, but I am facing the problem on both android and ios platforms . I think I have some problmes with my cocos library.