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]: (Android) HLS in background stops and shows buffering animation forever in example/basic app on physical devices #4039

Open
paulrinaldi opened this issue Jul 29, 2024 · 13 comments
Labels
bug Platform: Android stale Closed due to inactivity or lack or resources

Comments

@paulrinaldi
Copy link
Contributor

paulrinaldi commented Jul 29, 2024

Version

^6.2.4

What platforms are you having the problem on?

Android

System Version

14

On what device are you experiencing the issue?

Real device

Architecture

Old architecture

What happened?

Using an HLS livestream such as this Democracy Now DVR stream (available from 8-9am United States Eastern Time) or
this DVR FPV Drone stream (always available) in the example/basic app on a physical device does not play properly in the background.

Reproduction

https://github.com/paulrinaldi/react-native-video/tree/master

  1. Start the app on a physical android 14 device
  2. Navigate channel up to one channel past the red bull stream
  3. Wait until the video loads
  4. Background the app
  5. Pull down the notification controls so you can observe AV (not necessarily needed, you can reproduce this without viewing the notif media controls)
    • Watch the notification's progress bar move until the circle hits the end of the progress bar and switches out the play/pause icon for the buffering animation

Actual:
7. Observe no AV and the buffering animation continue nonstop*

Desired:
7. Observe the playable duration increase and the progress bar's ticker move backward slightly because the new buffered section loaded in the progress bar and no interruption in the audio while backgrounded.

OR

Add either or both of these entries to examples/basic/src/constants/general.ts this DVR HLS:

  {
    description: 'democracy now',
    uri: 'https://democracynow-hls.secdn.net/democracynow-live/play/democracynow.smil/playlist.m3u8',
  },
  {
    description: 'Drone B-Roll',
    uri: 'https://5b44cf20b0388.streamlock.net:8443/dvr/dvr/playlist.m3u8?DVR',
  },

Actual:

  1. Start the app on a physical android 14 device
  2. Tap notification controls
  3. Navigate channel up to the added source
  4. Background the app
  5. Pull down the notification controls so you can observe AV (not necessarily needed, you can reproduce this without viewing the notif media controls)
  6. Observe no AV and the buffering animation continue nonstop*

Desired:
7. Observe the playable duration increase and the progress bar's ticker move backward slightly because the new buffered section loaded in the progress bar and no interruption in the audio while backgrounded.

Other notes:
In Browserstack, this cannot be reproduced, this is potentially because the browserstack devices are of very high quality and low wear and tear unlike phones that actual owners have when they use our apps.

*(the only way to resume is to foreground the app and wait like 10s, rewind the player via notif controls, rewind the player via player controls in foreground, seek forward the player via notif controls, seek forward the player via player controls in foreground, or foreground the app then pause then play the player - sometimes neither of these options resume the player)

@maksymhcode-care
Copy link

Similar issue on ios, but issue appears even on foreground

@paulrinaldi
Copy link
Contributor Author

With a stream that had DVR off, I unfortunately reproduced this issue. The playable duration sometimes does not update and the notification shows the buffering icon animation continually - and to resume the player one must foreground and or get the player to pause/play, skip forward, or skip backward.

@paulrinaldi paulrinaldi changed the title [BUG]: Android DVR HLS buffers forever when in background on Android [BUG]: Android HLS buffers forever eventually when in background on Android Aug 1, 2024
@paulrinaldi paulrinaldi changed the title [BUG]: Android HLS buffers forever eventually when in background on Android [BUG]: Android HLS eventually buffers forever when in background on Android Aug 1, 2024
@KrzysztofMoch
Copy link
Collaborator

@paulrinaldi is possible to reproduce this issue on emulator? I don't have physical android 14 :/

@paulrinaldi
Copy link
Contributor Author

I haven't been able to reproduce this on an emulator.

@KrzysztofMoch
Copy link
Collaborator

So this can be related to codec (as it is working on simulator) 🤔

@paulrinaldi
Copy link
Contributor Author

paulrinaldi commented Aug 6, 2024

As open source developers, you can get free use of physical mobile devices. Scroll to the bottom of:
https://www.browserstack.com/pricing
@KrzysztofMoch

I use browserstack and it works fairly well.

@paulrinaldi
Copy link
Contributor Author

paulrinaldi commented Aug 8, 2024

Here are the codecs on the m3u8 file stream we have:

#EXTM3U
#EXT-X-VERSION:7
#EXT-X-STREAM-INF:BANDWIDTH=4750288,CODECS="avc1.42c01f,mp4a.40.2",RESOLUTION=1280x720
https://vse2-na-us-nm6.secdn.net/democracynow-origin/live/democracynow-broadcast/enc-jdjj94fd/chunklist_sess343177297.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=4750288,CODECS="avc1.42c01f,mp4a.40.2",RESOLUTION=1280x720
https://vse2-na-us-nm7.secdn.net/democracynow-origin/live/democracynow-broadcast/enc-jdjj94fd/chunklist_sess343177297.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=4750288,CODECS="avc1.42c01f,mp4a.40.2",RESOLUTION=1280x720
https://vse2-na-us-nm8.secdn.net/democracynow-origin/live/democracynow-broadcast/enc-jdjj94fd/chunklist_sess343177297.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=565072,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360
https://vse2-na-us-nm6.secdn.net/democracynow-origin/live/democracynow-broadcast_360p2/enc-l5elsiaa/chunklist_sess343177297.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=565072,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360
https://vse2-na-us-nm7.secdn.net/democracynow-origin/live/democracynow-broadcast_360p2/enc-l5elsiaa/chunklist_sess343177297.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=565072,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360
https://vse2-na-us-nm8.secdn.net/democracynow-origin/live/democracynow-broadcast_360p2/enc-l5elsiaa/chunklist_sess343177297.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=84968,CODECS="avc1.64000b,mp4a.40.2",RESOLUTION=284x160
https://vse2-na-us-nm6.secdn.net/democracynow-origin/live/democracynow-broadcast_160p/enc-cf2i6k3s/chunklist_sess343177297.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=84968,CODECS="avc1.64000b,mp4a.40.2",RESOLUTION=284x160
https://vse2-na-us-nm7.secdn.net/democracynow-origin/live/democracynow-broadcast_160p/enc-cf2i6k3s/chunklist_sess343177297.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=84968,CODECS="avc1.64000b,mp4a.40.2",RESOLUTION=284x160
https://vse2-na-us-nm8.secdn.net/democracynow-origin/live/democracynow-broadcast_160p/enc-cf2i6k3s/chunklist_sess343177297.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=96888,CODECS="mp4a.40.2"
https://vse2-na-us-nm6.secdn.net/democracynow-origin/live/democracynow-broadcast_audio/enc-h2eyh7fj/chunklist_sess343177297.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=96888,CODECS="mp4a.40.2"
https://vse2-na-us-nm7.secdn.net/democracynow-origin/live/democracynow-broadcast_audio/enc-h2eyh7fj/chunklist_sess343177297.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=96888,CODECS="mp4a.40.2"
https://vse2-na-us-nm8.secdn.net/democracynow-origin/live/democracynow-broadcast_audio/enc-h2eyh7fj/chunklist_sess343177297.m3u8

Extracted out I see:

CODECS="avc1.42c01f,mp4a.40.2"
CODECS="avc1.64001e,mp4a.40.2"
CODECS="avc1.64000b,mp4a.40.2"
CODECS="mp4a.40.2"

=>

Video Codecs:

avc1.42c01f: H.264 Baseline profile, level 3.1
avc1.64001e: H.264 High profile, level 3.0
avc1.64000b: H.264 High profile, level 1.1

Audio Codec:

mp4a.40.2: AAC-LC (Low Complexity)

@paulrinaldi
Copy link
Contributor Author

paulrinaldi commented Aug 9, 2024

The red bull HLS m3u8 file has no codecs declared in it: https://rbmn-live.akamaized.net/hls/live/590964/BoRB-AT/master_928.m3u8

So that is a stark difference (ah and thus it has textTracksAllowChunklessPreparation=false)!

I still do not understand how codecs might be the problem here even if they are a big difference since (1) I don't see an "unsupported" error when using the democracy now m3u8 (https://democracynow-hls.secdn.net/democracynow-live/play/democracynow.smil/playlist.m3u8) and (2) codecs describe the compression and decompression algorithm for the AV. I suppose RNV could handle these codecs improperly. This same stream used to work fine in v5.2 RNV.

I will use logcat on my physical device to see what else I can learn about the playable duration (from onProgress event) when in background vs foreground and anything else that pops out to me.

If you have any suggestions, please feel free to mention them.

Just tested what I believe is my non-DVR HLS, and I saw correct buffering in the background in my app (only problem is if I fast forwarded to the tip of the progress bar and the bar player then pauses - this could be due to my code will check). Will keep testing, perhaps it's just a problem with my DVR HLS.

@paulrinaldi
Copy link
Contributor Author

paulrinaldi commented Aug 9, 2024

Tracing code more today.

@paulrinaldi
Copy link
Contributor Author

paulrinaldi commented Aug 9, 2024

Also, I have not seen this issue on iOS.

@paulrinaldi
Copy link
Contributor Author

This issue does not occur in browserstack, only on physical devices (tested on Pixel 6a and Samsung S21 5G. The issue still occurs in non-DVR streams, so this is an HLS issue.

I wonder where the issue lies. This all used to work in 5.2.0.

@paulrinaldi
Copy link
Contributor Author

Built a pure new android kotlin project with exoplayer 1.4.0 and got background audio stable with my DVR and nonDVR version HTTPS livestream. So there is a bug likely in RNV. Working to find it now. I appreciate any help. I do some unstable api's in use.

@paulrinaldi paulrinaldi changed the title [BUG]: Android HLS eventually buffers forever when in background on Android [BUG]: (Android) HLS in background stops and shows buffering animation forever in example/basic app on physical devices Aug 16, 2024
Copy link

This issue is stale because it has been open for 30 days with no activity. If there won't be any activity in the next 14 days, this issue will be closed automatically.

@github-actions github-actions bot added the stale Closed due to inactivity or lack or resources label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Platform: Android stale Closed due to inactivity or lack or resources
Projects
None yet
Development

No branches or pull requests

3 participants