mirror of
https://github.com/status-im/react-native-webview.git
synced 2025-02-22 16:58:34 +00:00
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
This commit is contained in:
parent
a2440f0491
commit
9e25e42cee
@ -259,10 +259,13 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user