Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: IOS- keeps buffering #3675

Open
rohankm opened this issue Apr 11, 2024 · 33 comments
Open

[BUG]: IOS- keeps buffering #3675

rohankm opened this issue Apr 11, 2024 · 33 comments
Labels
bug demo requested Please submit a simple app that shows the issue

Comments

@rohankm
Copy link

rohankm commented Apr 11, 2024

Version

v6 (Beta)

What platforms are you having the problem on?

iOS

Architecture

Old architecture

What happened?

After seeking the hls video in ios is just stuck buffering and never plays back.

Reproduction

repository link

Reproduction

Step to reproduce this bug are:

@rohankm rohankm added the bug label Apr 11, 2024
@freeboub
Copy link
Collaborator

Any way to reproduce? Are you able to reproduce with the sample included in the repo ?

@freeboub freeboub added the demo requested Please submit a simple app that shows the issue label Apr 12, 2024
@rohankm
Copy link
Author

rohankm commented Apr 12, 2024

Any way to reproduce? Are you able to reproduce with the sample included in the repo ?

Hi, I'm working with Fairplay DRM.. I'm not quite sure how to send a reproducible example

@rohankm rohankm changed the title [BUG]: IOS- keeps buffering on seek [BUG]: IOS- keeps buffering Apr 12, 2024
@rohankm
Copy link
Author

rohankm commented Apr 13, 2024

video with lesser duration plays fine but not with more duration(30 mins +). The player is stuck buffering

@rohankm
Copy link
Author

rohankm commented May 1, 2024

the issue still persists in the latest version

@rohankm
Copy link
Author

rohankm commented May 15, 2024

@freeboub the issue still exists for the DRM videos on ios... videos without DRM work fine.

@freeboub
Copy link
Collaborator

Not sure how we can help here ...
Do you have issues in xcode logs ? Did you try to record a charles trace to ensure network communications work fine ?

@rohankm
Copy link
Author

rohankm commented May 15, 2024

@freeboub the network communication is fine and there are no xcode logs.. it's just the video buffers forever. {"isBuffering": true, "target": 6819}

Im currently testing with ios 14.8

@rohankm
Copy link
Author

rohankm commented May 16, 2024

@freeboub I tested on a newer device with the latest ios but the problem still exists... probably can we connect on discord and I will share the DRM content so that you can check it from your end also.

@rohankm
Copy link
Author

rohankm commented May 16, 2024

adding maxBitRate={3000000} the video loads perfectly

@KrzysztofMoch
Copy link
Collaborator

So probably not an library issue ?

@rohankm
Copy link
Author

rohankm commented May 17, 2024

So probably not an library issue ?

I really don't understand what exactly is the issue.. or how do I even debug the issue

@KrzysztofMoch
Copy link
Collaborator

Maybe I will add to docs (in debug section) to try set maxBitRate in such case - let's close this as I see that this worked for you

@rohankm
Copy link
Author

rohankm commented May 18, 2024

setting maxBitRate={0} also works fine

@rohankm rohankm closed this as completed May 18, 2024
@rohankm
Copy link
Author

rohankm commented May 20, 2024

@freeboub @KrzysztofMoch reopening the issue as setting maxBitRate just lowers the video quality. Also, i tested with expo-video and it works fine... I don't know what the issue is with react-native-video with DRM videos. Is there any steps to debug this buffering issue?

@rohankm rohankm reopened this May 20, 2024
@Meet-Kapadiya
Copy link

Same problem still persists in 6.2.0, You can check by logging "isBuffering", It never returns false

@Meet-Kapadiya
Copy link

 useEffect(() => {
    if (Platform.OS === 'ios' && loading) {
      setTimeout(() => {
        setLoading(false);
      }, 2500);
    }
  }, [loading]);

For temporary workaround you can do this

@rohankm
Copy link
Author

rohankm commented May 24, 2024

We cannot use this hack in production... The bug should be fixed

@freeboub
Copy link
Collaborator

If you want to investigate here are some inputs:
handlePlaybackBufferKeyEmpty and handlePlaybackLikelyToKeepUp are good starting points.
relevant documentation is here: https://developer.apple.com/documentation/avfoundation/avplayeritem/1390348-isplaybacklikelytokeepup

@Meet-Kapadiya
Copy link

react-native-video+6.1.2.patch

I made the patch, it works fine, but at the beginning when I start playing the video, the buffering takes time to return false is proportional to the length of the video.

@rohankm
Copy link
Author

rohankm commented May 24, 2024

@Meet-Kapadiya are you testing with drm videos or normal?

@Meet-Kapadiya
Copy link

HLS streams

@Meet-Kapadiya
Copy link

react-native-video+6.1.2.patch

I made the patch, it works fine, but at the beginning when I start playing the video, the buffering takes time to return false is proportional to the length of the video.

To solve this you can set

  • preferredForwardBufferDuration={15} (In Seconds)
  • Default value is 0, So player will choose an appropriate level of buffering

@maksymhcode-care
Copy link

It seems that it only happens with HLS/m3u8 format, please take a look at that @freeboub

@suritkandel
Copy link

suritkandel commented Jun 11, 2024

The MPEG-TS & m3u8 video does not work at all but for HLS the video works for 30 seconds and you get a error.

HLS Error at 30 seconds:
{"error": {"code": -12312, "domain": "CoreMediaErrorDomain", "localizedDescription": "The operation couldn’t be completed. (CoreMediaErrorDomain error -12312.)", "localizedFailureReason": "", "localizedRecoverySuggestion": ""}, "target": 10675} error

Let me know if you need a url to try to replicate this? @freeboub

I appreciate your help.

Video Code Below:
<Video
paused={paused}
source={{
uri: url,
}}
onLoadStart={() => setIsLoading(true)}
onLoad={() => setIsLoading(false)}
ref={ref}
fullscreen={fullScreen ? true : false}
bufferConfig={bufferConfig}
// bufferConfig={{
// minBufferMs: 15000, // Minimum buffer in milliseconds
// // maxBufferMs: calculateBufferSize(1000000), // Maximum buffer size based on bitrate
// maxBufferMs: 50000,
// bufferForPlaybackMs: 5000, // Buffer needed for playback start
// bufferForPlaybackAfterRebufferMs: 20000, // Buffer needed after rebuffering
// }}
preferredForwardBufferDuration={15}
selectedVideoTrack={{
type: 'resolution',
value: 1080,
}}
onProgress={handleProgress}
// onError={handleVideoError}
style={{width: '100%', height: fullScreen ? '100%' : 250}}
resizeMode={fullScreen ? 'cover' : 'contain'}
playInBackground={true}
pictureInPicture={true}
muted={mute}
fullscreenAutorotate={true}
ignoreSilentSwitch={'ignore'}
minLoadRetryCount={5} // retry 5 times
mixWithOthers={'duck'}
/>

 Example Video Below:
 https://github.com/TheWidlarzGroup/react-native-video/assets/123834956/ad208e09-5bc0-4f60-8725-652cefd8e535

@maksymhcode-care
Copy link

@freeboub @KrzysztofMoch Please try any m3u8/hls test url you prefer. onBuffer will return true even if video is playing
https://ottverse.com/free-hls-m3u8-test-urls/

@edenmoyal1
Copy link

It happens to me too.
I used onPlaybackStateChanged and set isBuffering to false when the video is playing.

@maksymhcode-care
Copy link

It happens to me too. I used onPlaybackStateChanged and set isBuffering to false when the video is playing.

But what if video is playing and buffering at the same time?

@maksymhcode-care
Copy link

It's a work around, but i can suggest to try this:

const onPlaybackStateChanged = ({ isPlaying }) => { setIsLoading(!isPaused.current && !isPlaying); };

Basically isPlaying from onPlaybackStateChanged return false, but you did not paused the video it means it's loading

@rohankm
Copy link
Author

rohankm commented Aug 24, 2024

@moskalakamil can you help me debug the issue? there are no error logs... it's just the video keeps on buffering at random spots... especially with longer-length videos

@moskalakamil
Copy link
Member

@freeboub the issue still exists for the DRM videos on ios... videos without DRM work fine.

Hi @rohankm, could you please check the changes from #4136? If the issue is related to DRM, it has been rewritten there.

@rohankm
Copy link
Author

rohankm commented Sep 2, 2024

@freeboub the issue still exists for the DRM videos on ios... videos without DRM work fine.

Hi @rohankm, could you please check the changes from #4136? If the issue is related to DRM, it has been rewritten there.

Hi sure I'm checking it..

@rohankm
Copy link
Author

rohankm commented Sep 2, 2024

@freeboub the issue still exists for the DRM videos on ios... videos without DRM work fine.

Hi @rohankm, could you please check the changes from #4136? If the issue is related to DRM, it has been rewritten there.

@moskalakamil @KrzysztofMoch thank you so much for the rewrite... the videos that used to be stuck buffering on seek seem to play seamlessly now.. probably this issue is solved. I will be testing it for a day more and let you know the updates.

@moskalakamil
Copy link
Member

Sure! Kudos to @KrzysztofMoch for rewriting it. It’s great to hear that it solved your issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug demo requested Please submit a simple app that shows the issue
Projects
None yet
Development

No branches or pull requests

8 participants