Skip to content

media3-migration.sh incorrectly rewrites MetadataRenderer import (and others) #2960

@stevemayhew

Description

@stevemayhew

Version

Media3 main branch

More version details

This actually occurs with any ExoPlayer client code running the 2.19.1 version of the migration script, but there is no place to put the bug there.

Devices that reproduce the issue

n/a

Devices that do not reproduce the issue

n/a

Reproducible in the demo app?

Yes

Reproduction steps

Run the media3-migration.sh script on any file that imports any of the affected classes

Summary

media3-migration.sh expands CLASS_MAPPINGS into sed substitutions that are not anchored (they match substrings, not whole identifiers). This causes prefix collisions when one class name is a prefix of another.

Concrete example: the mapping intended to rewrite only:

  • com.google.android.exoplayer2.metadata.Metadata

also matches the prefix of:

  • com.google.android.exoplayer2.metadata.MetadataRenderer

As a result, code importing MetadataRenderer can be rewritten to the wrong package, and the correct mapping never gets a chance to apply.


Affected script / location

  • Script: media3-migration.sh

  • Repo: google/ExoPlayer (release-v2 branch)

  • Relevant code in the script (class mapping expression builder):

    classes_expressions+="-e s/$src\.$clazz/$dest.$clazz/g "
    

Expected result

Correct mappings are applied to all former ExoPlayer classes. Example,

import com.google.android.exoplayer2.metadata.MetadataRenderer;

Actual result

Package is incorrectly mapping the class to common:

import androidx.media3.common.MetadataRenderer;

Media

n/a

Bug Report

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions