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

ArrayIndexOutOfBoundsException in MP4 parsing (regression from 1.4.x to 1.5.x) #2062

Closed
1 task done
JonatanPlesko opened this issue Jan 21, 2025 · 2 comments
Closed
1 task done
Assignees

Comments

@JonatanPlesko
Copy link

JonatanPlesko commented Jan 21, 2025

Version

Media3 main branch

More version details

Media3 1.5.0 and 1.5.1.
This issue does not occur on Media3 1.4.1.

Devices that reproduce the issue

Google Pixel 7 running Android 15
Samsung Galaxy S10+ running Android 12

Devices that do not reproduce the issue

(None found so far; it appears consistent on all tested Android devices.)

Reproducible in the demo app?

Yes

Reproduction steps

  1. Launch the Media3 demo app (or your own app that uses Media3 1.5.x).
  2. Play the problematic MP4 file.
  3. Observe that playback fails with an ArrayIndexOutOfBoundsException.

Expected result

The video should play normally (as it does in the browser, QuickTime, iOS devices, and previous Media3 1.4.1).

Actual result

Playback fails with a Source error in the Media3 logs. The exception stack trace looks like:

08:51:38.668  E  Unexpected exception loading stream
                   java.lang.ArrayIndexOutOfBoundsException: src.length=417 srcPos=-1 dst.length=418 dstPos=0 length=418
                       at java.lang.System.arraycopy(Native Method)
                       at androidx.media3.extractor.mp4.BoxParser.parseStbl(BoxParser.java:776)
                       at androidx.media3.extractor.mp4.BoxParser.parseTraks(BoxParser.java:168)
                       at androidx.media3.extractor.mp4.Mp4Extractor.processMoovAtom(Mp4Extractor.java:691)
                       at androidx.media3.extractor.mp4.Mp4Extractor.processAtomEnded(Mp4Extractor.java:634)
                       at androidx.media3.extractor.mp4.Mp4Extractor.readAtomPayload(Mp4Extractor.java:610)
                       at androidx.media3.extractor.mp4.Mp4Extractor.read(Mp4Extractor.java:388)
                       at androidx.media3.exoplayer.source.BundledExtractorsAdapter.read(BundledExtractorsAdapter.java:147)
                       at androidx.media3.exoplayer.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1122)
                       at androidx.media3.exoplayer.upstream.Loader$LoadTask.run(Loader.java:450)
                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
                       at java.lang.Thread.run(Thread.java:920)
08:51:38.671  E  internalError [eventTime=10.26, mediaPos=0.00, window=0, period=0, loadError
                   androidx.media3.exoplayer.upstream.Loader$UnexpectedLoaderException: Unexpected ArrayIndexOutOfBoundsException: src.length=417 srcPos=-1 dst.length=418 dstPos=0 length=418
                       at androidx.media3.exoplayer.upstream.Loader$LoadTask.run(Loader.java:471)
                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
                       at java.lang.Thread.run(Thread.java:920)
                   Caused by: java.lang.ArrayIndexOutOfBoundsException: src.length=417 srcPos=-1 dst.length=418 dstPos=0 length=418
                       at java.lang.System.arraycopy(Native Method)
                       at androidx.media3.extractor.mp4.BoxParser.parseStbl(BoxParser.java:776)
                       at androidx.media3.extractor.mp4.BoxParser.parseTraks(BoxParser.java:168)
                       at androidx.media3.extractor.mp4.Mp4Extractor.processMoovAtom(Mp4Extractor.java:691)
                       at androidx.media3.extractor.mp4.Mp4Extractor.processAtomEnded(Mp4Extractor.java:634)
                       at androidx.media3.extractor.mp4.Mp4Extractor.readAtomPayload(Mp4Extractor.java:610)
                       at androidx.media3.extractor.mp4.Mp4Extractor.read(Mp4Extractor.java:388)
                       at androidx.media3.exoplayer.source.BundledExtractorsAdapter.read(BundledExtractorsAdapter.java:147)
                       at androidx.media3.exoplayer.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1122)
                       at androidx.media3.exoplayer.upstream.Loader$LoadTask.run(Loader.java:450)
                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
                       at java.lang.Thread.run(Thread.java:920) 
                 ]
08:51:38.679  E  Playback error
                   androidx.media3.exoplayer.ExoPlaybackException: Source error
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:737)
                       at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:713)
                       at android.os.Handler.dispatchMessage(Handler.java:102)
                       at android.os.Looper.loopOnce(Looper.java:226)
                       at android.os.Looper.loop(Looper.java:313)
                       at android.os.HandlerThread.run(HandlerThread.java:67)
                   Caused by: androidx.media3.exoplayer.upstream.Loader$UnexpectedLoaderException: Unexpected ArrayIndexOutOfBoundsException: src.length=417 srcPos=-1 dst.length=418 dstPos=0 length=418
                       at androidx.media3.exoplayer.upstream.Loader$LoadTask.run(Loader.java:471)
                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
                       at java.lang.Thread.run(Thread.java:920)
                   Caused by: java.lang.ArrayIndexOutOfBoundsException: src.length=417 srcPos=-1 dst.length=418 dstPos=0 length=418
                       at java.lang.System.arraycopy(Native Method)
                       at androidx.media3.extractor.mp4.BoxParser.parseStbl(BoxParser.java:776)
                       at androidx.media3.extractor.mp4.BoxParser.parseTraks(BoxParser.java:168)
                       at androidx.media3.extractor.mp4.Mp4Extractor.processMoovAtom(Mp4Extractor.java:691)
                       at androidx.media3.extractor.mp4.Mp4Extractor.processAtomEnded(Mp4Extractor.java:634)
                       at androidx.media3.extractor.mp4.Mp4Extractor.readAtomPayload(Mp4Extractor.java:610)
                       at androidx.media3.extractor.mp4.Mp4Extractor.read(Mp4Extractor.java:388)
                       at androidx.media3.exoplayer.source.BundledExtractorsAdapter.read(BundledExtractorsAdapter.java:147)
                       at androidx.media3.exoplayer.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1122)
                       at androidx.media3.exoplayer.upstream.Loader$LoadTask.run(Loader.java:450)
                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
                       at java.lang.Thread.run(Thread.java:920) 

Media

I will email the media file to android-media-github@google.com shortly after filing this issue.

Bug Report

@tonihei
Copy link
Collaborator

tonihei commented Jan 24, 2025

@rohitjoins : I wonder if that is related to the recent changes for edit lists and handling out of order sample timestamps.

copybara-service bot pushed a commit that referenced this issue Jan 28, 2025
The exception occurred when an edit list started at a non-sync frame with no preceding sync frame. The fix searches forward for the next sync frame in such cases, preventing the out-of-bounds access.

Issue: #2062

#cherrypick

PiperOrigin-RevId: 720642687
@rohitjoins
Copy link
Contributor

Thank you for reporting this bug. We’ve implemented a fix in the main branch, which will be part of the upcoming 1.6.0-alpha02 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants