UnityPlugin-AVProMovieCapture icon indicating copy to clipboard operation
UnityPlugin-AVProMovieCapture copied to clipboard

Program Freezes When using Dual Monitor

Open koko-DL opened this issue 2 years ago • 4 comments

Describe the bug Program freezes (or drop at less than 0.03FPS) when using dual monitor and audio capture when recording. (Also, it seams memory leak is happenning)

Your Setup (please complete the following information):

  • Unity version: 2021.3.12f1
  • AVPro Movie Capture version: latest
  • Operating system version: Windows 10
  • Capture component used: CaptureFromTexture + CaptureAudioFromAudioListener
  • Capture settings (resolution, frame-rate, codec): CaptureBase.Resolution.HD_1920x1080 30fps 1200000~2000000 bitrate

To Reproduce Steps to reproduce the behavior:

  1. Clone the attached project based on Unity's HDRP demo (emailed)
  2. Open the scene "Char_Test.unity" under Assets(HDRP) Defender - Character Demo\Scenes
  3. Press "Play" button to play the scene
  4. Press the "Do something" button on the game screen for several times
  5. Wait a while after "Do something" finished, and notice the FPS will not come back, Editor freezes
  • The problem also happens in Standalone build.
  • When comment out the following two lines in NativePlugin.cs, the problem will not happen: GL.IssuePluginEvent(RenderCaptureEventFunction, PluginID | (int)renderEvent | handle); GL.IssuePluginEvent(RenderFreeEventFunction, PluginID | (int)renderEvent);

Logs N/A

Screenshots N/A

Videos N/A

koko-DL avatar Aug 23 '23 08:08 koko-DL

Hi, is there any update on this issue?

koko-DL avatar Aug 29 '23 03:08 koko-DL

Hi @koko-DL,

Thanks for sending your test scene - I see you're sleeping the main thread for 3 seconds which in turn blocks any new frames being rendered/sent to the video encoder, but as Unity's audio is on another thread it is still amassing samples. Then when the main thread unblocks the mismatched data is causing the low-level video encoder to massively stall to attempt to re-sync.

We're looking at a possible solution that may avoid the stalls in this scenario but fundamentally blocking the main thread is unadvised (yielding, coroutines etc.. are better).

Cheers,

RichRH avatar Sep 12 '23 16:09 RichRH

Hi, thank you for your reply.

In the sample project, I sleep in the main thread to simulate the condition that reproduces the issue. However, in our real project, it only occurs when switching scenes. Additionally, we are using coroutines with yield instructions to prevent main thread blocks.

Our project is intended to run on a console for several days, so freezing is a critical problem. It would be acceptable for us if the stalls and memory leaks can be resolved, even if the recording result is not satisfactory in this condition.

koko-DL avatar Sep 13 '23 01:09 koko-DL

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 15 '23 06:12 stale[bot]