androidx / androidx/media

Videos stuck on buffering forever, and getting "ExoTimeoutException: Detaching surface timed out" after seeking to other videos

Open
#1,772 4 comments 7 reactions 1 assignee View on GitHub

@icbaker is already working on this.

Since Oct 7, 2024.

bug
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

Version

Media3 1.4.1

More version details

No response

Devices that reproduce the issue

I was able to reproduce on Pixel 7 pro with Android 15

The following report is from Crashlytics:

27% Honor

  • 5% Honor X5 Plus
  • 4% Honor X6
  • 4% Honor X7a

16% Oppo

  • 9% A57
  • 3% A57s/A77
  • 2% A17

15% Samsung

  • 2% Galaxy A03s
  • 1% Galaxy A03s

OS:
41% Android 14
30% Android 12
20% Android 13
3% Android 10

Devices that do not reproduce the issue

All emulator seems working fine with those videos

Reproducible in the demo app?

Not tested

Reproduction steps

Created a minimal reproducible project here
https://github.com/kevinguitar/video-pager/tree/main

  1. Open the app
  2. Swipe down to start playback those problematic videos
Expected result

I would expect two possible results:

  1. The player can play those videos
  2. Even if the player cannot playback those videos, it shouldn't stuck on buffering, and I expect some reasonable error message. Moreover, it shouldn't affect other videos playback.

This issue is really affecting us significantly, I'm all in to provide whatever information you'll need to investigate, please let me know 🙏 Please and thank you!

Actual result

The player stuck forever in the buffering state, here are the logs with EventLogger:

16:34:01.998  D  loading [eventTime=38.57, mediaPos=3.50, window=0, period=0, true]
16:34:02.030  D  loading [eventTime=38.60, mediaPos=3.50, window=0, period=0, false]
16:34:02.034  D  loading [eventTime=38.60, mediaPos=3.54, window=0, period=0, true]
16:34:02.077  D  loading [eventTime=38.65, mediaPos=3.58, window=0, period=0, false]
16:34:02.098  D  positionDiscontinuity [eventTime=38.67, mediaPos=0.00, window=1, reason=SEEK, PositionInfo:old [mediaItem=0, period=0, pos=3600], PositionInfo:new [mediaItem=1, period=1, pos=0]]
16:34:02.098  D  mediaItem [eventTime=38.67, mediaPos=0.00, window=1, reason=SEEK]
16:34:02.098  D  tracks [eventTime=38.67, mediaPos=0.00, window=1
16:34:02.098  D  ]
16:34:02.098  D  state [eventTime=38.67, mediaPos=0.00, window=1, BUFFERING]
16:34:02.098  D  isPlaying [eventTime=38.67, mediaPos=0.00, window=1, false]
16:34:02.100  D  videoSize [eventTime=38.67, mediaPos=0.00, window=0, period=0, 720, 1280]
16:34:02.103  D  renderedFirstFrame [eventTime=38.67, mediaPos=0.00, window=0, period=0, Surface(name=android.graphics.SurfaceTexture@5aad852 mNativeObject=-5476376655747503696)/@0x9134723]
16:34:02.111  D  videoDisabled [eventTime=38.68, mediaPos=0.00, window=0, period=0]
16:34:02.111  D  videoSize [eventTime=38.68, mediaPos=0.00, window=0, period=0, 0, 0]
16:34:02.122  D  surfaceSize [eventTime=38.69, mediaPos=0.00, window=0, period=0, 1080, 1080]
16:34:02.125  D  audioDisabled [eventTime=38.70, mediaPos=0.00, window=0, period=0]
16:34:02.126  D  positionDiscontinuity [eventTime=38.70, mediaPos=0.00, window=1, reason=SEEK_ADJUSTMENT, PositionInfo:old [mediaItem=1, period=1, pos=0], PositionInfo:new [mediaItem=1, period=1, pos=0]]
16:34:02.127  D  loading [eventTime=38.70, mediaPos=0.00, window=1, period=1, true]
16:34:02.127  D  audioTrackReleased [eventTime=38.70, mediaPos=0.00, window=1, period=1, 2,12,48000,false,false,61568]
16:34:02.128  D  timeline [eventTime=38.70, mediaPos=0.00, window=1, period=1, periodCount=4, windowCount=4, reason=SOURCE_UPDATE
16:34:02.128  D    period [5.72]
16:34:02.128  D    period [?]
16:34:02.128  D    period [?]
16:34:02.128  D    ...
16:34:02.128  D    window [5.72, seekable=true, dynamic=false]
16:34:02.128  D    window [?, seekable=false, dynamic=false]
16:34:02.128  D    window [?, seekable=false, dynamic=true]
16:34:02.128  D    ...
16:34:02.128  D  ]
16:34:02.427  D  timeline [eventTime=39.00, mediaPos=0.00, window=1, period=1, periodCount=4, windowCount=4, reason=SOURCE_UPDATE
16:34:02.427  D    period [5.72]
16:34:02.427  D    period [10.50]
16:34:02.427  D    period [?]
16:34:02.427  D    ...
16:34:02.427  D    window [5.72, seekable=true, dynamic=false]
16:34:02.427  D    window [10.50, seekable=true, dynamic=false]
16:34:02.427  D    window [?, seekable=false, dynamic=true]
16:34:02.427  D    ...
16:34:02.427  D  ]
16:34:02.434  D  videoEnabled [eventTime=39.01, mediaPos=0.00, window=1, period=1]
16:34:02.436  D  audioEnabled [eventTime=39.01, mediaPos=0.00, window=1, period=1]
16:34:02.437  D  tracks [eventTime=39.01, mediaPos=0.00, window=1, period=1
16:34:02.437  D    group [
16:34:02.437  D      [X] Track:0, id=2, mimeType=video/avc, codecs=avc1.4D001E, res=320x568, color=BT709/Limited range/SDR SMPTE 170M/8/8, fps=30.0, supported=YES
16:34:02.437  D    ]
16:34:02.437  D    group [
16:34:02.438  D      [X] Track:0, id=1, mimeType=audio/mp4a-latm, bitrate=170680, codecs=mp4a.40.2, channels=2, sample_rate=44100, language=und, supported=YES
16:34:02.438  D    ]
16:34:02.438  D    Metadata [
16:34:02.438  D      Mp4Timestamp: creation time=3805953565, modification time=3805953566, timescale=600
16:34:02.438  D    ]
16:34:02.438  D  ]
16:34:02.438  D  downstreamFormat [eventTime=39.01, mediaPos=0.00, window=1, period=1, id=2, mimeType=video/avc, codecs=avc1.4D001E, res=320x568, color=BT709/Limited range/SDR SMPTE 170M/8/8, fps=30.0]
16:34:02.440  D  videoInputFormat [eventTime=39.01, mediaPos=0.00, window=1, period=1, id=2, mimeType=video/avc, codecs=avc1.4D001E, res=320x568, color=BT709/Limited range/SDR SMPTE 170M/8/8, fps=30.0]
16:34:02.440  D  downstreamFormat [eventTime=39.01, mediaPos=0.00, window=1, period=1, id=1, mimeType=audio/mp4a-latm, bitrate=170680, codecs=mp4a.40.2, channels=2, sample_rate=44100, language=und]
16:34:02.441  D  audioDecoderReleased [eventTime=39.01, mediaPos=0.00, window=1, period=1, c2.android.aac.decoder]
16:34:02.476  D  audioDecoderInitialized [eventTime=39.05, mediaPos=0.00, window=1, period=1, c2.android.aac.decoder]
16:34:02.476  D  audioInputFormat [eventTime=39.05, mediaPos=0.00, window=1, period=1, id=1, mimeType=audio/mp4a-latm, bitrate=170680, codecs=mp4a.40.2, channels=2, sample_rate=44100, language=und]
16:34:02.496  D  audioTrackInit [eventTime=39.07, mediaPos=0.00, window=1, period=1, 2,12,44100,false,false,56704]
16:34:02.604  D  loading [eventTime=39.17, mediaPos=0.00, window=1, period=1, false]
16:34:02.615  D  loading [eventTime=39.19, mediaPos=0.00, window=1, period=1, true]
16:34:03.200  D  loading [eventTime=39.77, mediaPos=0.00, window=1, period=1, false]
16:34:03.209  D  loading [eventTime=39.78, mediaPos=0.00, window=1, period=1, true]
16:34:03.288  D  loading [eventTime=39.86, mediaPos=0.00, window=1, period=1, false]
16:34:03.293  D  loading [eventTime=39.86, mediaPos=0.00, window=1, period=1, true]
16:34:03.349  D  loading [eventTime=39.92, mediaPos=0.00, window=1, period=1, false]

When I tried to play other videos, I ran into this exception on every seek attempt. Essentially, the player became unusable.

16:35:27.526  E  playerFailed [eventTime=124.09, mediaPos=0.00, window=3, period=3, errorCode=ERROR_CODE_TIMEOUT
                   androidx.media3.exoplayer.ExoPlaybackException: Unexpected runtime error
                       at androidx.media3.exoplayer.ExoPlayerImpl.setVideoOutputInternal(ExoPlayerImpl.java:2747)
                       at androidx.media3.exoplayer.ExoPlayerImpl.setSurfaceTextureInternal(ExoPlayerImpl.java:2708)
                       at androidx.media3.exoplayer.ExoPlayerImpl.setVideoTextureView(ExoPlayerImpl.java:1463)
                       at com.example.videopager.VideoPlayer.setTextureView(VideoPlayer.kt:54)
                       at com.example.videopager.VideoInteractor.setTextureView(VideoInteractor.kt:28)
                       at com.example.videopager.VideoInteractor.play(VideoInteractor.kt:21)
                       at com.example.videopager.MainActivityKt$VideoCard$2$1.invokeSuspend(MainActivity.kt:87)
                       at com.example.videopager.MainActivityKt$VideoCard$2$1.invoke(Unknown Source:8)
                       at com.example.videopager.MainActivityKt$VideoCard$2$1.invoke(Unknown Source:4)
                       at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1$2.emit(Emitters.kt:223)
                       at kotlinx.coroutines.flow.StateFlowImpl.collect(StateFlow.kt:396)
                       at kotlinx.coroutines.flow.StateFlowImpl$collect$1.invokeSuspend(Unknown Source:15)
                       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
                       at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81)
                       at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.android.kt:41)
                       at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57)
                       at android.os.Handler.handleCallback(Handler.java:959)
                       at android.os.Handler.dispatchMessage(Handler.java:100)
                       at android.os.Looper.loopOnce(Looper.java:232)
                       at android.os.Looper.loop(Looper.java:317)
                       at android.app.ActivityThread.main(ActivityThread.java:8756)
                       at java.lang.reflect.Method.invoke(Native Method)
                       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
                   Caused by: androidx.media3.exoplayer.ExoTimeoutException: Detaching surface timed out.
                       at androidx.media3.exoplayer.ExoPlayerImpl.setVideoOutputInternal(ExoPlayerImpl.java:2746)
                       ... 24 more
Media

Problematic videos:
https://bandlab-test-video.azureedge.net/public/9fc787ef-2052-410a-b001-23ff5871c775/original.mp4
https://bandlab-test-video.azureedge.net/public/5c797341-14e2-45ee-a28a-1bc825f42f93/original.mp4

They're used in the sample project here:
https://github.com/kevinguitar/video-pager/blob/main/app/src/main/java/com/example/videopager/VideoPlayer.kt#L20

Bug Report
  • You will email the zip file produced by adb bugreport to android-media-github@google.com after filing this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.