1*30877f79SAndroid Build Coastguard Worker--- 2*30877f79SAndroid Build Coastguard Workertitle: OEM testing 3*30877f79SAndroid Build Coastguard Worker--- 4*30877f79SAndroid Build Coastguard Worker 5*30877f79SAndroid Build Coastguard WorkerExoPlayer is used by a large number of Android applications. As an OEM, it's 6*30877f79SAndroid Build Coastguard Workerimportant to ensure that ExoPlayer works correctly both on new devices, and on 7*30877f79SAndroid Build Coastguard Workernew platform builds for existing devices. This page describes compatibility 8*30877f79SAndroid Build Coastguard Workertests that we recommend running before shipping a device or platform OTA, and 9*30877f79SAndroid Build Coastguard Workersome of the common failure modes encountered when running them. 10*30877f79SAndroid Build Coastguard Worker 11*30877f79SAndroid Build Coastguard Worker## Running the tests ## 12*30877f79SAndroid Build Coastguard Worker 13*30877f79SAndroid Build Coastguard WorkerTo run ExoPlayer's playback tests, first check out the latest release of 14*30877f79SAndroid Build Coastguard WorkerExoPlayer from [GitHub][]. You can then run the tests from the command line or 15*30877f79SAndroid Build Coastguard WorkerAndroid Studio. 16*30877f79SAndroid Build Coastguard Worker 17*30877f79SAndroid Build Coastguard Worker### Command line ### 18*30877f79SAndroid Build Coastguard Worker 19*30877f79SAndroid Build Coastguard WorkerFrom the root directory, build and install the playback tests: 20*30877f79SAndroid Build Coastguard Worker~~~ 21*30877f79SAndroid Build Coastguard Worker./gradlew :playbacktests:installDebug 22*30877f79SAndroid Build Coastguard Worker~~~ 23*30877f79SAndroid Build Coastguard Worker{: .language-shell} 24*30877f79SAndroid Build Coastguard WorkerNext, run the playback tests in the GTS package: 25*30877f79SAndroid Build Coastguard Worker~~~ 26*30877f79SAndroid Build Coastguard Workeradb shell am instrument -w -r -e debug false \ 27*30877f79SAndroid Build Coastguard Worker -e package com.google.android.exoplayer2.playbacktests.gts \ 28*30877f79SAndroid Build Coastguard Worker com.google.android.exoplayer2.playbacktests.test/androidx.test.runner.AndroidJUnitRunner 29*30877f79SAndroid Build Coastguard Worker~~~ 30*30877f79SAndroid Build Coastguard Worker{: .language-shell} 31*30877f79SAndroid Build Coastguard WorkerTest results appear in STDOUT. 32*30877f79SAndroid Build Coastguard Worker 33*30877f79SAndroid Build Coastguard Worker### Android Studio ### 34*30877f79SAndroid Build Coastguard Worker 35*30877f79SAndroid Build Coastguard WorkerOpen the ExoPlayer project, navigate to the `playbacktests` module, right click 36*30877f79SAndroid Build Coastguard Workeron the `gts` folder and run the tests. Test results appear in Android Studio's 37*30877f79SAndroid Build Coastguard WorkerRun window. 38*30877f79SAndroid Build Coastguard Worker 39*30877f79SAndroid Build Coastguard Worker## Common failure modes ## 40*30877f79SAndroid Build Coastguard Worker 41*30877f79SAndroid Build Coastguard WorkerSome of the common failure modes encountered when running ExoPlayer's playback 42*30877f79SAndroid Build Coastguard Workertests are described below, together with the likely root cause in each case. We 43*30877f79SAndroid Build Coastguard Workerwill add to this list as further failure modes are discovered. 44*30877f79SAndroid Build Coastguard Worker 45*30877f79SAndroid Build Coastguard Worker### Unexpected video buffer presentation timestamp ### 46*30877f79SAndroid Build Coastguard Worker 47*30877f79SAndroid Build Coastguard WorkerLogcat will contain an error similar to: 48*30877f79SAndroid Build Coastguard Worker~~~ 49*30877f79SAndroid Build Coastguard WorkerCaused by: java.lang.IllegalStateException: Expected to dequeue video buffer 50*30877f79SAndroid Build Coastguard Workerwith presentation timestamp: 134766000. Instead got: 134733000 (Processed 51*30877f79SAndroid Build Coastguard Workerbuffers since last flush: 2242). 52*30877f79SAndroid Build Coastguard Worker~~~ 53*30877f79SAndroid Build Coastguard Worker{: .language-shell} 54*30877f79SAndroid Build Coastguard WorkerThis failure is most often caused by the video decoder under test incorrectly 55*30877f79SAndroid Build Coastguard Workerdiscarding, inserting or re-ordering buffers. In the example above, the test 56*30877f79SAndroid Build Coastguard Workerexpected to dequeue a buffer with presentation timestamp `134766000` from 57*30877f79SAndroid Build Coastguard Worker`MediaCodec.dequeueOutputBuffer`, but found that it dequeued a buffer with 58*30877f79SAndroid Build Coastguard Workerpresentation timestamp `134733000` instead. We recommend that you check the 59*30877f79SAndroid Build Coastguard Workerdecoder implementation when encountering this failure, in particular that it 60*30877f79SAndroid Build Coastguard Workercorrectly handles adaptive resolution switches without discarding any buffers. 61*30877f79SAndroid Build Coastguard Worker 62*30877f79SAndroid Build Coastguard Worker### Too many dropped buffers ### 63*30877f79SAndroid Build Coastguard Worker 64*30877f79SAndroid Build Coastguard WorkerLogcat will contain an error similar to: 65*30877f79SAndroid Build Coastguard Worker~~~ 66*30877f79SAndroid Build Coastguard Workerjunit.framework.AssertionFailedError: Codec(DashTest:Video) was late decoding: 67*30877f79SAndroid Build Coastguard Worker200 buffers. Limit: 25. 68*30877f79SAndroid Build Coastguard Worker~~~ 69*30877f79SAndroid Build Coastguard Worker{: .language-shell} 70*30877f79SAndroid Build Coastguard WorkerThis failure is a performance problem, where the video decoder under test was 71*30877f79SAndroid Build Coastguard Workerlate decoding a large number of buffers. In the example above, ExoPlayer dropped 72*30877f79SAndroid Build Coastguard Worker200 buffers because they were late by the time they were dequeued, for a test 73*30877f79SAndroid Build Coastguard Workerthat imposes a limit of 25. The most obvious cause is that the video decoder 74*30877f79SAndroid Build Coastguard Workeris too slow decoding buffers. If the failures only occur for the subset of tests 75*30877f79SAndroid Build Coastguard Workerthat play Widevine protected content, it's likely that the platform operations 76*30877f79SAndroid Build Coastguard Workerfor buffer decryption are too slow. We recommend checking the performance of 77*30877f79SAndroid Build Coastguard Workerthese components, and looking at whether any optimizations can be made to speed 78*30877f79SAndroid Build Coastguard Workerthem up. 79*30877f79SAndroid Build Coastguard Worker 80*30877f79SAndroid Build Coastguard Worker### Native window could not be authenticated ### 81*30877f79SAndroid Build Coastguard Worker 82*30877f79SAndroid Build Coastguard WorkerLogcat will contain an error similar to: 83*30877f79SAndroid Build Coastguard Worker~~~ 84*30877f79SAndroid Build Coastguard WorkerSurfaceUtils: native window could not be authenticated 85*30877f79SAndroid Build Coastguard WorkerExoPlayerImplInternal: Internal runtime error. 86*30877f79SAndroid Build Coastguard WorkerExoPlayerImplInternal: android.media.MediaCodec$CodecException: Error 0xffffffff 87*30877f79SAndroid Build Coastguard Worker~~~ 88*30877f79SAndroid Build Coastguard Worker{: .language-shell} 89*30877f79SAndroid Build Coastguard WorkerThis failure is indicative of the platform failing to correctly set the secure 90*30877f79SAndroid Build Coastguard Workerbit flag. 91*30877f79SAndroid Build Coastguard Worker 92*30877f79SAndroid Build Coastguard Worker### Test timed out ### 93*30877f79SAndroid Build Coastguard Worker 94*30877f79SAndroid Build Coastguard WorkerLogcat will contain an error similar to: 95*30877f79SAndroid Build Coastguard Worker~~~ 96*30877f79SAndroid Build Coastguard WorkerAssertionFailedError: Test timed out after 300000 ms. 97*30877f79SAndroid Build Coastguard Worker~~~ 98*30877f79SAndroid Build Coastguard Worker{: .language-shell} 99*30877f79SAndroid Build Coastguard WorkerThis failure is most often caused by poor network connectivity during the test 100*30877f79SAndroid Build Coastguard Workerrun. If the device appears to have good network connectivity then it's possible 101*30877f79SAndroid Build Coastguard Workerthat the test is getting stuck calling into a platform component (e.g. 102*30877f79SAndroid Build Coastguard Worker`MediaCodec`, `MediaDrm`, `AudioTrack` etc). Inspect the call stacks of the 103*30877f79SAndroid Build Coastguard Workerthreads in the test process to establish whether this is the case. 104*30877f79SAndroid Build Coastguard Worker 105*30877f79SAndroid Build Coastguard Worker[GitHub]: https://github.com/google/ExoPlayer 106