Crash on Buffering the HLS Streaming (Updated Adaptive HLS Streaming)
Hi,
we take a update today for adaptive HLS Streaming . its working fine but we are getting crash if we play video for few second. or seeking the video. May be there some buffer Problem. Here is log
11-19 20:24:34.661: E/ExoPlayerImplInternal(21053): Internal runtime error. 11-19 20:24:34.661: E/ExoPlayerImplInternal(21053): java.nio.BufferOverflowException 11-19 20:24:34.661: E/ExoPlayerImplInternal(21053): at java.nio.Buffer.checkPutBounds(Buffer.java:189) 11-19 20:24:34.661: E/ExoPlayerImplInternal(21053): at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:307) 11-19 20:24:34.661: E/ExoPlayerImplInternal(21053): at com.google.android.exoplayer.hls.TsExtractor.convert(TsExtractor.java:285) 11-19 20:24:34.661: E/ExoPlayerImplInternal(21053): at com.google.android.exoplayer.hls.TsExtractor.getSample(TsExtractor.java:175) 11-19 20:24:34.661: E/ExoPlayerImplInternal(21053): at com.google.android.exoplayer.hls.HlsSampleSource.readData(HlsSampleSource.java:219) 11-19 20:24:34.661: E/ExoPlayerImplInternal(21053): at com.google.android.exoplayer.MediaCodecTrackRenderer.feedInputBuffer(MediaCodecTrackRenderer.java:504) 11-19 20:24:34.661: E/ExoPlayerImplInternal(21053): at com.google.android.exoplayer.MediaCodecTrackRenderer.doSomeWork(MediaCodecTrackRenderer.java:405) 11-19 20:24:34.661: E/ExoPlayerImplInternal(21053): at com.google.android.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:398) 11-19 20:24:34.661: E/ExoPlayerImplInternal(21053): at com.google.android.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:203) 11-19 20:24:34.661: E/ExoPlayerImplInternal(21053): at android.os.Handler.dispatchMessage(Handler.java:98) 11-19 20:24:34.661: E/ExoPlayerImplInternal(21053): at android.os.Looper.loop(Looper.java:157) 11-19 20:24:34.661: E/ExoPlayerImplInternal(21053): at android.os.HandlerThread.run(HandlerThread.java:61) 11-19 20:24:34.661: E/ExoPlayerImplInternal(21053): at com.google.android.exoplayer.util.PriorityHandlerThread.run(PriorityHandlerThread.java:40) 11-19 20:24:34.661: W/System.err(21053): com.google.android.exoplayer.ExoPlaybackException: java.nio.BufferOverflowException 11-19 20:24:34.661: W/System.err(21053): at com.google.android.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:236) 11-19 20:24:34.661: W/System.err(21053): at android.os.Handler.dispatchMessage(Handler.java:98) 11-19 20:24:34.661: W/System.err(21053): at android.os.Looper.loop(Looper.java:157) 11-19 20:24:34.661: W/System.err(21053): at android.os.HandlerThread.run(HandlerThread.java:61) 11-19 20:24:34.661: W/System.err(21053): at com.google.android.exoplayer.util.PriorityHandlerThread.run(PriorityHandlerThread.java:40) 11-19 20:24:34.661: W/System.err(21053): Caused by: java.nio.BufferOverflowException 11-19 20:24:34.661: W/System.err(21053): at java.nio.Buffer.checkPutBounds(Buffer.java:189) 11-19 20:24:34.661: W/System.err(21053): at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:307) 11-19 20:24:34.661: W/System.err(21053): at com.google.android.exoplayer.hls.TsExtractor.convert(TsExtractor.java:285) 11-19 20:24:34.661: W/System.err(21053): at com.google.android.exoplayer.hls.TsExtractor.getSample(TsExtractor.java:175) 11-19 20:24:34.661: W/System.err(21053): at com.google.android.exoplayer.hls.HlsSampleSource.readData(HlsSampleSource.java:219) 11-19 20:24:34.661: W/System.err(21053): at com.google.android.exoplayer.MediaCodecTrackRenderer.feedInputBuffer(MediaCodecTrackRenderer.java:504) 11-19 20:24:34.661: W/System.err(21053): at com.google.android.exoplayer.MediaCodecTrackRenderer.doSomeWork(MediaCodecTrackRenderer.java:405) 11-19 20:24:34.666: I/ACodec(21053): [OMX.Exynos.avc.dec] Now Executing->Idle 11-19 20:24:34.666: W/System.err(21053): at com.google.android.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:398) 11-19 20:24:34.666: W/System.err(21053): at com.google.android.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:203) 11-19 20:24:34.666: W/System.err(21053): ... 4 more 11-19 20:24:34.676: E/EventLogger(21053): playerFailed [11.16] 11-19 20:24:34.676: E/EventLogger(21053): com.google.android.exoplayer.ExoPlaybackException: java.nio.BufferOverflowException 11-19 20:24:34.676: E/EventLogger(21053): at com.google.android.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:236) 11-19 20:24:34.676: E/EventLogger(21053): at android.os.Handler.dispatchMessage(Handler.java:98) 11-19 20:24:34.676: E/EventLogger(21053): at android.os.Looper.loop(Looper.java:157) 11-19 20:24:34.676: E/EventLogger(21053): at android.os.HandlerThread.run(HandlerThread.java:61) 11-19 20:24:34.676: E/EventLogger(21053): at com.google.android.exoplayer.util.PriorityHandlerThread.run(PriorityHandlerThread.java:40) 11-19 20:24:34.676: E/EventLogger(21053): Caused by: java.nio.BufferOverflowException 11-19 20:24:34.676: E/EventLogger(21053): at java.nio.Buffer.checkPutBounds(Buffer.java:189) 11-19 20:24:34.676: E/EventLogger(21053): at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:307) 11-19 20:24:34.676: E/EventLogger(21053): at com.google.android.exoplayer.hls.TsExtractor.convert(TsExtractor.java:285) 11-19 20:24:34.676: E/EventLogger(21053): at com.google.android.exoplayer.hls.TsExtractor.getSample(TsExtractor.java:175) 11-19 20:24:34.676: E/EventLogger(21053): at com.google.android.exoplayer.hls.HlsSampleSource.readData(HlsSampleSource.java:219) 11-19 20:24:34.676: E/EventLogger(21053): at com.google.android.exoplayer.MediaCodecTrackRenderer.feedInputBuffer(MediaCodecTrackRenderer.java:504) 11-19 20:24:34.676: E/EventLogger(21053): at com.google.android.exoplayer.MediaCodecTrackRenderer.doSomeWork(MediaCodecTrackRenderer.java:405) 11-19 20:24:34.676: E/EventLogger(21053): at com.google.android.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:398) 11-19 20:24:34.676: E/EventLogger(21053): at com.google.android.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:203) 11-19 20:24:34.676: E/EventLogger(21053): ... 4 more
That's normally indicative of an abnormally large video sample. Please could you provide a test stream that reproduces the issue? Also, on which device(s) are you seeing this? Thanks!
Actually , In server side , we are using 200kbs bitrate to 15mb bit rate in siml file. we reduced to 4mb . . now crash is not happening . but still video is stop again and again. In log , we are getting warning message like omx. target 3.
The warnings come from the lower level system, but I suspect they're expected. Decoders print out various debugging messages at the wrong log level on some devices.
15Mbit/sec is pretty crazy, you shouldn't be needing such a high bitrate. Netflix tops out at something like 3.5Mbit/sec (http://ispspeedindex.netflix.com/usa - note that the results are effectively capped by the bitrates they provide). If the video keeps stopping and starting, it's quite likely that the path from server->client just doesn't have enough bandwidth.
Hi, i encounter the same problem here, using the HLS Apple master playlist provided in the Demo with API 16 or 17.
The stream is this one: https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8
The max bitrate (according to VLC) seems to be around 1,8 or 2Mbit/sec
but it fails after couple segments with the error:
E/OMXNodeInstance﹕ OMX_GetExtensionIndex failed
and then
E/ExoPlayerImplInternal﹕ Internal runtime error. java.nio.BufferOverflowException at java.nio.Buffer.checkPutBounds(Buffer.java:189) ....
The strange thing is:
- the demo works perfectly on Emulator with Nexus 5 (1,5Gb Ram) and API 23
- the demo fail (with BufferOverflowException) on the same Emulator and Ram, but with API 16 or 17
The API are handling the buffer in different ways i guess ? How to prevent that error to append ?
Thanks for your help
I'm having the same issue on Acer Iconia Tab 8 (4.4.2). The playback stops after 18 seconds with this exception:
[OMX.Intel.hw_vd.h264] storeMetaDataInBuffers failed w/ err -2147483648
09-21 13:58:40.445: E/ExoPlayerImplInternal(12384): Internal runtime error.
09-21 13:58:40.445: E/ExoPlayerImplInternal(12384): java.nio.BufferOverflowException
09-21 13:58:40.445: E/ExoPlayerImplInternal(12384): at java.nio.Buffer.checkPutBounds(Buffer.java:189)
09-21 13:58:40.445: E/ExoPlayerImplInternal(12384): at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:307)
09-21 13:58:40.445: E/ExoPlayerImplInternal(12384): at com.google.android.exoplayer.d.g.a(Unknown Source)
09-21 13:58:40.445: E/ExoPlayerImplInternal(12384): at com.google.android.exoplayer.d.g.b(Unknown Source)
09-21 13:58:40.445: E/ExoPlayerImplInternal(12384): at com.google.android.exoplayer.d.b.a(Unknown Source)
09-21 13:58:40.445: E/ExoPlayerImplInternal(12384): at com.google.android.exoplayer.e.f.a(Unknown Source)
09-21 13:58:40.445: E/ExoPlayerImplInternal(12384): at com.google.android.exoplayer.e.n.a(Unknown Source)
09-21 13:58:40.445: E/ExoPlayerImplInternal(12384): at com.google.android.exoplayer.w.c(Unknown Source)
09-21 13:58:40.445: E/ExoPlayerImplInternal(12384): at com.google.android.exoplayer.w.a(Unknown Source)
09-21 13:58:40.445: E/ExoPlayerImplInternal(12384): at com.google.android.exoplayer.p.k(Unknown Source)
09-21 13:58:40.445: E/ExoPlayerImplInternal(12384): at com.google.android.exoplayer.p.handleMessage(Unknown Source)
09-21 13:58:40.445: E/ExoPlayerImplInternal(12384): at android.os.Handler.dispatchMessage(Handler.java:98)
09-21 13:58:40.445: E/ExoPlayerImplInternal(12384): at android.os.Looper.loop(Looper.java:149)
09-21 13:58:40.445: E/ExoPlayerImplInternal(12384): at android.os.HandlerThread.run(HandlerThread.java:61)
09-21 13:58:40.445: E/ExoPlayerImplInternal(12384): at com.google.android.exoplayer.i.s.run(Unknown Source)
This is the only device which I tested that is causing this issue.
@ojw28 why do you rush into closing all the issues reporting this problem? Almost every single issue I saw was closed without a proper solution given.
Hi, yes it is related to the stream bitrate. I tried to lower the max available bitrate and it finally succeeded. But it is still a BUG !
HLS is supposed to manage adaptative streaming regarding the network available bandwith AND the device capabilities ! It's not a solution to just lower the max bitrate available to support older Android device ! How can i provide HD alternative for supported device this way ?
Please re-open this issue as a BUG, it needs to be fixed by avoiding to select a quality bitrate in the variant playlist which will lead to a buffer overflow. We need to trigger the downward quality selection if a given quality leads to this exception!
Thanks
This bug was closed because the bitrate used was unreasonable large. #513 was closed because no-one updated it to provide more information. #714 is not closed and can be used to track the issue. We don't need more than one open bug.
Regarding the comment above, the HLS specification isn't actually defined in a way that makes it particularly easy for devices to take into account their own capabilities. Specifically, the HLS specification does not require that CODECS and (particularly) RESOLUTION tags are included in the master playlist, which are necessary for devices to sanely determine whether a variant is playable given the capabilities of the device. If you're not already doing so, including these tags will go some way to help devices to adapt to their own capabilities.
Hi, Yes you're right no need for multiple issues, i didn't saw the #714. I will add my observations to it.
And indeed, the playlist doesn't provide CODECS or RES, but the behaviour i observed is that the HLS Renderer first start with the poorest quality and then try the better ones. One solution to help with this bug would be to trigger some kind of "i can't read it" mechanism" while trying to upscale to a better quality which would force the player to stay on the lower quality, whithout throwing the Exception. What do you think ?
Best, Thomas
We have no plans to support that kind of mechanism. Implementation wise it's horrendous. It basically involves downloading a chunk of data and allocating potentially large blocks of memory, only to fail and throw it all away when you can't play what you've loaded. It's reasonably unlikely that you'll be able to seamlessly switch to a different quality having already tried and failed to switch to a few other qualities, because an unsuccessful switch attempt takes time (e.g. to download the chunk).
Really, a player shouldn't need to go to these lengths to patch over the serving side not providing sufficient information and the HLS specification not being well suited to what's actually trying to be achieved. If a provider wants to provide a stream that's playable across devices with different capabilities, they should (a) think carefully about what the best technology is for doing this, and (b) if they do choose HLS, always include necessary information like the CODECS and RESOLUTION tags to make it easy for a client to do the right thing.
I'm not sure to understand, i already provide the RESOLUTION tags in my test playlist, but it fails anyway.. ExoPlayer doesn't handle it, right ? I have to parse it on my own and disable the highest one ?
My goal is indeed to provide a stream playable across devices with different capabilities - that's the "adaptative" in Adaptative Streaming. Yet i understand that HLS might not be the best option, but since DASH is not well implemented in iOS and neither SmoothStreaming, the best i can do is to go for the less worst !
A fluent switch to a lower quality when this overflow exception appends is indeed complicated to achieve since it suppose either to know if the current chunk will fail in advance, either preloading a lower quality chunk "in case of emergency" which is not really acceptable.
BUT when this Exception appends, we can either:
- crash.. and let people understand that they have to provide separate m3u8 regarding the device, which kills the "adaptative" concept of this already poor but yet commonly used HLS protocol (which you choosed to implement in ExoPlayer anyway).
- or: 1) freeze the playback, 2) blacklist the current quality as not suitable, 3) start back to the lowest quality to restore the playback as soon as possible and then 4) start again to upscale the quality, while staying under the balcklisted ones..
With the second solution we only freeze during the loading time of the poorest quality chunk, which is, in my opinion more acceptable than just crashing out.. and more "adaptative" also. I understand that it is not perfect and need some work to achieve but hey, choosing to implement HLS in the first place was already a challenge ;) And this is the right place to post this kind of ideas isn't it ?
Anyway thanks for the hard work on this so far, it's really helpfull.
Best Regards,
Thomas
I think your confusion is because there are multiple issues involved here. Some of the points in this issue are general ones, whilst other points are specific. To clarify, there are multiple possible failure modes when switching up to a higher quality:
- Manifest omits RESOLUTION/CODECS tags. Client does not have an easy way to determine whether a stream is playable, tries to switch and fails.
- Manifest includes RESOLUTION/CODECS tags. Device incorrectly advertises support for playback that it doesn't really support. Client tries to switch and fails.
- Manifest includes RESOLUTION/CODECS tags. Device can support the resolution, but sizes its video input buffers too small for the resolution. Client reaches a large frame during playback and fails.
The first of these is a shortcoming with HLS and/or the people providing the streams, depending on how you look at things. The second and third issues apply to DASH as well, but tend to be isolated to a small number of not particularly popular devices. The Acer Iconia Tab 8 being one. Emulators and unofficial Android TV boxes are other classes of device where we see this kind of thing. We will get around to looking at the Acer device eventually, but it doesn't make sense to prioritise making playback "sort of work" on these devices. It's the underlying device that's at fault.
Note also that the player does not crash. It prints an exception in the logs and reports failure through its event listener.
Thanks for the clarifications.
In case 1.: since App developpers doesn't necessary have controls on HLS specification or the stream provider, it might still be good to implement a fallback solution when RES/CODECS are not provided..
In my situation the problem happens using a manifest which provide RES/CODECS, so i suppose the problem comes from 2. or 3. I am indeed using the Emulator for now so it might just be it, but i will soon try it on different physical devices, and let you know if i face this again.
And yeah, it doesn't crash, you're right, but it doesn't play either ;)
Best,
Thomas
The emulator has not done a good job of supporting media, historically. It's not a "device" we make any effort to target, because it's not what end users actually use.