react-native-video: IOS Memory Leak
Bug
Platform
Which player are you experiencing the problem on:
- iOS
Environment info
Library version: 6.0.0-beta.0 Device: iPhone 14 Pro Max (Emulator)
Steps To Reproduce
- Show video component with an online video (in the example i am using the following 30mb sample video: https://sample-videos.com/video123/mp4/480/big_buck_bunny_480p_30mb.mp4)
- Unmount the video component
- Re-Mount the component
- The Memory usage of the app grows by about the size of the video in my case, and keeps growing with each repeat
- Profiling also seems to report several memory leaks, with most of the extra memory allocation going into
VM: CoreMedia HTTP cache
Expected behaviour
- Video data is cleared from memory whenever the
Videocomponent is unmounted
Reproducible sample code
Full repo here: Clean RN init + RNVideo@6.0.0-beta.0 install only
import React, {useState} from 'react';
import {SafeAreaView, TouchableOpacity, Text, View} from 'react-native';
import Video from 'react-native-video';
function App() {
const [hidden, setHidden] = useState(false);
return (
<SafeAreaView style={{flex: 1}}>
<View style={{height: 300, width: '100%'}}>
{!hidden && (
<Video
style={{height: 300, width: '100%'}}
source={{
uri: 'https://sample-videos.com/video123/mp4/480/big_buck_bunny_480p_30mb.mp4',
}}
controls
paused={false}
/>
)}
</View>
<TouchableOpacity
style={{padding: 20, backgroundColor: hidden ? 'red' : 'green'}}
onPress={() => setHidden(!hidden)}>
<Text>Video: {hidden ? 'Unmounted' : 'Mounted'}</Text>
</TouchableOpacity>
</SafeAreaView>
);
}
export default App;
Video sample
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 13
- Comments: 18
Happening to me too. 😕 +1
Should be fixed with
6.0.0-beta.5, feel free to repo if it doesn’tThe same with FeedScreen using FlatList, try alpha 7 version work perfect, waiting for new update
It works! Thanks a lot