ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Some Android 10 devices has ANR

Open jasoncfpl opened this issue 2 years ago • 4 comments

Bug

android.os.BinderProxy.transactNative(Native Method) android.os.BinderProxy.transact(BinderProxy.java:610) android.media.IAudioService$Stub$Proxy.getStreamVolume(IAudioService.java:4565) android.media.AudioManager.getStreamVolume(AudioManager.java:1210) com.google.android.exoplayer2.StreamVolumeManager.getVolumeFromManager(StreamVolumeManager.java:1) com.google.android.exoplayer2.StreamVolumeManager.(StreamVolumeManager.java:8) com.google.android.exoplayer2.SimpleExoPlayer.(SimpleExoPlayer.java:60) com.google.android.exoplayer2.SimpleExoPlayer$Builder.build(SimpleExoPlayer.java:3) io.flutter.plugins.videoplayer.VideoPlayer.(VideoPlayer.java:7) io.flutter.plugins.videoplayer.VideoPlayerPlugin.create(VideoPlayerPlugin.java:16)

jasoncfpl avatar Apr 26 '23 08:04 jasoncfpl

This is unfortunately something to be expect on some devices or devices with high load.

When the build() call is made a StreamVolumeManager will be created that will directly try to read audioManager to get current volume. Since this requires a bind call that is blocking, this can and will ANR sometimes.

See the Play Store explanation for those kind of issues:

image

Since ExoPlayer recommend using main thread this is somewhat expected that most will create the player in main thread too.

You can mitigate this by creating the player in a background thread and use setLooper to set the proper main thread looper.

Tolriq avatar Apr 26 '23 15:04 Tolriq

We're closing this issue because there hasn't been any recent activity.

rohitjoins avatar Jun 13 '23 12:06 rohitjoins

@rohitjoins This is certainly to be considered a bug of ExoPlayer....

You are doing an IPC blocking call on init of the StreamVolumeManager this should not be done and is an error that should be addressed. The workaround to init ExoPlayer in the background is a workaround and is not documented anywhere as recommended so people are facing this in prod.

Tolriq avatar Jun 13 '23 12:06 Tolriq

Hi! We are experiencing hundreds of such anrs per month. Are there any plans on it?

AntonMalykh avatar Mar 04 '24 08:03 AntonMalykh