MediaPipeUnityPlugin icon indicating copy to clipboard operation
MediaPipeUnityPlugin copied to clipboard

When changing settings the camera hangs in Async mode on Android (Samsung S22 Ultra and other Galaxy models)

Open gb2111 opened this issue 2 years ago • 7 comments

Description

I am running pose tracking from MediaPipeUnityPlugin-all.zip on Android in Async mode for pose tracking. When I am starting demo first time, it immediately show camera feed but start showing landmarks only after 10-15 seconds when mediapipe initializes (or something). When I am in Sync mode app freezes during that time. But I use Async, I wait and that is not a problem. When I change camera or something in settings, the app freezes until mediapipe is initializes again, but I'd like to see at least camera feed working like during startup and only wait for mediapipe to initialize.

I was debugging and noted that it hangs here. It doesn't return from that function. https://github.com/homuler/MediaPipeUnityPlugin/blob/6b8c6743f23539f7604e74dc260b01e0f58f1707/Assets/MediaPipeUnity/Samples/Common/Scripts/ImageSource/TextureFrame.cs#L278

I compared it to PC and noted that on PC _glSyncToken is null but on Android it isn't. So I finally commented out below line and I now I can change settings on Android without any extra blocking on the ui/camera. Still need wait for Mediapipe to initialize but that is fine. https://github.com/homuler/MediaPipeUnityPlugin/blob/6b8c6743f23539f7604e74dc260b01e0f58f1707/Assets/MediaPipeUnity/Samples/Common/Scripts/ImageSource/TextureFramePool.cs#L121

I can't see where I can go any further, also don't like idea of commenting that out so perhaps you can find solution for this. Regards

gb2111 avatar Feb 08 '23 07:02 gb2111

Thank you for reporting the issue.

So I finally uncommented out below line and I now I can change settings on Android without any extra blocking on the ui/camera.

I'm not sure, but it looks like a bug to me.

homuler avatar Feb 08 '23 11:02 homuler

I'm not sure, but it looks like a bug to me.

Sorry. I meant that I commented out the line cause there was no comment before. Not removed the comment from already commented code.

gb2111 avatar Feb 08 '23 12:02 gb2111

I meant that I commented out the line cause there was no comment before.

Never mind. I know that.

homuler avatar Feb 09 '23 12:02 homuler

Never mind. I know that.

Can u give a tip on how to fix that?

gb2111 avatar Feb 15 '23 09:02 gb2111

If I knew that, I would have fixed it already. In the first place, I think I don't understand exactly what the problem is.

homuler avatar Feb 15 '23 11:02 homuler

related to https://github.com/homuler/MediaPipeUnityPlugin/issues/768#issuecomment-1285330371

homuler avatar Feb 18 '23 01:02 homuler

Maybe GlSyncPoint#WaitOnGpu should be called instead. cf. https://github.com/google/mediapipe/blob/68ba9a6ebf27e9c6c9e4500f7e1b68dd2db8c05b/mediapipe/java/com/google/mediapipe/components/ExternalTextureConverter.java#L603

homuler avatar Feb 18 '23 01:02 homuler