UI frame drop while loading (initial buffer) the video
See original GitHub issueBug
The main UI thread is being blocked by loading the video in the initial buffer, causing the UI to drop to 5-20 fps.
Platform
Which player are you experiencing the problem on:
- iOS
Environment info
React native info output:
System:
OS: macOS 12.4
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 315.81 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 8.5.5 - ~/.nvm/versions/node/v16.15.0/bin/npm
Watchman: 2022.05.16.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.2 - /Users/matin/.rvm/gems/ruby-3.0.2/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK:
API Levels: 28, 29, 30, 31
Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0, 31.0.0
System Images: android-27 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play ARM 64 v8a, android-30 | Google Play Intel x86 Atom, android-30 | Google Play Intel x86 Atom_64, android-31 | Google APIs Intel x86 Atom_64, android-S | Google Play Intel x86 Atom_64
Android NDK: 23.0.7344513-beta4
IDEs:
Android Studio: 4.2 AI-202.7660.26.42.7351085
Xcode: 13.3/13E113 - /usr/bin/xcodebuild
Languages:
Java: 11.0.10 - /usr/local/opt/openjdk@11/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.68.2 => 0.68.2
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
info React Native v0.69.0 is now available (your project is running on v0.68.2).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.69.0.
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.68.2.
info To upgrade, run "react-native upgrade".
Library version: https://github.com/react-native-video/react-native-video.git#054abcac8e1dcb738b0b679f8b496474f8a159e5
Steps To Reproduce
- Create a list of items with FlatList
- Load the video when item is viewable
- Try scrolling
Expected behaviour
- Not having frame drop
Reproducible sample code
interface Props extends VideoProperties {
isInViewport: boolean
autoPlay?: boolean
}
export const VideoPlayer = ({
isInViewport = false,
autoPlay = false,
source,
...rest
}: Props) => {
const {ref, ...player} = useVideoPlayer(isInViewport, autoPlay)
return (
<Pressable onPress={() => {}}>
{isInViewport && (
<Video
{...rest}
style={[styles.video, rest.style]}
source={source}
resizeMode={'contain'}
playInBackground={false}
playWhenInactive={false}
ignoreSilentSwitch={'ignore'}
ref={ref}
paused={player.paused}
muted={player.muted}
onProgress={player.onProgress}
/>
)}
{!isInViewport && (
<Image
source={{uri: rest.poster}}
resizeMode={'contain'}
style={styles.video}
/>
)}
<VideoOverlay {...player} />
</Pressable>
)
}
Screen record
https://drive.google.com/file/d/1O-S3wdNHIk_somhq-bSwDwaZ3HiAVR8A/view?usp=sharing
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:14 (3 by maintainers)
Top Results From Across the Web
Frame Drop issue with video playback - android - Stack Overflow
I'm seeing 180ms between the arrival of frames on the SurfaceView BufferQueue, which is about 5.5fps. There's some long onVideoEvent sections in ......
Read more >Ridiculous FPS drops : r/Overwatch - Reddit
While I was able to have minimum 160 FPS in OW1 - OW2 gives me really bad FPS drops, like below 10 even...
Read more >Slow rendering - Android Developers
If your app suffers from slow UI rendering, then the system is forced to skip frames and the user will perceive stuttering in...
Read more >Swapchains and frame pacing | Raph Levien's blog
I'm starting to collect performance measurements of piet-gpu running ... to use a deeper buffer to minimize the chance of a dropped frame)....
Read more >Troubleshooting issues related to playback and performance ...
Media Cache contains the.CFA and.PEK files that are generated by Premiere Pro while importing clips for the first time in Project bin. Clearing ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I am having same issue in iOS with version 6.0.0-alpha.2. When Video player is rendered application UI is blocked until video from external url is loaded which was not the case with version 5.2.0. On Android it works fine.
UPDATE I have managed to get this working by changing way of assigning AVPlayer in RCTVideo.swift.
In function setSrc() changing line 267
self._player = AVPlayer(playerItem: self._playerItem)to
seems to fix this issue.
@sperko00 can you open a PR please ? Thank you