一、问题
如题:glUniform3fv 传入的 FloatBuffer 为空时导致异常,报访问的地址为空
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] JNI DETECTED ERROR IN APPLICATION: field operation on NULL object: 0x0
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] in call to GetIntField
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] from void android.opengl.GLES20.glUniform3fv(int, int, java.nio.FloatBuffer)
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] "GLThread 135" prio=5 tid=14 Runnable
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] | group="main" sCount=0 dsCount=0 obj=0x12c34300 self=0x7fab39e20600
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] | sysTid=2860 nice=0 cgrp=default sched=0/0 handle=0x7fab39c3f440
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] | state=R schedstat=( 0 0 0 ) utm=2 stm=1 core=0 HZ=100
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] | stack=0x7fab39b3d000-0x7fab39b3f000 stackSize=1037KB
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] | held mutexes= "mutator lock"(shared held)
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] native: #00 pc 00000000005678e7 /system/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::ArtMethod*, void*)+215)
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] native: #01 pc 0000000000530b30 /system/lib64/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+208)
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] native: #02 pc 000000000039cde9 /system/lib64/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+1177)
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] native: #03 pc 000000000039e4b1 /system/lib64/libart.so (art::JavaVMExt::JniAbortV(char const*, char const*, __va_list_tag*)+97)
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] native: #04 pc 000000000018bb50 /system/lib64/libart.so (art::ScopedCheck::AbortF(char const*, ...)+160)
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] native: #05 pc 0000000000192c25 /system/lib64/libart.so (art::ScopedCheck::CheckInstanceFieldID(art::ScopedObjectAccess&, _jobject*, _jfieldID*)+597)
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] native: #06 pc 0000000000192e7f /system/lib64/libart.so (art::ScopedCheck::CheckFieldAccess(art::ScopedObjectAccess&, _jobject*, _jfieldID*, bool, art::Primitive::Type)+63)
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] native: #07 pc 00000000001a0725 /system/lib64/libart.so (art::CheckJNI::GetField(char const*, _JNIEnv*, _jobject*, _jfieldID*, bool, art::Primitive::Type)+757)
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] native: #08 pc 00000000001a0ed1 /system/lib64/libart.so (art::CheckJNI::GetIntField(_JNIEnv*, _jobject*, _jfieldID*)+33)
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] native: #09 pc 00000000000c0fcc /system/lib64/libandroid_runtime.so (???)
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] native: #10 pc 0000000001219b6e /data/dalvik-cache/x86_64/system@framework@boot.oat (Java_android_opengl_GLES20_glUniform3fv__IILjava_nio_FloatBuffer_2+210)
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] at android.opengl.GLES20.glUniform3fv(Native method)
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] at ly.com.fragment.sample1402.Ball.drawSelf(Ball.java:178)
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] at ly.com.fragment.sample1402.Fragment1402SurfaceView$SceneRenderer.onDrawFrame(Fragment1402SurfaceView.java:60)
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1535)
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410] at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
12-11 09:38:17.895 2831-2860/ly.com.opengles A/art: art/runtime/java_vm_ext.cc:410]
二、原因以及解决
检查 glUniform3fv 的第三个参数 FloatBuffer 是否为空指针即可。
网友评论