我们正致力于通过texureview
展示需要硬件加速的视频。
一切都很好,生活很幸福,直到我们解决这个问题。
这是崩溃堆栈信息:
12-25 19:49:24.951 E/SurfaceTexture( 6432): [unnamed-6432-2](this:0x605`enter code here`b5620,api:0) **detachFromContext: invalid current EGLContext** 12-25 19:49:24.951 D/AndroidRuntime( 6432): Shutting down VM 12-25 19:49:24.951 W/dalvikvm( 6432): threadid=1: thread exiting with uncaught exception (group=0x41a719a8) 12-25 19:49:24.964 W/System.err( 6432): java.lang.RuntimeException: Error during detachFromGLContext (see logcat for details) 12-25 19:49:24.964 W/System.err( 6432): at android.graphics.SurfaceTexture.detachFromGLContext(SurfaceTexture.java:217) 12-25 19:49:24.964 W/System.err( 6432): at android.view.TextureView.destroySurface(TextureView.java:226) 12-25 19:49:24.964 W/System.err( 6432): at android.view.TextureView.access$000(TextureView.java:105) 12-25 19:49:24.964 W/System.err( 6432): at android.view.TextureView$1.run(TextureView.java:214) 12-25 19:49:24.964 W/System.err( 6432): at android.view.HardwareRenderer$Gl20Renderer.safelyRun(HardwareRenderer.java:1605) 12-25 19:49:24.964 W/System.err( 6432): at android.view.TextureView.onDetachedFromWindow(TextureView.java:211) 12-25 19:49:24.964 W/System.err( 6432): at android.view.View.dispatchDetachedFromWindow(View.java:12039) 12-25 19:49:24.964 W/System.err( 6432): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2616) 12-25 19:49:24.964 W/System.err( 6432): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2616) 12-25 19:49:24.964 W/System.err( 6432): at android.view.ViewGroup.removeDetachedView(ViewGroup.java:3940) 12-25 19:49:24.964 W/System.err( 6432): at android.widget.AbsListView.access$5900(AbsListView.java:102) 12-25 19:49:24.964 W/System.err( 6432): at android.widget.AbsListView$RecycleBin.clear(AbsListView.java:6875) 12-25 19:49:24.964 W/System.err( 6432): at android.widget.AbsListView.onDetachedFromWindow(AbsListView.java:2720) 12-25 19:49:24.965 W/System.err( 6432): at android.view.View.dispatchDetachedFromWindow(View.java:12039) 12-25 19:49:24.965 W/System.err( 6432): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2618) 12-25 19:49:24.965 W/System.err( 6432): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2616) 12-25 19:49:24.965 W/System.err( 6432): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2616) 12-25 19:49:24.965 W/System.err( 6432): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2616) 12-25 19:49:24.965 W/System.err( 6432): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2616) 12-25 19:49:24.965 W/System.err( 6432): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2616) 12-25 19:49:24.965 W/System.err( 6432): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2616) 12-25 19:49:24.965 W/System.err( 6432): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2616) 12-25 19:49:24.965 W/System.err( 6432): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2616) 12-25 19:49:24.965 W/System.err( 6432): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2616) 12-25 19:49:24.965 W/System.err( 6432): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2616) 12-25 19:49:24.966 W/System.err( 6432): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2616) 12-25 19:49:24.966 W/System.err( 6432): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:2616) 12-25 19:49:24.966 W/System.err( 6432): at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:2958) 12-25 19:49:24.966 W/System.err( 6432): at android.view.ViewRootImpl.doDie(ViewRootImpl.java:4557) 12-25 19:49:24.966 W/System.err( 6432): at android.view.ViewRootImpl.die(ViewRootImpl.java:4538) 12-25 19:49:24.966 W/System.err( 6432): at android.view.WindowManagerGlobal.removeViewLocked(WindowManagerGlobal.java:338) 12-25 19:49:24.966 W/System.err( 6432): at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:288) 12-25 19:49:24.966 W/System.err( 6432): at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:84) 12-25 19:49:24.966 W/System.err( 6432): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3662) 12-25 19:49:24.967 W/System.err( 6432): at android.app.ActivityThread.access$1200(ActivityThread.java:156) 12-25 19:49:24.967 W/System.err( 6432): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1395) 12-25 19:49:24.967 W/System.err( 6432): at android.os.Handler.dispatchMessage(Handler.java:99) 12-25 19:49:24.967 W/System.err( 6432): at android.os.Looper.loop(Looper.java:153) 12-25 19:49:24.967 W/System.err( 6432): at android.app.ActivityThread.main(ActivityThread.java:5338) 12-25 19:49:24.967 W/System.err( 6432): at java.lang.reflect.Method.invokeNative(Native Method) 12-25 19:49:24.967 W/System.err( 6432): at java.lang.reflect.Method.invoke(Method.java:511) 12-25 19:49:24.967 W/System.err( 6432): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 12-25 19:49:24.967 W/System.err( 6432): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 12-25 19:49:24.968 W/System.err( 6432): at dalvik.system.NativeStart.main(Native Method)
从上面的信息中我们发现SurfaceTexture.cpp
if (mEglContext != ctx && mEglContext != EGL_NO_CONTEXT) {
ST_LOGE("detachFromContext: invalid current EGLContext");
return INVALID_OPERATION;
}
我们通过listview
使用缓存的textureview,但我们不知道这是否是问题所在。我们不擅长OpenGL
,我们对硬件加速的机制知之甚少。
有人可以帮忙吗?