-
-
Notifications
You must be signed in to change notification settings - Fork 626
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
Screen objects rendering performance #1564
Comments
We've discussed this in another thread, but if you're using Xcode 15.4, I'd like you to measure with the Thread Performance Checker turned OFF. If you're using a different version of Xcode, please provide the environment information. My test case is
As for the expected behavior, in version 2.0.0, the transition from |
Thank you for the advice! I tried the example app with the Thread Performance Checker disabled, and the CPU usage for 1.9.1 + multicam + idle dropped from 80% to 50%. I will start migrating to version 2.0.0 to obtain the actor fix. Regarding multicam and screen rendering performance, it still seems like |
Currently, the iPhone 15 Pro Max (2023) has a 6-core CPU, allowing for a maximum CPU usage of 600%. Additionally, on the iPhone XR (2018), which is the minimum requirement for iOS 17, it was around 65-70%. As long as the main thread isn't locked, I think it’s practical to use. In the future, I’d like to try rendering using Metal. However, my understanding is that the CPU usage isn't so much due to vImage but rather the bottleneck is the YUV to RGB conversion of the camera feed. Simply switching to Metal-based or other alternative methods won’t necessarily reduce CPU usage or stabilize FPS and other performance aspects; I don't know until it’s implemented. |
I'll try to use 2.0.0 + CISourceOverCompositing to compare the performance. However, looks like Metal is the best choice because Core Image might be unpredictable in utilizing GPU over CPU. It looks like the YUV to RGB conversion is possible using a shader. Going to close this for now as I don't know when I'll be able to try to add Metal implementation. |
@mkrn Regarding the lag in the preview with stabilization, are you referring to the following preferredVideoStabilizationMode? preferredVideoStabilizationMode = .cinematic |
|
I use
However, when switching to .off it seems to help with perceived performance |
As for the issue, is the problem the lag that occurs when Thanks to mkrn's advice, I was able to reduce the CPU usage to some extent. Thank you.
|
This is good. I already tested first, and it improved a lot. Waiting for 1.9.5 for testing the second |
We launched production a week ago and we noticed some lag issues in rendering (whether for the preview, local recording or streaming). This appears when ScreenObject is rendered. That's was not the case before with the old way with the old registerVideoEffect and older version. The issue appears only when the recording or stream is started, not when both are off and only the preview is displayed. @mkrn did you test the with the new version ? |
After some tests, the problem seems to have come from stabilization. |
Describe the bug
1.9.1 has significant CPU usage increase comparing to 1.8.1. Here's some comparison:
There is a gain on the main thread:
Spoiler
1.8.1:
1.9.1:
Most of the gain comes from
vImageAlphaBlend_ARGB8888
andcreateCGImage
. I'm thinking about some optimizations that could be done and looking for your opinion:vImageAlphaBlend_ARGB8888
from the main threadCIFilter
for screens' rendering instead ofvImage
to avoid using CPU’s vector processorcreateCGImage
Any feedback is appreciated.
To Reproduce
Profile CPU usage of 1.8.1 and 1.9.1
Expected behavior
Version
1.8.1, 1.9.1
Smartphone info.
iPhone 15 Pro Max
Additional context
No response
Screenshots
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: