-
Notifications
You must be signed in to change notification settings - Fork 109
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
Using scaleX/scaleY instead of alpha/visible to control visibility performs better #466
Comments
This is interesting! Which devices specifically did you try this on? @hiratariq |
The device is a STB, FPS generally is pretty down on it anyway, same with memory usage. |
@hiratariq is your STB running RDK software like RDK-V? |
It's not running RDK. However the scale vs visibility performance comparison is not just limited to this device, its just more noticeable on the device as it is quite slow. |
Hi @hiratariq I am not seeing the performance benefits on my machine(M1 Mac). I copied your code here. Attaching the profile in case you wanna check the difference on your end: Maybe you could try to capture the performance profile on your end and share? |
Edit: Please ignore this comment Hi @imtiaz101325 apologies I've taken this long to check for updates on github. I think at the time I posted the codepen I forgot to disable image worker. But I've updated it to not use it. In my codebase I completely removed alpha/visible property and used scale throughout which made significant difference on the STB. In the codepen however, at the time I posted it here I saw the difference I was talking about, but rerunning today the results are inconsistent and changing order of the lines of code also effects the time. I'll have to write an elaborate example instead. I've tweaked the codepen a little which basically after showing and hiding the Element I repeat it again. So previously I had Now I have But really changing the order of lines changes everything and the codepen doesn't do a good enough job to prove my findings in the actual codebase I am working with. I'll give the code you've attached a go and get back to you with better example. |
Edit: Please ignore the striked through bit These are screenshots from my profiling session. |
Apologies, but after having slept on the issue I realised patching without rendering anything was the missing piece in the codePen so I have now updated it https://codepen.io/hiratariq/pen/wvErXmb Now it does show that scaling instead of changing visibility does perform better, so the issue is valid thats why reopened. |
Hi @hiratariq |
Hi, i will try to explain why setting From an engine perspective it needs to execute the following steps when updating scaleX property:
Steps for updating alpha property:
Currently, we are essentially executing similar logic when modifying the
For setting
Since Lightning is build with embedded in mind, there is a lot more logic being executed when you update the alpha property of a component, it will eagerly try to clean-up after itself to free up resources. TLDR; The reason why setting |
Thanks so much @erikhaandrikman 🙏🏾 |
Thanks @erikhaandrikman I did dive a little into the code to realise the recursion is where the two methods differ. Thanks for the detailed explanation. Definitely shader and texture management matters in our codebase. But is there an alternate method, that produces the visual results faster and then cleanups later when convenient to us? |
Hi,
In a very complex render tree, I experimented with scaling the components down to nothing instead of hiding their visibility,
link to example
It seems to me that scaleX/scaleY is significantly faster than alpha/visible to mainly hide and show. It makes quite a difference on our slower device as well. I haven't come across any penalty from Lightning that comes with it, that is, patching is faster comparatively, and the drawFrame right after seems to take about the same amount of time.
Is there something I am overlooking, if not, why is scaling faster than visibility?
Thanks!
The text was updated successfully, but these errors were encountered: