Skip to content

Commit 7a38b23

Browse files
committed
docs: add docs addressing crashes caused by webview during navigation
closes #154
1 parent 54f81db commit 7a38b23

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed

docs/navigation-crash.mdx

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
id: navigation-crash
3+
title: Crash when used with react-navigation
4+
---
5+
6+
The YoutubePlayer causes a crash immediately on navigating to another screen, and also sometimes when navigating to the screen that contains the component.
7+
8+
:::info
9+
This will happen if you have any webviews inside a screen.
10+
11+
This is not exclusive to the youtube player.
12+
:::
13+
14+
## Solutions
15+
16+
:::tip Pick one that fits your need
17+
Don't try to implement ALL of them.
18+
:::
19+
20+
### 1. Tweak react-navigation config
21+
22+
#### use a transition animations that only involves translations. ([documentation](https://reactnavigation.org/docs/stack-navigator/#pre-made-configs))
23+
24+
```jsx
25+
<Stack.Screen
26+
component={ScreenWithWebview}
27+
options={{
28+
cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS,
29+
}}
30+
/>
31+
```
32+
33+
#### disable transition animations on screens that have the youtube player. ([documentation](https://reactnavigation.org/docs/stack-navigator/#animationenabled))
34+
35+
```jsx
36+
<Stack.Screen
37+
component={ScreenWithWebview}
38+
options={{
39+
animationEnabled: false,
40+
}}
41+
/>
42+
```
43+
44+
### 2. Tweak webview props
45+
46+
#### change webview opacity to `0.99` ([issue comment](https://github.com/LonelyCpp/react-native-youtube-iframe/issues/110#issuecomment-779848787))
47+
48+
```jsx
49+
<YoutubePlayer
50+
webViewStyle={{opacity: 0.99}}
51+
//
52+
{...otherProps}
53+
/>
54+
```
55+
56+
#### set `renderToHardwareTextureAndroid` ([issue comment](https://github.com/react-native-webview/react-native-webview/issues/811#issuecomment-748611465))
57+
58+
```jsx
59+
<YoutubePlayer
60+
webViewProps={{
61+
renderToHardwareTextureAndroid: true,
62+
}}
63+
//
64+
{...otherProps}
65+
/>
66+
```
67+
68+
#### tweak `androidLayerType` ([issue comment](https://github.com/LonelyCpp/react-native-youtube-iframe/issues/110#issuecomment-786603325))
69+
70+
```jsx
71+
<YoutubePlayer
72+
webViewProps={{
73+
androidLayerType:
74+
Platform.OS === 'android' && Platform.Version <= 22 ? 'hardware' : 'none',
75+
}}
76+
//
77+
{...otherProps}
78+
/>
79+
```
80+
81+
### github threads to follow
82+
83+
- [issue #110](https://github.com/LonelyCpp/react-native-youtube-iframe/issues/110)
84+
- [issue #101](https://github.com/LonelyCpp/react-native-youtube-iframe/issues/101)
85+
- [rn-webview issue #811](https://github.com/react-native-webview/react-native-webview/issues/811)

website/sidebars.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ module.exports = {
77
'module-methods',
88
'self-host-remote-source',
99
],
10-
FAQ: ['play-store-compatibility', 'remove-context-share', 'elapsed-time'],
10+
FAQ: [
11+
'play-store-compatibility',
12+
'remove-context-share',
13+
'elapsed-time',
14+
'navigation-crash',
15+
],
1116
},
1217
};

0 commit comments

Comments
 (0)