Pārlūkot izejas kodu

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
thanakij 5 gadus atpakaļ
vecāks
revīzija
9e25e42cee

+ 5
- 2
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java Parādīt failu

@@ -259,10 +259,13 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
259 259
 
260 260
   @ReactProp(name = "androidHardwareAccelerationDisabled")
261 261
   public void setHardwareAccelerationDisabled(WebView view, boolean disabled) {
262
-    if (disabled) {
262
+    ReactContext reactContext = (ReactContext) view.getContext();
263
+    final boolean isHardwareAccelerated = (reactContext.getCurrentActivity().getWindow()
264
+        .getAttributes().flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0;
265
+    if (disabled || !isHardwareAccelerated) {
263 266
       view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
264 267
     } else {
265
-      view.setLayerType(View.LAYER_TYPE_NONE, null);
268
+      view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
266 269
     }
267 270
   }
268 271