Java 通过编程获取GPU信息有时会给出;createcontext失败egl“u bad”u alloc“;错误

Java 通过编程获取GPU信息有时会给出;createcontext失败egl“u bad”u alloc“;错误,java,android,opengl-es,gpu,Java,Android,Opengl Es,Gpu,我试图以编程方式获取GPU信息。实际上,我的代码在许多设备上都能工作。但firebase在某些设备上显示错误。错误是这样的。这只发生在一些设备上,并且所有设备都在安卓7牛轧糖上 Fatal Exception: java.lang.RuntimeException: createContext failed: EGL_BAD_ALLOC at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.jav

我试图以编程方式获取GPU信息。实际上,我的代码在许多设备上都能工作。但firebase在某些设备上显示错误。错误是这样的。这只发生在一些设备上,并且所有设备都在安卓7牛轧糖上

Fatal Exception: java.lang.RuntimeException: createContext failed: EGL_BAD_ALLOC
   at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:1209)
   at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:1200)
   at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:1050)
   at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1410)
   at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1257)
我不知道如何修正这个错误。有人能指导我修正这个错误吗

这是我的密码

public class SplashActivity extends Activity implements GLSurfaceView.Renderer {
private final Globals globals = Globals.getInstance();
private GLSurfaceView glSurfaceView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    TextView txtGPUsupport = findViewById(R.id.txtGPUsupport);
    txtGPUsupport.setText(R.string.GPUVendor);
    glSurfaceView = new GLSurfaceView(this);
    glSurfaceView.setRenderer(this);
    ((ViewGroup) txtGPUsupport.getParent()).addView(glSurfaceView);
}

@Override
protected void onPause() {
    super.onPause();
    if (glSurfaceView != null) {
        glSurfaceView.onPause();
    }
}

@Override
protected void onResume() {
    super.onResume();
    if (glSurfaceView != null) {
        glSurfaceView.onResume();
    }
}

@Override
public void onDrawFrame(GL10 gl) {

}

@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {

}

@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    try {
        runOnUiThread(() -> glSurfaceView.setVisibility(View.GONE));
        globals.setGpuRenderer(gl.glGetString(GL10.GL_RENDERER));
        globals.setGpuVendor(gl.glGetString(GL10.GL_VENDOR));
        globals.setGpuVersion(gl.glGetString(GL10.GL_VERSION));
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
只需使用搜索: