Sfoglia il codice sorgente

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 4 anni fa
parent
commit
9e25e42cee

+ 5
- 2
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java Vedi File

259
 
259
 
260
   @ReactProp(name = "androidHardwareAccelerationDisabled")
260
   @ReactProp(name = "androidHardwareAccelerationDisabled")
261
   public void setHardwareAccelerationDisabled(WebView view, boolean disabled) {
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
       view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
266
       view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
264
     } else {
267
     } else {
265
-      view.setLayerType(View.LAYER_TYPE_NONE, null);
268
+      view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
266
     }
269
     }
267
   }
270
   }
268
 
271