New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capture slows then freezes on Apple Silicon macs #146
Comments
Forgot to mention that this testing was being done on a new: It appears that when I build for Intel 64-bit, and run the standalone build through Rosetta, the capture completes successfully without stalling. Therefore, this may be a Silicon specific issue. Since Apple is now only selling Silicon computers and Intel is being phased out, hopefully this can still be treated as an urgent issue - I hope you may have an M1 device to test with? |
Thanks for the repro project. The issue appears to be that you have not set the capture component to manual update. This means the component is already capturing a frame when you call capture from your co-routine, effectively capturing twice per-frame. At 4k this is a significant memory overhead so I'm not surprised that it's slowing down. To resolve just set the frame update to manual before you start the capture, as shown below: void Start()
{
captureFromCamera.FrameUpdate = CaptureBase.FrameUpdateMode.Manual;
} |
Thank you for the suggested solution. I changed frame update to manual, and unfortunately that does not fix or change the issue.
As per my later post above, captures complete perfectly in Intel builds. The stall seems to be replicable only on Silicon architecture. |
With the frame update set to manual I was able to run your test scene and capture all 50000 frames with a frame rate consistently around the ~50 fps mark. This was using a Mac mini (M1, 2020) and macOS 12.0.1. |
Please understand that I'm still experiencing a hard freeze ~1 minute into capture, and this is still posing a serious issue for my users. Not trying to get you to spend time on something that's not actually a problem. |
This was using Intel and Apple Silicon builds. |
Thank you, much appreciated. I understand how frustrating debugging something like this is. I appreciate you looking into it. |
Here is a screen capture of the freeze issue on my 2021 MacBook Pro M1 Pro when I capture in the Silicon Editor: Quicktime screen capture replaced the rainbow wheel cursor with a normal cursor at the end of the screen capture - at the end, the cursor is actually the rainbow spinning wheel as soon as the freeze happens. |
There seems to be an issue with the Apple Silicon version of the editor and getting a temporary render target that results in the main and graphics threads becoming deadlocked. This is something that we should be able to work around for now though. If you could find the method We'll continue to investigate... |
Happy to report this appears to fix the issue in a release build of my app. Both times I tested with the fix, a 10 minute 4K capture completed successfully in a Silicon build of my app. Both times I tested with a reverted Silicon build, the 4K capture froze around 6 minutes. I think that means this is a fix. Is there any additional instability or issue this code change could cause? Or should we be good to go with this as a long term fix? Thank you very much for the fix |
There should be no instabilities with this fix, in fact it should improve performance slightly as the texture resolve is not necessary on the Mac. The code will be tidied up slightly as the resolve is still required on windows and will make it into the next release. |
|
Please use the following: private bool RequiresResolve(Texture texture)
{
#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || (UNITY_IOS && !UNITY_EDITOR)
// Texture resolve wholly unnecessary on macOS and iOS
return false;
#else
bool result = false;
if (texture is RenderTexture)
{
RenderTexture rt = texture as RenderTexture;
// Linear textures require resolving to sRGB
result = !rt.sRGB;
if (!result &&
(rt.format != RenderTextureFormat.ARGB32) &&
(rt.format != RenderTextureFormat.Default) &&
(rt.format != RenderTextureFormat.BGRA32)
)
{
// Exotic texture formats require resolving
result = true;
}
}
else
{
// Any other texture type needs to be resolve to RenderTexture
result = true;
}
return result;
#endif
} |
Thank you, much appreciated. Really appreciate the great support! |
Describe the bug
Movie capture slows over a period of 3 minutes, before eventually stalling and freezing the app.
Your Setup (please complete the following information):
Issue is reproducible with a range of settings. However, it is reproduced most quickly with:
Offline Render
(No audio - video only)
3840 x 2160
60 FPS
H.264 Codec
To Reproduce
Steps to reproduce the behavior:
If you really need me to make a repro project, I can. This seems to be a fundamental issue that you could create the repro on your own? But if you need to repro to look at this more quickly, I can set it up and send it over. This is extremely urgent for my app, and is costing me business.
This was working perfectly previously. The issue seems to have been introduced a few updates ago.
I also provide the Unity framework NatCorder as a capture framework alternative to MovieCapture in the app. The NatCorder capture continues to render out flawlessly without any slowdowns or stalls. So it seems fairly clear that the instability is coming from the MovieCapture framework during the render, rather than my app.
I noticed that something about "intervals" in the release notes for MacOS / iOS - if some changes have been introduced recently to the fundamental capture encoding process recently on MacOS, perhaps it would be possible to closely examine those and see if they could have introduced some instability?
Logs
No errors are thrown in the Logs
Thank you for your assistance
The text was updated successfully, but these errors were encountered: