Skip to content

Commit

Permalink
fix: Workaround Android 12 webview crash (#42517)
Browse files Browse the repository at this point in the history
* fix: Workaround Android 12 webview crash

A crash occurred due to combining webviews with Android 12's new scroll
overflow behavior. Applying `opacity: 0.99` prevents the crash from
occurring. This change should be viewed as a temporary fix while we
await a more appropriate solution for the `react-native-webview`
library.

react-native-webview/react-native-webview#1915 (comment)

* docs: Add change log entry
  • Loading branch information
dcalhoun authored Jul 19, 2022
1 parent 44131df commit c92be64
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/components/src/sandbox/index.native.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/**
* External dependencies
*/
import { Dimensions, Platform } from 'react-native';
import { Dimensions, StyleSheet } from 'react-native';
import { WebView } from 'react-native-webview';

/**
* WordPress dependencies
*/
import {
Platform,
renderToString,
memo,
useRef,
Expand Down Expand Up @@ -307,6 +308,7 @@ function Sandbox( {
style={ [
sandboxStyles[ 'sandbox-webview__content' ],
getSizeStyle(),
Platform.isAndroid && workaroundStyles.webView,
] }
onMessage={ checkMessageForResize }
scrollEnabled={ false }
Expand All @@ -317,4 +319,15 @@ function Sandbox( {
);
}

const workaroundStyles = StyleSheet.create( {
webView: {
/**
* The slight opacity below is a workaround for an Android crash caused from combining Android
* 12's new scroll overflow behavior and webviews.
* https://github.com/react-native-webview/react-native-webview/issues/1915#issuecomment-808869253
*/
opacity: 0.99,
},
} );

export default memo( Sandbox );
1 change: 1 addition & 0 deletions packages/react-native-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ For each user feature we should also add a importance categorization label to i

- [*] Add React Native FastImage [#42009]
- [*] Block inserter displays block collections [#42405]
- [**] Fix a crash when scrolling posts containing Embed blocks (Android 12 only) [#42514]

## 1.79.0
- [*] Add 'Insert from URL' option to Video block [#41493]
Expand Down

0 comments on commit c92be64

Please sign in to comment.