From 9e25e42ceef65b47467860592ae38fb9f03c24df Mon Sep 17 00:00:00 2001 From: thanakij Date: Mon, 23 Sep 2019 05:03:42 +0700 Subject: [PATCH] fix(Android): hardware acceleration issue (#854) * Fix https://github.com/react-native-community/react-native-webview/issues/575 * Check if hardware acceleration is available also * Alternative way to check isHarewareAccelerated --- .../reactnativecommunity/webview/RNCWebViewManager.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java b/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java index 83e2474..0292783 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java +++ b/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java @@ -259,10 +259,13 @@ public class RNCWebViewManager extends SimpleViewManager { @ReactProp(name = "androidHardwareAccelerationDisabled") public void setHardwareAccelerationDisabled(WebView view, boolean disabled) { - if (disabled) { + ReactContext reactContext = (ReactContext) view.getContext(); + final boolean isHardwareAccelerated = (reactContext.getCurrentActivity().getWindow() + .getAttributes().flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0; + if (disabled || !isHardwareAccelerated) { view.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } else { - view.setLayerType(View.LAYER_TYPE_NONE, null); + view.setLayerType(View.LAYER_TYPE_HARDWARE, null); } }