Multithreaded rendering on Android
code.facebook.com
code.facebook.com
It is mentioned in the article that Android documentation does not recommend doing multithreading optimizations since the UI Toolkit itself is not thread-safe, does this mean that Android's own UI Toolkit cannot be used within this context? What is the level of integration that Litho and Android's UI Toolkit can have? Also, in regards to Android's Accessibility APIs, does Litho components handle/have that capability?
I guess I should have done a bit more research/experimentation on Litho, but these are some questions I have. I'd really love to use it though.
https://medium.com/airbnb-engineering/epoxy-airbnbs-view-arc...
> does this mean that Android's own UI Toolkit cannot be used within this context? Views should not be accessed on a background thread according to the Android documentation. Litho renders inside of a light weight wrapper view and interacts with this wrapper view on the UI thread. Nevertheless, Litho moves most of the heavy lifting from rendering to the background.
> What is the level of integration that Litho and Android's UI Toolkit can have? During the conversion to Litho, News Feed rendered with some standard views and some Litho
>in regards to Android's Accessibility APIs, does Litho components handle/have that capability? Yup! It's a full featured UI framework. Animations are under active development though.
What they're talking about doing here is multi-threaded layout which isn't nearly that impressive. Heck, you can call measure()/layout() off-thread right now on views, there's just an invalidate when they get inserted into the hierarchy.
Also something not mentioned is that each CPU core you spin up is eating into XX% of your battery life. So you may get a faster layout but your users may see worse battery usage because of it.
[1] - https://android.googlesource.com/platform/frameworks/base/+/...
For what it's worth unless you're on Vulkan(which few Android devices support) you're going to be limited to a single dispatch thread by GLES' threading semantics anyway.
I still rest my point that they're doing layout, which is fine but doesn't consist of multi-threaded rendering. Using their approach they're still going to have to set some sort of absolute layout views which must go through a measure and layout pass on the UI thread.
It is telling that battery life is almost never mentioned or discussed in depth anywhere. What is the battery impact of React Native? Or of this solution?
It's a really nasty problem too because power usage isn't linear. Chips tend to have voltage steps[1] as they increase in frequency so if you can do something longer and at lower frequency it uses less power than the same workload at a higher frequency for shorter time.
Compound that with the fact that you really want to bring the whole SoC to a low power state and just keep the display lit since 90% of the time users aren't actually moving something.
Arm has tried to solve this with big.LITTLE[2] to mixed results. It turns out that it's hard to build a general purpose scheduler that's power aware much like it's hard to build a general purpose memory allocator that's fast in every case.
Google released the tool they created in order to benchmark it (battery historian). btw, releasing the tool they created for a specific improvement is what they do each time they focus on improving one aspect of the platform, and that's an excellent practice.
Google probably cares to some extent about battery life. I doubt that the mobile team behind let's say Youtube cares, but the framework team does.
Third party devs tend to do not worry at all about battery life .. unless they use a really excessive amount of battery and are shamed for it
Also android developers are using Reactive components more and more, but the UI is still very much statefull. So i see a bright future for this approach (maybe not the facebook library, but the approach itself)