ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

decoderInfosCache issue in MediaCodecUtil

Open gvidda opened this issue 7 years ago • 3 comments

Issue description

In our stream-logs we see quite a few errors regarding decoder initialization with the cause DecoderQueryException for mimeType "video/avc" (both DRM and free media).

According to the docs for MediaCodecUtil.DecoderQueryException: "Thrown when an error occurs querying the device for its underlying media capabilities. Such failures are not expected in normal operation and are normally temporary (e.g. if the mediaserver process has crashed and is yet to restart)."

But the decoderInfosCache in MediaCodecUtil is a private static. If the getDecoderInfosInternal() method returns an empty array the first run, that empty array is put in the decoderInfosCache and used well... until a cold start of the app. So even if the failure is temporary (mediaserver crash) all subsequent attempts to play something are trying to use the same saved empty decoder.

Reproduction steps

Haven't been able to reproduce locally, just looked at MediaCodeUtil.java.

Version of ExoPlayer being used

Version used in production is still 2.7.1 but it's the same code in 2.9.2.

Device(s) and version(s) of Android being used

This is seen on a wide variety of devices, Samsung Galaxy A5, S6, S7, S8, S9, S9+, Tab A 9.7" LTE, Sony Xperia Z5, L1, X, Bravia 4K, Huawei Honor 8, 6X and so on...

I don't have a clear solution to this, I'd like to see some way to clear the cache, that could be used in a warm start of the app (like warmDecoderInfoCache() can be used), or that getDecoderInfos() are checking both if the cached decoder is null and if it's an empty list before returning the cached (empty) item.

gvidda avatar Dec 06 '18 09:12 gvidda

I don't really understand this issue. A DecoderQueryException being thrown and getDecoderInfosInternal() returning an empty array are mutually exclusive. If decoderInfosCache() returns the empty array then that's not an error case, and it's correct that it would be cached. If DecoderQueryException is thrown then I don't think anything is cached. Please clarify.

ojw28 avatar Dec 09 '18 03:12 ojw28

I think you're right, it's probably not the DecoderQueryException that's the problem.

I'll do a change in my checked out code with an extra check that the cached decoder isn't empty and test that for a few weeks in prod. To see if the error numbers improve for the better.

gvidda avatar Dec 11 '18 08:12 gvidda

Closing for now as it's therefore unclear what this is tracking. Please respond here if you discover something new. Thanks!

ojw28 avatar Dec 11 '18 09:12 ojw28