Crash when used with react-navigation
- The YoutubePlayer causes a crash immediately on navigating to another screen, and also sometimes when navigating to the screen that contains the component.
- crashes are observed only on android
- only some android versions have this issue (likely tied to google chrome version)
info
This will happen if you have any webviews inside a screen.
This is not exclusive to the youtube player.
#
SolutionsPick one that fits your need
Don't try to implement ALL of them.
#
1. Tweak react-navigation configdocumentation)#
use a transition animations that only involves translations. (<Stack.Screen component={ScreenWithWebview} options={{ cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS, }}/>
documentation)#
disable transition animations on screens that have the youtube player. (<Stack.Screen component={ScreenWithWebview} options={{ animationEnabled: false, }}/>
#
2. Tweak webview props0.99
(issue comment)#
change webview opacity to <YoutubePlayer webViewStyle={{opacity: 0.99}} // {...otherProps}/>
renderToHardwareTextureAndroid
(issue comment)#
set <YoutubePlayer webViewProps={{ renderToHardwareTextureAndroid: true, }} // {...otherProps}/>
androidLayerType
(issue comment)#
tweak <YoutubePlayer webViewProps={{ androidLayerType: Platform.OS === 'android' && Platform.Version <= 22 ? 'hardware' : 'none', }} // {...otherProps}/>
#
github threads to follow#
should the library handle this?no.
All these are workarounds, and it's the responsibility of core libraries to fix the root cause.