60 FPS Widevine DASH content stutters on some devices
Content description
60 FPS Widevine encrypted DASH streams stutter and/or have many dropped frames. The (per email) provided content shows a live ticker at the bottom, where this stuttering and frame drops can be observed very well.
There are players like the NexPlayer (https://www.nexplayersdk.com/), which shows better performance on the same content and devices, therefore we rule out a weak DRM decryption module or hardware decoders.
We also tried to find the bottleneck in the code base, tried to tweak several parameters, and implemented a decoder version using the asynchronous callback Android provides. Unfortunately without major improvements.
Additionally, on the more powerful/recent devices we observed that frames are provided to the Surface in time (ExoPlayer business logic did not drop the frames) but the stuttering was still visible. When we changed the code so that the renderTimeStamp passed to releaseOutputBuffer is not "reasonably close" to the current system time (which causes the Surface to ignore the timestamp and display the buffer at the earliest feasible time. In this mode the Surface will not drop frames), we did not see any stuttering/frame drops anymore as expected. However, over time video and audio were drifting apart as if video would not be playing at 60 FPS anymore but rather at a lower frame rate. This observation lead us to the assumption that the surface itself maybe cannot keep up with the high frame rate.
Link to test content
Provided per email.
Version of ExoPlayer being used
2.10.4 and at least back to 2.9.6
Device(s) and version(s) of Android being used
Seems unrelated to the Android version. Seen issues with:
- OnePlus 5T
- OnePlus 5
- Galaxy Tab E (SM-T337W) | 7.1.1, 6.0.1
- Galaxy Tab 3 Lite (SM-T113) | 4.4.4
- Galaxy S8 (Canadian and "regular" version) | 9.0.0
- OnePlus 5 | 9.0.0
- Google Pixel 3 | 9.0.0
- Samsung S6 (SM-G928V) | 7.0.0
- Samsung S7 (SM-G930T1) | 8.0.0
- Galaxy Tab 3 10.1 (GT-P5210)
- Huawei P30 Lite (MAR-LX3A)
- Galaxy Tab 3 (SM-T310)
- Galaxy Tab S3 (SM-T820)
- Galaxy Tab S2 (SM-T810) | 6.0.1,7.0,7.0
- Galaxy Core (SM-G386) | 4.4.2
- Galaxy Tab 4 (SM-T230) | 4.4.2
- MiBox3 (MIBOX3) | 8.0.0
- Galaxy A8 (SM-A530W) | 7.1.1,8.0.0,9
A full bug report captured from the device
Provided per email.
@ojw28 Have you had already time to check this? If not, can you maybe provide a time frame?
We are happy to support you in further investigation, just let me know.
@christosts - We should probably treat this as a duplicate of https://github.com/google/ExoPlayer/issues/5796 (or at least investigate both at the same time). The test content and information above will be useful for helping to look at that issue.
Ack
Hi @matamegger
Checked the DASH links provided over email yesterday and they returned 404*. Can you please check the health status of the links, and if they are not alive anymore, maybe provide new ones?
Also, regarding:
When we changed the code so that the renderTimeStamp passed to releaseOutputBuffer is not "reasonably close" to the current system time
Can you please share the change you made so that we can attempt to reproduce the behavior?
Thanks.
[edit] *I tried to access the links from a browser and got the 404.
We are experiencing - what probably is - the same issue with widevine drm, but with video tracks that are 720p50fps. They work fine unencrypted.
Iv'e done several tests with one problematic device, Xiamo Mi A3 (with Android One). Changing between L1/L3 does nothing. The only thing that helps is disableing the audio renderer (for some reason)
There's also an old issue from last year about this, but it's closed with no resolution. https://github.com/google/ExoPlayer/issues/4496
@christosts I will check back on the assets, and provide you the renderTimeStamp change asap.
Regarding the "renderTimeStamp". It's basically something like the following patch shows.
With this change in the MediaCodecVideoRenderer the Surface will (according to the doc) not drop any frames and renders them as fast as possible.
.../library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java
@@ -912,8 +912,8 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
protected void renderOutputBufferV21(
MediaCodec codec, int index, long presentationTimeUs, long releaseTimeNs) {
maybeNotifyVideoSizeChanged();
TraceUtil.beginSection("releaseOutputBuffer");
- codec.releaseOutputBuffer(index, releaseTimeNs);
+ codec.releaseOutputBuffer(index, 0);
TraceUtil.endSection();
lastRenderTimeUs = SystemClock.elapsedRealtime() * 1000;
decoderCounters.renderedOutputBufferCount++;
Note: This is only executed on devices API >= 21
@matamegger
thanks. If you can check the content links (they are returning 404) and provide working links, I will try to repro and come back with findings.
Mailed you a new set of assets.
Hi Matthias.
An update:
When tested with a Galaxy S7 (SM-G930F), I can see frames being dropped by the player at 60fps at the highest bitrate track. I will work on that to see why the player drops frames.
Apart from that, there is the issue for frames being dropped by the surface and not the player. May I ask how observable is the problem in this case?
For example, in the test content I can see there's a news reel at the bottom which sometimes has glitches, and also there are glitches on the bottom right window. Is this the problem you observed? On my tests, I can see these glitches but not with the same severity across different devices (Samsung Galaxy S7, Pixel 2/3). In addition, I cannot observe glitches on the main window of the content. Therefore I am not 100% sure if these glitches are in content itself (from encoding) or happening at the device, therefore what you describe as frames being dropped by the surface.
I did not see a difference in the glitches by changing the releaseOutputBuffer() param to 0.
Yes, depending on the device the "main content" is not glitching, on older or weaker phones the main content also has glitches, but in this case the glitches might be expected due to the processing power of the devices. The glitches can be observed the best in the news ticker. Which should run smoothly (The glitches are not an effect of encoding or the content).
Depending on the device either exoplayer or the surface (maybe even both) drop frames. For your tests, you could try to disable the frame dropping of exoplayer, to see the pure surface drops. (Disabling by commenting/deleting the drop code).
Hey there. We've also been facing exactly this issue. I agree with @ojw28 in that in order to really fix this problem, multithreaded rendering is required. I noticed that changing the time interval between rendering loops helps a bit. The delay is hardcoded to be 10ms, changing it to 0 definitely helped us.
.../library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java
@@ -83,7 +83,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
private static final int MSG_PLAYBACK_PARAMETERS_CHANGED_INTERNAL = 17;
private static final int PREPARING_SOURCE_INTERVAL_MS = 10;
- private static final int RENDERING_INTERVAL_MS = 10;
+ private static final int RENDERING_INTERVAL_MS = 0;
private static final int IDLE_INTERVAL_MS = 1000;
private final Renderer[] renderers;
With this change, some frames are still dropped depending on the device used though. I'm pretty sure this is not enough to be a production-ready patch, but maybe an improvement could be done by dynamically adjusting this value until proper multithreaded rendering is implemented.
Just an update:
As mentioned in my previous comment, when tested the 60fps 5.7Mbits widevine stream on a Galaxy S7, I can see ExoPlayer (not the surface) is dropping frames. I am working to address that. The fix will probably be inline with adding threads to handle rendering.
With regards to the 'glitches' in the news ticker. I am not sure it is the surface or I am not seeing the same symptoms. In detail, I played the 60fps track offline on multiple devices and multiple players (and asked more people to view!) and saw glitching on the news ticker on all setups.
- Samsung S7: ExoPlayer and VLC
- Linux: Media player and VLC
- Mac: Quicktime Player and VLC
In all devices/players, the ticker did not run 100% smoothly, which I interpret there is some glitching encoded. But I can't tell of course if the glitching that I observe is the same as the glitch reported originally.
@matamegger would you mind trying something similar, that is try to play offline the 60fps/5.7mbit content and see if you can see similar glitch along devices/players?
There are no glitches in the stream itself. We have validated this many times. Chrome reports a decoder underflow Quick chrome://media-internals
Also by observing the glitches closer and multiple times, one can see that they do not happen on the same position in the content.
Hi. We are facing similar problems. Is there any updates to this issue?
In our case it's 720p50fps which is causing stuttering and a lot of dropped frames on some devices. Most problematic on Google Pixel (Gen1) running Android 10, but also on a few other devices.
We found a (to us) weird thing though which I would love to get help understanding. If we keep the main thread busy by either tapping quickly on the screen to show/hide player controls or by pressing the volume rocker to show the volume slider video becomes smooth with no dropped frames. You can see the behavior in this screen capture: https://www.dropbox.com/s/039slthc6gbzzyo/sailfishQP1A.191005.007.A1eneroth01302020120714.mp4?dl=0
Video is blacked out, but you can see the db count increasing quickly until I start toggling the player controls during which db count is not increasing and video is playing fine.
We could also reduce the dropped frames by starting an endless Runnable no-op loop on the main thread while video was playing. But this still causes a few frame drops, so not a production stable workaround.
Reproduced this issue on the ExoPlayer demo app, running version 2.11.1.
Hi. We are facing similar problems. Is there any updates to this issue?
We have been working on it. It is still in progress but let me share an update.
Note: the following comment points to experimental code that is available on the dev-2 branch but it is still under testing/evaluation. Therefore we cannot guarantee at the moment the feature's stability or that the API will not change in a future release.
As a first step, we are experimenting with operating Android's MediaCodec in asynchronous mode. We have seen (in some devices) this alone improves the MediaCodec's performance. In the dev2 branch, the DefaultRenderersFactory currently has the method experimental_setMediaCodecOperationMode which sets ExoPlayer's MediaCodec operation mode. At the moment, there are four modes available: OPERATION_MODE_SYNCHRONOUS is the existing behavior and there are 3 additional modes which basically set the MediaCodec in asynchronous mode but differ in the threading model or implementation details (documented here).
For high frame rate video, we expect OPERATION_MODE_ASYNCHRONOUS_DEDICATED_THREAD and OPERATION_MODE_ASYNCHRONOUS_DEDICATED_THREAD_MULTI_LOCK to provide better performance because they introduce additional threads for the MediaCodec callbacks. That said, we are evaluating their impact on other aspects such as battery use and performance on devices on the lower end w.r.t. CPU.
We will be happy if you can experiment with the feature and provide feedback, but let me repeat that this feature is still under internal evaluation and the API is not final. An easy way would be to checkout the dev2 branch, set the MediaCdec operation mode in the demo app and play your test video.
On top of this work, we plan to add additional parallelization to offload the player's internal thread. When this feature is available on the dev2 branch, we will announce the experimental features (possibly in our blog) and invite the community to experiment and provide feedback.
@fredrikeneroth can share a link to the 720p50fps video to test it on a Pixel? If you cannot share it in public, will you be able to email to [email protected] with subject "Issue #6348"?
Thanks
Okay, that sounds promising @christosts. Will try it out. I've sent the test content to your email. Let me know if it doesn't work or if you need any additional content.
Update: I tried the dev-v2 branch and all of the different operation modes. Unfortunately it didn't help with the dropped frames. I also just mailed you some new up-to-date test content.
An update:
We are seeing varying performance improvements between devices. For example, for Pixel (Gen 1) we got a noticeable reduction on dropped frames (10x). But for some other devices the performance improvement is small and does not make a noticeable difference.
@fredrikeneroth what were the devices you tested with?
We expect to push the additional code improvements for high fps soon (hopefully within Febr 2020), in which case I will update the ticket accordingly.
Thanks