Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANR on speficic devices when SurfaceView Visibility is set to GONE since version 2.5.0 #3724

Closed
ba-a opened this issue Jan 18, 2018 · 8 comments
Assignees

Comments

@ba-a
Copy link

ba-a commented Jan 18, 2018

Issue description

We recently updated the ExoPlayer version in our app from 2.4.0 to 2.6.1. After that we got a lot of ANR reports in the developer console, mostly from the Huawei P8 Lite.
This is important, on most devices the error doesn't occur, but on this and a couple others it happens every time you try to set up the player.

When setting up the player, the stream starts running (you can hear the sound) but the video is not being rendered. (The first frame is shown but stuck) As soon as there is an attempt to interact, the ANR is triggered and the app does not respond anymore.

After a lot of time spent investigating the problem (sorry for the whining but it was painful 😄 ) we found out that setting the visibility of the SurfaceView during the loading time of the player is causing the problem. (TextureView is fine, happening only with SurfaceView)
We tracked it down, the ANR happens since ExoPlayer Version 2.5.0 and ever since. Before that (until 2.4.4) it is not a problem.

We set the visibility to show some loading screen stuff as long as the stream needs to load. We can probably work around that but I thought it would be interesting to know what is causing the problem. Especially since it's only happening for special devices.

Reproduction steps

We could reproduce the problem on a slightly modified version of the demo app. Here is a fork of the ExoPlayer project with the necessary changes. We didn't release the player here in onPause because we reuse the instance in our app to show different streams.

https://github.com/ba-a/ExoPlayer

The commit with the changes:
ba-a@56af4de

To reproduce:

  • open the app
  • start any video, f.e. Youtube dash, Google Glass
  • press back
    -> ANR Huawei P8 Lite

Version of ExoPlayer being used

ExoPlayer 2.5.0 or higher also tried out 2.6.0 and 2.6.1

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

Huawei P8 Lite
Android 6

A full bug report captured from the device

Here is traces log from the device. The player gets stuck in
ExoPlayerImplInternal.blockingSendMessages
I guess waiting for a message that is never delivered.
ANR Huawei P8 Lite traces.txt

If you need any more input just let me know.
Best regards

@ojw28
Copy link
Contributor

ojw28 commented Jan 19, 2018

Thanks for the detailed report. Could you try hardcoding MediaCodecVideoRenderer.codecNeedsSetOutputSurfaceWorkaround to return true? If that resolves the issue then we should add a case into that method for the affected device. Please let us know!

@ojw28
Copy link
Contributor

ojw28 commented Jan 19, 2018

As an aside, it's generally less error prone to have the SurfaceView always visible, and to place another view on top of it if you want to show something else.

@ojw28
Copy link
Contributor

ojw28 commented Jan 19, 2018

I got hold of a device. It looks like hardcoding codecNeedsSetOutputSurfaceWorkaround to return true, and also hardcoding shouldUseDummySurface to return false, properly works around the issue. We'll follow up with a proper fix shortly, which will:

  • Include the AVC decoder on P8 in codecNeedsSetOutputSurfaceWorkaround.
  • Update shouldUseDummySurface to return false in cases where the output surface workaround is required, since it actually makes things worse rather than better in that case.

@ba-a
Copy link
Author

ba-a commented Jan 22, 2018

As always, thanks for the quick response and detailed information for a fix. 👍
I will try this out as well and give feedback again.

@4xes
Copy link

4xes commented Jan 22, 2018

Also got this ANR after update ExoPlayer.
This applies to multiple devices, just on P8 more often:

P8 Lite (hwALE-H) | 505 | 65.7%
Y6II (HWCAM-H) | 201 | 26.1%
Redmi Note 4 (mido) | 10 | 1.3%
honor 6C Pro (HWJMM) | 9 | 1.2%
hi6210sft | 7 | 0.9%
vivo 1716 (1716) | 5 | 0.7%
Mi A1 (tissot_sprout) | 4 | 0.5%
Redmi 4X (santoni) | 3 | 0.4%
Moto G (5th Gen) (cedric) | 2 | 0.3%
vivo 1611 (1611) | 2 | 0.3%
Redmi 3S (land) | 2 | 0.3%
Z2 (z2r) | 2 | 0.3%
Mi 5 (gemini) | 1 | 0.1%
Moto E (2nd Gen) (otus_ds) | 1 | 0.1%
Honor 6A (HWDLI-Q) | 1 | 0.1%
err_value | 1 | 0.1%
HUAWEI MediaPad M3 Lite (HWCPN-Q) | 1 | 0.1%
Moto Z Play Droid (addison) | 1 | 0.1%
Moto G (5) Plus (potter_n) | 1 | 0.1%
p212 | 1 | 0.1%
Others | 9 | 1.2%

@ba-a
Copy link
Author

ba-a commented Jan 22, 2018

Another thing I just mentioned is, it doesn't seem to be a problem if the SurfaceView is wrapped in a layout and the visibility is set on the layout. As long as the SurfaceView stays untouched it's fine.

ojw28 added a commit that referenced this issue Jan 23, 2018
Also disable use of dummy surface for devices that require the
workaround. It's only useful in the case that we can use
setOutputSurfaceWorkaround, so if it's disabled the dummy surface
has no purpose (it actually makes things worse by consuming past
the key-frame prior to the current position, which doesn't happen
if you have no surface at all).

Issue: #3724

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182750068
@ojw28
Copy link
Contributor

ojw28 commented Jan 23, 2018

This should be fixed for the P8 Lite in the dev-v2 branch. Please verify if possible. I'm trying to get hold of a Huawei Y6II too.

@ba-a
Copy link
Author

ba-a commented Jan 29, 2018

@ojw28 We integrated today the dev-v2 Branch in our app and by now it works pretty well. No ANRs so far. 🤞 Big thanks for the quick fix! I'm looking for the release.

ojw28 added a commit that referenced this issue Feb 16, 2018
Issue: #3724

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185548632
@ojw28 ojw28 closed this as completed Feb 16, 2018
ojw28 added a commit that referenced this issue Feb 20, 2018
Issue: #3724

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185548632
@google google locked and limited conversation to collaborators Jun 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants