java - 以编程方式获取 GPU 信息有时会给出“createcontext failed egl_bad_alloc”错误
问题描述
我正在尝试以编程方式获取 GPU 信息。实际上我的代码适用于许多设备。但是 firebase 在某些设备上显示错误。错误是这样的。这仅在某些设备上发生,并且所有设备都在 Android 7 Nougat 上。
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();
}
}
解决方案
推荐阅读
- ibm-cloud - IBM Watson Assistent:客户端操作调用以验证槽对话节点内的客户信息
- python - 以下二叉搜索树方法的大O是多少
- jenkins - 如何迭代节点以在 Jenkins Pipeline 中运行命令
- r - R如何在一个表达式中推断变量是数据还是向量?
- java - 如何断言包含的 if 语句
- c++ - 如何使用 FFMPEG 捕获显示并流式传输到 RGB LED 矩阵
- d3.js - 如何在此树形图中包含颜色插值?
- java - 如何设置 Eclipse RCP 插件以使用 JOGL?
- ios - 变量在完成处理程序之外变为 nil
- c++ - 采用 lambda 的模板类的类型推导