2012-01-05 84 views
2

通過Android市場,對於我的應用程序用戶報告了大量的不受支持的操作異常。堆棧跟蹤指向從webview代碼內部進行的drawPicture()調用。我確實在我的應用中使用了網頁瀏覽。Android硬件加速webview崩潰

我知道在HWA打開時不支持drawPicture(),但在這種情況下,調用來自webview內部。我需要採取哪些特殊步驟來確保webview不會使用此方法?

不幸的是,我一直無法重現這個問題,但肯定會被用戶看到。

堆棧跟蹤:

java.lang.UnsupportedOperationException 
at android.view.GLES20Canvas.drawPicture(GLES20Canvas.java:753) 
at android.webkit.WebView.drawCoreAndCursorRing(WebView.java:4128) 
at android.webkit.WebView.drawContent(WebView.java:3797) 
at android.webkit.WebView.onDraw(WebView.java:3862) 
at android.view.View.draw(View.java:9286) 
at android.view.View.getDisplayList(View.java:8749) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2554) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2189) 
at android.view.View.getDisplayList(View.java:8747) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2554) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2189) 
at android.view.View.draw(View.java:9289) 
at android.view.View.getDisplayList(View.java:8749) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2554) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2189) 
at android.view.View.getDisplayList(View.java:8747) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2554) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2189) 
at android.view.View.getDisplayList(View.java:8747) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2554) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2189) 
at android.view.View.draw(View.java:9289) 
at android.widget.FrameLayout.draw(FrameLayout.java:419) 
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1923) 
at android.view.View.getDisplayList(View.java:8749) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2554) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2189) 
at android.view.View.getDisplayList(View.java:8747) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2554) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2189) 
at android.view.View.draw(View.java:9289) 
at android.view.View.getDisplayList(View.java:8749) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2554) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2189) 
at android.view.View.getDisplayList(View.java:8747) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2554) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2189) 
at android.view.View.getDisplayList(View.java:8747) 
at android.view.ViewGroup.drawChild(ViewGroup.java:2554) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2189) 
at android.view.View.draw(View.java:9289) 
at android.widget.FrameLayout.draw(FrameLayout.java:419) 
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1923) 
at android.view.View.getDisplayList(View.java:8749) 
at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:609) 
at android.view.ViewRoot.draw(ViewRoot.java:1600) 
at android.view.ViewRoot.performTraversals(ViewRoot.java:1416) 
at android.view.ViewRoot.handleMessage(ViewRoot.java:2046) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:132) 
at android.app.ActivityThread.main(ActivityThread.java:4123) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:491) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) 
at dalvik.system.NativeStart.main(Native Method) 
+3

這是一個有趣的錯誤。當WebView在硬件加速畫布上繪製時,它不使用drawPicture(),而是使用完全不同的代碼路徑。如果您能夠提出一個重複案例,請將其發送給我,我會將其轉發給WebView團隊。 – 2012-01-05 23:00:22

+0

不知道爲什麼這是downvoted ... – BeRecursive 2012-01-05 23:02:45

回答

1

是否使用restorePicture? (http://developer.android.com/reference/android/webkit/WebView.html#restorePicture(android.os.Bundle,java.io.File))

該方法不支持硬件加速(並且該方法已被棄用,所以您應該放棄它)。作爲一種解決方法,您可以將webview設置爲軟件層,直到您加載其他內容爲止。

+0

我正在使用restorePicture(),所以也許這是根本原因。該代碼路徑並沒有爲我執行,但它可能會在某些特定情況下執行(例如,設備上的內存不足)。我會繼續測試,看看是否刪除restorePicture()有幫助。 – 2012-01-06 19:02:19