Skip to content

Commit c92be64

Browse files
authored
fix: Workaround Android 12 webview crash (#42517)
* 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
1 parent 44131df commit c92be64

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/components/src/sandbox/index.native.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
/**
22
* External dependencies
33
*/
4-
import { Dimensions, Platform } from 'react-native';
4+
import { Dimensions, StyleSheet } from 'react-native';
55
import { WebView } from 'react-native-webview';
66

77
/**
88
* WordPress dependencies
99
*/
1010
import {
11+
Platform,
1112
renderToString,
1213
memo,
1314
useRef,
@@ -307,6 +308,7 @@ function Sandbox( {
307308
style={ [
308309
sandboxStyles[ 'sandbox-webview__content' ],
309310
getSizeStyle(),
311+
Platform.isAndroid && workaroundStyles.webView,
310312
] }
311313
onMessage={ checkMessageForResize }
312314
scrollEnabled={ false }
@@ -317,4 +319,15 @@ function Sandbox( {
317319
);
318320
}
319321

322+
const workaroundStyles = StyleSheet.create( {
323+
webView: {
324+
/**
325+
* The slight opacity below is a workaround for an Android crash caused from combining Android
326+
* 12's new scroll overflow behavior and webviews.
327+
* https://github.com/react-native-webview/react-native-webview/issues/1915#issuecomment-808869253
328+
*/
329+
opacity: 0.99,
330+
},
331+
} );
332+
320333
export default memo( Sandbox );

packages/react-native-editor/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ For each user feature we should also add a importance categorization label to i
1313

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

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

0 commit comments

Comments
 (0)