Closed BasilDavid closed 3 months ago
Potential Fixes: Any insights into how to prevent the freezing or optimize the operations would be appreciated.
@BasilDavid this is a known issue, and is the reason why prepareOnAwake
exists. When an application first uses a hardware encoder, the system has to provision hardware resources. This results in a noticeable hiccup which is app-wide, and can't be worked around by using a background thread (see this question). The prepareOnAwake
setting exists to hide this hiccup in app initialization, so there isn't a noticeable hiccup during the app's execution. After this first recording, all subsequent recordings will never show this hiccup.
Thread Safety: Clarifications on whether MediaRecorder.Create and recorder.Append should be handled differently in an async context would be helpful.
Media recorders can be used from different threads. You just have to synchronize accesses using a lock.
Description:
I am encountering an issue where Unity iOS app freezes during Prepare on awake asynchronous operation, specifically when using the MediaRecorder class for video processing. Despite using async/await and offloading tasks to background threads, Unity's main thread still freezes, which impacts the overall performance of the application.
Steps to Reproduce:
I took the VideoKitRecorder.PrepareEncoder method for testing on a new script
Code Example:
Observed Results:
Problem:
Expected Behavior:
Environment:
Unity Version: 2022.3.40f1 Editor Platform: macOS Target Platform: iOS VideoKit Library Version: 0.0.20
Request for Help: