androidx / androidx/media

Optimize allocations during metadata extraction

Open
#1,929 2 comments 0 reactions 1 assignee View on GitHub

@icbaker is already working on this.

Since Dec 4, 2024.

enhancement low priority
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

[REQUIRED] Use case description

My music app relies on ExoPlayer's exposed metadata parsing (MetadataRetriever) to do mass scans of music libraries.

However, there seems to be some poor memory use during certain parts of metadata extraction, with entire ID3 tags and vorbis comments being directly read into memory.

When my metadata system encounters large cover art data and generally large tags, these repeated allocations and copies often slow down the process due to the constant GCs required.

Proposed solution

Refactor the container extractors to minimize reading out data into memory until the actual tag data is needed. For example, Id3Decoder would read from an input stream up until the identified bound of the tag, rather than reading from an in-memory ByteArray. Using some kind of composable reader pattern could be helpful if data transformation is required.

Alternatives considered

Using another tagging library that allows me to stream in this data. I don't like the duplication of container parsing, but can tolerate it for efficiency.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.