google / google/ExoPlayer

Getting ExoPlaybackException->IllegalArgumentException during setVideoSurface(null)

Open
#6,355 5 comments 1 reaction 1 assignee Assigned to @microkatz View on GitHub
needs triage question
Dominant language
Java
Stars
21.9k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

### [REQUIRED] Issue description
Getting error while releasing surface:
```
main|E] EventLogger: playerFailed [4.80, 1.08, window=0, period=0]
com.google.android.exoplayer2.ExoPlaybackException: java.lang.IllegalArgumentException
at com.google.android.exoplayer2.t.handleMessage(ExoPlayerImplInternal.java:24)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:193)
at android.os.HandlerThread.run(HandlerThread.java:65)
Caused by: java.lang.IllegalArgumentException: null
at android.media.MediaCodec.native_setSurface(Native Method)
at android.media.MediaCodec.setOutputSurface(MediaCodec.java:1979)
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.a(MediaCodecVideoRenderer.java:176)
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.a(MediaCodecVideoRenderer.java:73)
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.a(MediaCodecVideoRenderer.java:57)
at com.google.android.exoplayer2.t.c(ExoPlayerImplInternal.java:9)
at com.google.android.exoplayer2.t.e(ExoPlayerImplInternal.java:4)
at com.google.android.exoplayer2.t.d(ExoPlayerImplInternal.java:50)
at com.google.android.exoplayer2.t.handleMessage(ExoPlayerImplInternal.java:4)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:193)
at android.os.HandlerThread.run(HandlerThread.java:65)
```
or
```
java.lang.IllegalStateException
at com.google.android.exoplayer2.t.handleMessage(ExoPlayerImplInternal.java:24)
at android.os.Handler.dispatchMessage(Handler.java:101)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)
Caused by: java.lang.IllegalStateException: null
at android.media.MediaCodec.native_setSurface(Native Method)
at android.media.MediaCodec.setOutputSurface(MediaCodec.java:1954)
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.a(MediaCodecVideoRenderer.java:176)
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.a(MediaCodecVideoRenderer.java:73)
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.a(MediaCodecVideoRenderer.java:57)
at com.google.android.exoplayer2.t.c(ExoPlayerImplInternal.java:9)
at com.google.android.exoplayer2.t.e(ExoPlayerImplInternal.java:4)
at com.google.android.exoplayer2.t.d(ExoPlayerImplInternal.java:50)
at com.google.android.exoplayer2.t.handleMessage(ExoPlayerImplInternal.java:4)
at android.os.Handler.dispatchMessage(Handler.java:101)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)
```

I'm not sure if it should be handled by the app, cause of integration specifics, or it can be workarounded with `MediaCodeVideoRenderer.codecNeedsSetOutputSurfaceWorkaround`.
In other cases decoder errors are wrapped to `MediaCodecVideoRenderer.VideoDecoderException` and it's easier to identify them and apply app-specific handling.

### [REQUIRED] Reproduction steps
This is part of "tv input service" which adopts TIF on Android TV.
When `TvInputService.Session.onSetSurface(null)` is called - this call routed to `SimpleExoPlayer.setVideoSurface`.
Due TIF integration specifics - surface is owned by host app (Live TV/Live Channels) and "tv input service" does not own it's lifecycle.

### [REQUIRED] Link to test content
non-applicable

### [REQUIRED] A full bug report captured from the device
no full report, since issue is observed on user's devices through Crashlytics

### [REQUIRED] Version of ExoPlayer being used
e267550d95a72ba7261eddad6dea8f8ce379e8e8

### [REQUIRED] Device(s) and version(s) of Android being used
According to crashlytics devices distribution looks like:
56% Xiaomi
20% Droidlogic
8% Amlogic
4% fengmi
12% Other (12)

Some of them :
```
System: 4.9.113 (20190809)
Sdk: 28
Device: galilei
Product: galilei
Manufacturer: AZW Model: GTKing
```
```
Brand: Droidlogic
Model: X96Max_V311_P
Operating System Version: 9
Rooted: Yes
```
```
Brand: Droidlogic
Model: Tx5
Operating System Version: 9
Rooted: Yes
```
```
Brand: Amlogic
Model: TX5 Pro
Operating System Version: 8.1.0
Rooted: Yes
```
```
Brand: Xiaomi
Model: MiBox S
Operating System Version: 8.1.0
Rooted: No
```
```
Brand: Amlogic
Model: TX5 Pro
Operating System Version: 8.1.0
Rooted: Yes
```
```
Brand: NVIDIA
Model: SHIELD TV
Operating System Version: 9
Rooted: No
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.