question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ensure logs from AudioTrack.getMinBufferSize are reported back to the application

See original GitHub issue

[REQUIRED] Use case description

I’m getting the following crash from an user but the underlying error is not logged except on the device logcat and users are often not willing to send full bugs report dumps from their device due to the sensitive nature of those.

Unexpected runtime error
      at com.google.android.exoplayer2.ExoPlaybackException.createForUnexpected(ExoPlaybackException.java:207)
      at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:587)
      at android.os.Handler.dispatchMessage(Handler.java)
      at android.os.Looper.loop(Looper.java)
      at android.os.HandlerThread.run(HandlerThread.java)
  Caused by: java.lang.IllegalStateException
      at com.google.android.exoplayer2.util.Assertions.checkState(Assertions.java:84)
      at com.google.android.exoplayer2.audio.DefaultAudioSink$Configuration.getPcmDefaultBufferSize(DefaultAudioSink.java:2126)
      at com.google.android.exoplayer2.audio.DefaultAudioSink$Configuration.computeBufferSize(DefaultAudioSink.java:2104)
      at com.google.android.exoplayer2.audio.DefaultAudioSink$Configuration.<init>(DefaultAudioSink.java:1974)
      at com.google.android.exoplayer2.audio.DefaultAudioSink.configure(DefaultAudioSink.java:602)
      at com.google.android.exoplayer2.audio.DecoderAudioRenderer.drainOutputBuffer(DecoderAudioRenderer.java:404)
      at com.google.android.exoplayer2.audio.DecoderAudioRenderer.render(DecoderAudioRenderer.java:303)
      at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:945)
      at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:478)
      ... 3 more

Proposed solution

Have that function logs send up to the normal log Exoplayer EventLogger

Alternatives considered

  • Throw directly in that function?
  • Return the result as a Pair containing the error string, or using one of the common Result monad stuff then add the message to the assert.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ojw28commented, Jun 28, 2021

Thanks. I’ve filed [internal ref: b/192226595] to request better error codes from the platform in this case.

We might be able to determine the cause at the ExoPlayer level by mimicking the logic in the platform, but that seems very error-prone (e.g., it can easily go out of sync, and may be out of sync already on some devices if OEMs have made platform modifications). So I’m not convinced it’s a good idea.

I’ll leave this issue closed, since there’s nothing actionable here for us for the time being. If we get better error codes from the platform, then we’ll make sure to plumb those through in the future!

0reactions
Tolriqcommented, Jun 28, 2021

@ojw28

It’s all about: https://cs.android.com/android/platform/superproject/+/master:frameworks/base/media/java/android/media/AudioTrack.java;l=2300?q=getMinBufferSize&ss=android%2Fplatform%2Fsuperproject

But maybe there’s a way to detect before or better before manually from ExoPlayer?

When playing from certain server I can request transcoding on the first 3 errors to supported media, but knowing the exact cause helps a lot to better determine what to transcode to. And as if it did not transcode first it means either the device was supposed to support the media or I failed some prechecks earlier so maybe I have something to fix but can’t really know easily.

BTW I’m using ffmepg for audio so don’t really know what kind of data reaches here and maybe there’s something I’m supposed to do so that ffmepg does something to not trigger such errors.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AudioTrack - Android Developers
An error code indicating that the object reporting it is no longer valid and needs to be ... Returns the maximum size of...
Read more >
webrtc/modules/audio_device/android/java/src ... - Google Git
Logging.e(TAG, "AudioTrack.getMinBufferSize returns an invalid value."); return false;. } // Ensure that prevision audio session was stopped correctly ...
Read more >
AudioTrack.getMinBufferSize returns a buffer too short in ...
Unfortunately, it seems to return a buffer size that is too short, and causes terrible crackling noise, making my application totally useless. If...
Read more >
webrtc/WebRtcAudioTrack.java at master - GitHub
reportWebRtcAudioTrackInitError("AudioTrack.getMinBufferSize returns an invalid value."); return false;. } // Ensure that prevision audio session was ...
Read more >
android.media.AudioTrack#STATE_INITIALIZED
mSessionId); if (audioTrack.getState() != AudioTrack.STATE_INITIALIZED) { Log.w(TAG, "Unable to create audio track."); audioTrack.release(); return null; } ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found