Context
I have a Jetpack Compose @Composable
function that has a AndroidView
(Camera previewview) and a Canvas
that I draw on.
Here's a very simplified version of my code:
@Composable
fun ExerciseCanvasView(...) {
Box(modifier = Modifier.fillMaxSize()) {
AndroidView(...)
Canvas(...)
}
}
Basically, I want to record a video of this function and save it into a file (video.mp4).
What I've Tried:
- MediaProjection. I tried MediaProjection but is not what I want. It records the whole screen and I dont really need that and it might record sensitive info.
- Drawing a composeview to a canvas to a bitmap. I have tried this also, but the drawing has to be done in the Main UI Thread (this question) and this blocks the Main UI Thread, rendering it unusable.
- Some other deprecated shenanigans that chatgpt recommended that dont work at all.
For now, I dont care if even i have to save captures of the Composable and then encode them to a video or anything, I cant even make that to work...
Question
Has anyone faced a similar issue and found a solution to record only this specific @Composable without blocking the UI thread?