问题描述:
项目里需要嵌入YouTube视频,所以用到了react-native-youtube-iframe。然后页面在android上进行页面跳转时偶尔会出现闪退,因为页面里也用到了webview,所以一开始没发现react-native-youtube-iframe也用到了webview…
总结: 在页面跳转时,react-navigation 会为整个屏幕(包括 webview,并且仅在 android 中)的不透明度设置动画并迅速使其崩溃。
解决方法:
方法1.设置webview的不透明度
<YoutubePlayer
...
webViewStyle={ {opacity:0.99} }
/>
方法2.关闭屏幕的导航动画
navigationOptions: { animationEnabled: false }
详情参考:
https://github.com/LonelyCpp/react-native-youtube-iframe/issues/110
WebView recently started crashing on Android on some devices #430