OpenGL ES glDrawArrays calls block

Hi, Baudouis,



Try using EGLSyncKHR:

// the following create a sync

EGLSyncKHR sync = eglCreateSyncKHR(display, EGL_SYNC_FENCE_KHR, NULL);

// flush all the commands and wait for them to complete

eglClientWaitSyncKHR(display, sync, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR);

// destroy when not needed anymore

eglDestroySyncKHR(display, sync);



I had a similar problem, and this helped me.



Try playing with flags (EGL_SYNC_FLUSH_COMMANDS_BIT_KHR vs 0), wait time (EGL_FOREVER_KHR vs 0) etc. Ideally you should create sync after glDraw* call and wait for it in a separate thread, but you adapt it if your use case is different.



In my cases I didn’t even have to wait for the sync, just creating and destroying helped (although I ended up waiting for the sync in a separate thread, but that’s my case). Also test it on as many different GPUs as you can, and make sure you pass EGL_SYNC_FLUSH_COMMANDS_BIT_KHR flag if you wait EGL_FOREVER_KHR (otherwise on some GPUs it may just hang because it’s waiting for operation that is not sheduled).



Good luck!