StreamPack: [BUG]: java.lang.SecurityException: Don't re-use the resultData to retrieve the same projection instance, and don't use a token that has timed out. Don't take multiple captures by invoking MediaProjection
Version
main
Environment that reproduces the issue
vivo v2408A-android15
RTMP/SRT/… Server
RTMP/SRT
Audio configuration
No response
Video configuration
No response
Is it reproducible in the demos application?
Yes
Reproduction steps
1.Connect to SRT or RTMP 2.click RECORD SCREEN
Expected result
screenRecorder DEMO can use MediaProjectionAudioSourceFactory
Actual result
screenRecorder DEMO can’t use MediaProjectionAudioSourceFactory creenRecorderSingleStreamer use MediaProjectionAudioSourceFactory SecurityException
Error while starting streamer java.lang.SecurityException: Don’t re-use the resultData to retrieve the same projection instance, and don’t use a token that has timed out. Don’t take multiple captures by invoking MediaProjection#createVirtualDisplay multiple times on the same instance. at android.os.Parcel.createExceptionOrNull(Parcel.java:3256) at android.os.Parcel.createException(Parcel.java:3240) at android.os.Parcel.readException(Parcel.java:3223) at android.os.Parcel.readException(Parcel.java:3165) at android.hardware.display.IDisplayManager$Stub$Proxy.createVirtualDisplay(IDisplayManager.java:1806) at android.hardware.display.DisplayManagerGlobal.createVirtualDisplay(DisplayManagerGlobal.java:790) at android.hardware.display.DisplayManager.createVirtualDisplay(DisplayManager.java:1225) at android.media.projection.MediaProjection.createVirtualDisplay(MediaProjection.java:262) at android.media.projection.MediaProjection.createVirtualDisplay(MediaProjection.java:231) at io.github.thibaultbee.streampack.core.elements.sources.video.mediaprojection.MediaProjectionVideoSource.startStream(MediaProjectionVideoSource.kt:112) at io.github.thibaultbee.streampack.core.pipelines.inputs.VideoInput$startStream$2.invokeSuspend(VideoInput.kt:327) at io.github.thibaultbee.streampack.core.pipelines.inputs.VideoInput$startStream$2.invoke(Unknown Source:8) at io.github.thibaultbee.streampack.core.pipelines.inputs.VideoInput$startStream$2.invoke(Unknown Source:4) at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndspatched(Undispatched.kt:66) at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:43) at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:165) at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1) at io.github.thibaultbee.streampack.core.pipelines.inputs.VideoInput.startStream(VideoInput.kt:316) at io.github.thibaultbee.streampack.core.pipelines.StreamerPipeline$startInputStreams$2.invokeSuspend(StreamerPipeline.kt:714) at io.github.thibaultbee.streampack.core.pipelines.StreamerPipeline$startInputStreams$2.invoke(Unknown Source:8) at io.github.thibaultbee.streampack.core.pipelines.StreamerPipeline$startInputStreams$2.invoke(Unknown Source:4) at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndspatched(Undispatched.kt:66) at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:43) at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:165) at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1) at io.github.thibaultbee.streampack.core.pipelines.StreamerPipeline.startInputStreams(StreamerPipeline.kt:696) at io.github.thibaultbee.streampack.core.pipelines.StreamerPipeline.access$startInputStreams(StreamerPipeline.kt:89) at io.github.thibaultbee.streampack.core.pipelines.StreamerPipeline$addOutputImpl$2$onStartStream$2.invokeSuspend(StreamerPipeline.kt:477) at io.github.thibaultbee.streampack.core.pipelines.StreamerPipeline$addOutputImpl$2$onStartStream$2.invoke(Unknown Source:8) at io.github.thibaultbee.streampack.core.pipelines.StreamerPipeline$addOutputImpl$2$onStartStream$2.invoke(Unknown Source:4) at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndspatched(Undispatched.kt:66) at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:43) at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:165) at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1) at io.github.thibaultbee.streampack.core.pipelines.StreamerPipeline$addOutputImpl$2.onStartStream(StreamerPipeline.kt:441) at io.github.thibaultbee.streampack.core.pipelines.outputs.encoding.EncodingPipelineOutput.startStreamInternal(EncodingPipelineOutput.kt:501) at io.github.thibaultbee.streampack.core.pipelines.outputs.encoding.EncodingPipelineOutput.access$startStreamInternal(EncodingPipelineOutput.kt:73) 2025-04-24 20:11:07.650 21135-21135 MainActivity io…bee.streampack.screenrecorder E at io.github.thibaultbee.streampack.core.pipelines.outputs.encoding.EncodingPipelineOutput$startStream$2.invokeSuspend(EncodingPipelineOutput.kt:533) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:829) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704) Caused by: android.os.RemoteException: Remote stack trace: at com.android.server.media.projection.MediaProjectionManagerService$MediaProjection.isValid(MediaProjectionManagerService.java:1252) at com.android.server.display.DisplayManagerService.createVirtualDisplayInternal(DisplayManagerService.java:1752) at com.android.server.display.DisplayManagerService.-$$Nest$mcreateVirtualDisplayInternal(DisplayManagerService.java:0) at com.android.server.display.DisplayManagerService$BinderService.createVirtualDisplay(DisplayManagerService.java:4599) at android.hardware.display.IDisplayManager$Stub.onTransact(IDisplayManager.java:899)
Code:
suspend fun screenRecorderSingleStreamer( context: Context, audioSourceFactory: IAudioSourceInternal.Factory? = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { MicrophoneSourceFactory() } else { MediaProjectionAudioSourceFactory() }, endpointFactory: IEndpointInternal.Factory = DynamicEndpointFactory(), @RotationValue defaultRotation: Int = context.displayRotation ): SingleStreamer
Additional context
No response
Relevant logs output
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (11 by maintainers)
It is a WIP but I am working on it. See https://github.com/ThibaultBee/StreamPack/tree/fix/shared_media_projection I am working on the service + demo, I need to find the best way to pass the activity result to the service.