TheWidlarzGroup / react-native-video

A <Video /> component for react-native
http://thewidlarzgroup.github.io/react-native-video/
MIT License
7.16k stars 2.88k forks source link

[BUG]: DVR HLS livestream in background buffers differently than in foreground on Android #4026

Closed paulrinaldi closed 2 months ago

paulrinaldi commented 2 months ago

Version

6.4.2

What platforms are you having the problem on?

Android

System Version

14

On what device are you experiencing the issue?

Real device, Simulator

Architecture

Old architecture

What happened?

When in background, the buffering behavior I see for a livestream I have ('https://democracynow-hls.secdn.net/democracynow-live/play/democracynow.smil/playlist.m3u8' active between 8am-9am weekdays Eastern Time (i.e. NY, USA) on the notification media control on Android is not the same as when in the foreground. Specifically, I've noticed the livestream not buffer until the current time meets the currently shown duration in the notification. Sometimes I repeatedly hit the forward button and that can also force the player while in the background to buffer forever.

In the example from red bull, the duration continually updates with more time and it's impossible seemingly to get it into a state where it's always buffering and the player is stopped. I really like that. That's what I'd want my livestream to be like so I set the bufferconfig to be the same as in the example (see below). In 5.2.0, this behavior is what I saw in my app.

With the livestream I have, if the user spams the forward button in the notification controls, the buffering symbol will come up and sometimes stay doing the buffering animation for minutes while the av is 'paused'. After foregrounding the app, the av still seems to be buffering since the av looks paused, and eventually after maybe 10s or more, it'll resume. I noticed the player was at ~3 min behind the loaded duration once after this situation. Additionally, while foregrounded, I caused a forward/rewind event, and both were able to resume the player within a second or less.

I do have some custom duration handling in a parent component that I intend on looking into. But any help anyone can provide would be very welcome. I do not know everything about buffering or live streams in m3u8 files.

IIRC I also tested this live stream in the example/basic and observed the same situation on android simulator. If I have time I will confirm this tomorrow.

Reproduction

No response

Reproduction

Step to reproduce this bug are:

import ReactNativeVideo, {BufferingStrategyType, TextTrackType} from 'react-native-video';

<ReactNativeVideo
        source={{ uri: 'https://democracynow-hls.secdn.net/democracynow-live/play/democracynow.smil/playlist.m3u8' }}
        bufferConfig={{
            minBufferMs: 15000,
            maxBufferMs: 50000,
            bufferForPlaybackMs: 2500,
            bufferForPlaybackAfterRebufferMs: 5000,
            cacheSizeMB: 0,
            live: {
              targetOffsetMs: 500,
            }
          }
        }
        showNotificationControls={true}
        bufferingStrategy={BufferingStrategyType.DEFAULT}
/>
moskalakamil commented 2 months ago

Hi @paulrinaldi, thanks for reporting the issue! Could you provide your entire component without unnecessary lines? It would make implementation much easier. Thanks!

paul-rinaldi commented 2 months ago

I'm going to close this issue in favor of https://github.com/TheWidlarzGroup/react-native-video/issues/4039 which captures it better.

And I'll edit this to be more succinct.