我在运行Android 4.4的Posiflex machine上运行我的应用。我的主页是webview(将使用Chromium 30)。有时我的应用程序冻结,logcat显示以下错误
DequeueBufferWrapper: Failed to de-queue buffer
Native window is invalid
在上述错误之后还有一个堆栈跟踪:
ViewRootImpl: Could not lock surface
java.lang.IllegalArgumentException
at android.view.Surface.nativeLockCanvas(Native Method)
at android.view.Surface.lockCanvas(Surface.java:246)
at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2435)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2409)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2253)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1883)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4998)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:811)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:627)
at dalvik.system.NativeStart.main(Native Method)
01-29 00:07:48.092 12167-12167/in.zeta.android.pos.debug E/Surface: dequeueBuffer failed (Invalid argument)
01-29 00:07:48.092 12167-12167/in.zeta.android.pos.debug
E/ViewRootImpl: Could not lock surface
java.lang.IllegalArgumentException
at android.view.Surface.nativeLockCanvas(Native Method)
at android.view.Surface.lockCanvas(Surface.java:246)
at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2435)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2409)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2253)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1883)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4998)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:811)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:627)
at dalvik.system.NativeStart.main(Native Method)
我只是使用此设备,无法控制Surface
或自定义视图的实现方式。有没有针对此问题的解决方法。这样的错误后我的应用程序冻结了。
答案 0 :(得分:0)
在观察到同一错误的几个案例之后,我发现只有在Android Kitkat(Android 4.4)中使用Webview
时才会出现错误,如果您确定只运行应用程序,这是快速解决方案关于Kitkat是关闭硬件加速:
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
但如果你支持不同的版本(其他设备),那么:
if (android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.KITKAT){
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}