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

SilenceMediaSource Error #6229

Closed
shaji-Dev opened this issue Jul 26, 2019 · 7 comments
Closed

SilenceMediaSource Error #6229

shaji-Dev opened this issue Jul 26, 2019 · 7 comments
Assignees
Labels

Comments

@shaji-Dev
Copy link

shaji-Dev commented Jul 26, 2019

Hi,

I keep getting this error when trying to prepare the SilcenceMediaSource in the player, it simply fails to play.

2019-07-26 12:03:45.884 4663-5805/com.yiqqi.android.yiqqi.development E/ExoPlayerImplInternal: Internal runtime error.
    java.lang.IndexOutOfBoundsException: off=0, len=-741232 out of bounds (size=4096)
        at java.nio.Buffer.checkBounds(Buffer.java:587)
        at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:285)
        at com.google.android.exoplayer2.source.SilenceMediaSource$SilenceSampleStream.readData(SilenceMediaSource.java:219)
        at com.google.android.exoplayer2.BaseRenderer.readSource(BaseRenderer.java:308)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.feedInputBuffer(MediaCodecRenderer.java:1024)
        at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:654)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:575)
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:326)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:214)
        at android.os.HandlerThread.run(HandlerThread.java:65)

This class was created under our request and we deeply appreciate it, but it seems to have this error which makes it unusable, could you please look into it? Thank you.

@andrewlewis
Copy link
Collaborator

Could you provide some more information on how to reproduce this error? Does it occur after seeking? I just tried playing a concatenation of some media with a SilenceMediaSource in the demo app and it worked as expected.

@shaji-Dev
Copy link
Author

shaji-Dev commented Jul 26, 2019

Yes, here's the situation, I have a timeline, which has multiple songs and with empty gaps between them, these gaps can be at the start and end as well. for that, I use ConcatenatingMediaSoruce with ClippingMediaSource for songs and SilenceMediaSource for gaps. Here's a representation of a simple timeline:

-song-song-song-
-: SilenceMediaSource
song: ClippingMediaSource with ProgressiveMediaSource

The issue is when readData happens, the byteRemaining is a negative value which shouldn't be the case, here's a debug screenshot up until the hightlighted line that produces the error:
image

This issue is that everytime I recreate the ConcatenatingMediaSoruce, even with the same values, with the same SilenceMediaSource durations and start positions for SilenceMediaSource and ClippingMediaSource. I sometimes get the error and sometime not. I tested with fixed constant values and recreated the ConcatenatingMediaSoruce again and again, it's like a hit and miss, works a couple of times, then error, then works again, then error again...

I'm sorry as it's hard to explain because I ran a couple of tests already and I can't seem to track down the exact source of the issue.

@andrewlewis
Copy link
Collaborator

@shaji-Dev I tried to create a similar setup, but still wasn't able to reproduce this. It would be nice if you could share a minimal test project or a patch to the demo app. Or could you modify SilenceSampleStream.seekTo to

public void seekTo(long positionUs) {
  long oldPositionBytes = positionBytes;
  positionBytes = getAudioByteCount(positionUs);
  Log.w("DEBUG", "seekTo " + positionUs + " position bytes " + oldPositionBytes + " -> " + positionBytes + " duration " + durationBytes, new Throwable());
}

then reproduce the issue and send us a bug report (adb bugreport)? Thanks.

@shaji-Dev
Copy link
Author

shaji-Dev commented Jul 29, 2019

Here's the bug report:

bugreport-2019-07-29-13-11-25.zip

The error appears here:

image

As I mentioned, it happens about once out of 5 times that I build the Media Sources, with the exact same values.

Thank you!

@andrewlewis
Copy link
Collaborator

It looks like there is a seek to ~ 3.412 seconds in a SilenceMediaSource with duration ~ 0.418 seconds. We'll make a change to clamp the seek position to be within bounds.

@shaji-Dev
Copy link
Author

Thank you for detecting the issue, do you have an estimate as to when the update will be available?

For a quick fix should I just check if the position is higher than the duration then I reset the position back to the max which is the duration?

Thank you.

ojw28 pushed a commit that referenced this issue Jul 29, 2019
ojw28 pushed a commit that referenced this issue Jul 29, 2019
Issue: #6229
PiperOrigin-RevId: 260500986
@andrewlewis
Copy link
Collaborator

Please try out the development branch and let us know if you see any other issues. Thanks.

@google google locked and limited conversation to collaborators Oct 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants