-
Notifications
You must be signed in to change notification settings - Fork 567
Description
Version
Media3 1.2.0
More version details
TimestampWrapper Effect with exoPlayer.setVideoEffects causes crash
I am trying this code
@OptIn(UnstableApi::class)
private fun initializePlayer() {
// ExoPlayer implements the Player interface
player = ExoPlayer.Builder(this)
.build()
.also { exoPlayer ->
viewBinding.videoView.player = exoPlayer
// Update the track selection parameters to only pick standard definition tracks
exoPlayer.trackSelectionParameters = exoPlayer.trackSelectionParameters
.buildUpon()
.setMaxVideoSizeSd()
.build()
val timeWrappedEffect: GlEffect = TimestampWrapper(
createOverlayEffect(),
(1000 * 1000).toLong(),
(5000 * 1000).toLong()
)
val effects = ImmutableList.Builder<Effect>()
effects.add(timeWrappedEffect)
exoPlayer.setMediaItems(abcd2())
exoPlayer.playWhenReady = playWhenReady
exoPlayer.setVideoEffects(effects.build())
exoPlayer.addListener(playbackStateListener)
exoPlayer.prepare()
exoPlayer.play()
}
}
@OptIn(UnstableApi::class)
fun createOverlayEffect(): OverlayEffect {
val overlaysBuilder = ImmutableList.Builder<TextureOverlay>()
val logoSettings =
OverlaySettings.Builder()
// Place the logo in the bottom left corner of the screen with some padding from the
// edges.
.setOverlayFrameAnchor(/* x= */ 1f, /* y= */ 1f)
.setBackgroundFrameAnchor(/* x= */ -0.95f, /* y= */ -0.95f)
.build()
val logo = packageManager.getApplicationIcon(packageName);
logo.setBounds(
/* left= */ 0, /* top= */ 0, logo.getIntrinsicWidth(), logo.getIntrinsicHeight()
);
val logoOverlay = DrawableOverlay.createStaticDrawableOverlay(logo, logoSettings);
overlaysBuilder.add(logoOverlay);
val overlays = overlaysBuilder.build()
return OverlayEffect(overlays)
}
fun abcd2(): List<MediaItem> {
return selectedList.map { uri: AssetInfo ->
MediaItem.Builder()
.setUri(uri.uriString)
.setClippingConfiguration(
MediaItem.ClippingConfiguration.Builder()
.setStartPositionMs(0)
.setEndPositionMs(10000)
.build()
)
.build()
}
When we try to use createOverlayEffect()
directly the video is rendered , however it causes a crash when we try to use TimestampWrapper
this is the error log
Playback error androidx.media3.exoplayer.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(null, null, null, video/raw, null, -1, null, [0, 0, -1.0, null], [-1, -1]), format_supported=NO_UNSUPPORTED_TYPE at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:608) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.os.HandlerThread.run(HandlerThread.java:67) Caused by: androidx.media3.exoplayer.video.VideoSink$VideoSinkException: androidx.media3.common.VideoFrameProcessingException: java.lang.IllegalStateException: Textures are all in use. Please release in-use textures before calling useTexture. at androidx.media3.exoplayer.video.CompositingVideoSinkProvider$VideoSinkImpl.lambda$onError$0$androidx-media3-exoplayer-video-CompositingVideoSinkProvider$VideoSinkImpl(CompositingVideoSinkProvider.java:462) at androidx.media3.exoplayer.video.CompositingVideoSinkProvider$VideoSinkImpl$$ExternalSyntheticLambda2.run(Unknown Source:4) at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:31) at androidx.media3.exoplayer.video.CompositingVideoSinkProvider$VideoSinkImpl.onError(CompositingVideoSinkProvider.java:451) at androidx.media3.effect.SingleInputVideoGraph$1.lambda$onError$2$androidx-media3-effect-SingleInputVideoGraph$1(SingleInputVideoGraph.java:143) at androidx.media3.effect.SingleInputVideoGraph$1$$ExternalSyntheticLambda0.run(Unknown Source:4) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.os.HandlerThread.run(HandlerThread.java:67) Caused by: androidx.media3.common.VideoFrameProcessingException: java.lang.IllegalStateException: Textures are all in use. Please release in-use textures before calling useTexture. at androidx.media3.effect.VideoFrameProcessingTaskExecutor.handleException(VideoFrameProcessingTaskExecutor.java:224) at androidx.media3.effect.VideoFrameProcessingTaskExecutor.lambda$wrapTaskAndSubmitToExecutorService$2$androidx-media3-effect-VideoFrameProcessingTaskExecutor(VideoFrameProcessingTaskExecutor.java:210) at androidx.media3.effect.VideoFrameProcessingTaskExecutor$$ExternalSyntheticLambda2.run(Unknown Source:6) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:463) at java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) at java.lang.Thread.run(Thread.java:1012) Caused by: java.lang.IllegalStateException: Textures are all in use. Please release in-use textures before calling useTexture. at androidx.media3.effect.TexturePool.useTexture(TexturePool.java:89) at androidx.media3.effect.BaseGlShaderProgram.queueInputFrame(BaseGlShaderProgram.java:144) at androidx.media3.effect.TimestampWrapperShaderProgram.queueInputFrame(TimestampWrapperShaderProgram.java:84) at androidx.media3.effect.FrameConsumptionManager.lambda$queueInputFrame$1$androidx-media3-effect-FrameConsumptionManager(FrameConsumptionManager.java:96) at androidx.media3.effect.FrameConsumptionManager$$ExternalSyntheticLambda1.run(Unknown Source:6) at androidx.media3.effect.VideoFrameProcessingTaskExecutor.lambda$wrapTaskAndSubmitToExecutorService$2$androidx-media3-effect-VideoFrameProcessingTaskExecutor(VideoFrameProcessingTaskExecutor.java:208) at androidx.media3.effect.VideoFrameProcessingTaskExecutor$$ExternalSyntheticLambda2.run(Unknown Source:6) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:463) at java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) at java.lang.Thread.run(Thread.java:1012) 2023-11-18 11:26:57.219 1262-3355 WindowManager system_server E win=Window{3c1e04c u0 com.trywork.video.MainActivity} destroySurfaces: appStopped=true cleanupOnResume=false win.mWindowRemovalAllowed=false win.mRemoveOnExit=false win.mViewVisibility=8 caller=com.android.server.wm.ActivityRecord.destroySurfaces:6776 com.android.server.wm.ActivityRecord.destroySurfaces:6757 com.android.server.wm.ActivityRecord.notifyAppStopped:6821 com.android.server.wm.ActivityRecord.activityStopped:7427 com.android.server.wm.ActivityClientController.activityStopped:263 android.app.IActivityClientController$Stub.onTransact:621 com.android.server.wm.ActivityClientController.onTransact:141
Devices that reproduce the issue
Samsung Galaxy tab A7 lite Android 13
Devices that do not reproduce the issue
did no try
Reproducible in the demo app?
Yes
Reproduction steps
just try code from this or any other simple video playback example from exoplayer
https://www.youtube.com/watch?v=Hw0Jeq42FNU&t=315s
and added the above code for effects
First try the simple exoPlayer.setVideoEffects(createOverlayEffect()) the video plays perfectly
Then try
val effects = ImmutableList.Builder<Effect>()
effects.add(timeWrappedEffect)
exoPlayer.setVideoEffects(effects.build())
this will crash the app
Expected result
video should render with overlay for the selected duration in imeWrappedEffect
Actual result
video doesnot render and app crashed after that
Media
it is the same url used in the example shared by google itself in the video on youtube the link of which I have shared above
Bug Report
- You will email the zip file produced by
adb bugreport
to android-media-github@google.com after filing this issue.