ExoPlayer ignores cached segments when adaptive streaming selects different quality
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
Version
Media3 1.5.1
More version details
No response
Devices that reproduce the issue
Google Pixel 3a with Android 11
Devices that do not reproduce the issue
not tested
Reproducible in the demo app?
Not tested
Reproduction steps
-
Set up two ExoPlayer instances:
Player 0 for playback.
Player 1 for preloading segments. -
Videos are encoded using DASH with multiple representations (e.g., 240p, 480p, 720p). Each video has multiple .m4s segment files and init files per representation.
-
Use a custom CacheKeyFactory to unify segment keys across quality levels:
override fun buildCacheKey(dataSpec: DataSpec): String { val url = dataSpec.uri.toString()
val chunkRegex = Regex(".*/([^/]+)/chunk-stream\\d+-(\\d+)")
val initRegex = Regex(".*/([^/]+)/init-stream(\\d+)")
chunkRegex.find(url)?.let {
val videoId = it.groupValues[1]
val chunkId = it.groupValues[2]
return "video-$videoId-chunk-$chunkId"
}
initRegex.find(url)?.let {
val videoId = it.groupValues[1]
val streamId = it.groupValues[2]
return "video-$videoId-init-$streamId"
}
return url
}
-
Player 1 preloads the first few segments of video N+1 using this setup and stores them in the SimpleCache.
-
When the user scrolls, Player 0 plays video N+1 using the same CacheKeyFactory, expecting cache reuse for the first few segments, and then uses ABR to download the missing segments at the end.
Both players download videos based on
val mediaSource = DashMediaSource.Factory(cacheDataSourceFactory)
.createMediaSource(mediaItem)
exoPlayer.setMediaSource(mediaSource)
where mediaItem is based on an URL.
Expected result
Player 0 should detect and use the cached segments (from Player 1), even if they are of a different quality than what the adaptive logic would normally choose.
Playback should begin immediately without needing to redownload those segments in a different quality.
Actual result
Player 0 ignores the cached segments if their quality doesn't match the current ABR selection.
If the current ABR selection is not in the cache, it re-downloads the same segment index but in different quality, making the preloaded segments useless despite identical cache keys.
Media
Big Buck Bunny Dataset: https://ftp.itec.aau.at/datasets/DASHDataset2014/BigBuckBunny/4sec/
Bug Report
- You will email the zip file produced by
adb bugreportto android-media-github@google.com after filing this issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.