Search code examples
androidopengl-eslive-wallpaperopengl-extensions

GL11Ext glDrawTexiOES throws INVALID_OPERATION exception for some devices


I use glDrawTexiOES for a Live Wallpaper. This command just draw a bitmap by a texture every second. It is works fine on 99.9% of devices. But other throws INVALID_OPERATION exceptions.

I can not reproduce this exception just can use negative or zero values of width and height and get INVALID_VALUE exception.

I tried to disable texture, set active texture to 1 etc. Finally I commented all code and this command still works without an exception.

Any ideas?

Exception android.opengl.GLException: invalid operation
  at android.opengl.GLErrorWrapper.checkError (GLErrorWrapper.java:62)
  at android.opengl.GLErrorWrapper.glDrawTexiOES (GLErrorWrapper.java:894)
  at com.example.WallpaperServiceGL$EngineGl$RendererMy.onDrawFrame (WallpaperServiceGL.java:270)
  at android.opengl.GLSurfaceView$GLThread.guardedRun (GLSurfaceView.java:1581)
  at android.opengl.GLSurfaceView$GLThread.run (GLSurfaceView.java:1280)



backtrace:
  #00  pc 0x00000000007080f4  /vendor/lib64/egl/mt6789/libGLES_mali.so
  #01  pc 0x000000000076a924  /vendor/lib64/egl/mt6789/libGLES_mali.so
  #02  pc 0x0000000000707be0  /vendor/lib64/egl/mt6789/libGLES_mali.so
  #03  pc 0x000000000076bbb4  /vendor/lib64/egl/mt6789/libGLES_mali.so
  #04  pc 0x000000000038c3c0  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (art_jni_trampoline+112)
  #05  pc 0x00000000007815f4  /apex/com.android.art/lib64/libart.so (nterp_helper+11140)
  #06  pc 0x000000000045e8ac  /system/framework/framework.jar (android.opengl.GLErrorWrapper.glDrawTexiOES+20)
  #07  pc 0x00000000020059f8  /memfd:jit-cache (t1.e0.onDrawFrame+1640)
  #08  pc 0x0000000000780890  /apex/com.android.art/lib64/libart.so (nterp_helper+7712)
  #09  pc 0x000000000046955e  /system/framework/framework.jar (android.opengl.GLSurfaceView$GLThread.guardedRun+2034)
  #10  pc 0x000000000077f9c4  /apex/com.android.art/lib64/libart.so (nterp_helper+3924)
  #11  pc 0x000000000046a00a  /system/framework/framework.jar (android.opengl.GLSurfaceView$GLThread.run+122)
  #12  pc 0x000000000036db74  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+612)
  #13  pc 0x0000000000359324  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+132)
  #14  pc 0x0000000000944438  /apex/com.android.art/lib64/libart.so (art::detail::ShortyTraits<(char)86>::Type art::ArtMethod::InvokeInstance<(char)86>(art::Thread*, art::ObjPtr<art::mirror::Object>, art::detail::ShortyTraits<>::Type...)+60)
  #15  pc 0x00000000006209f4  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+1344)
  #16  pc 0x00000000006204a4  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallbackWithUffdGc(void*)+8)
  #17  pc 0x00000000000fbacc  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+204)
  #18  pc 0x000000000008e670  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)

Solution

  • Finally I fix the problem. Many thanks to @solidpixel for advice. Just added this line:

    surface.setPreserveEGLContextOnPause( true ); // GLSurfaceView