I updated my app dependencies from appcompat 1.3.1 to appcompat 1.4.1, where one of the key changes is:
Updatable emoji support is enabled by default via the androidx.emoji2 library
It seemed to me that the smoothness of RecyclerView in my app got worse, and Profiler confirmed this. I have 4 TextViews in the ViewHolder whose setText method has always been one of the slowest actions in onBind. But after the update, the situation has become disastrous:
onBind now takes 11ms on average, 7.3ms of which is summed up by androidx.emoji2.viewsintegration.EmojiInputFilter.filter()
and androidx.emoji2.viewshelper.EmojiTransformationMethod.getTransormation()
for 4 textview.
I don't need emoji support like most developers, I need the app to run smoothly. Is there any way to disable emoji2 without downgrading to 1.3.1?
Below is a screenshot from the profiler for one TextView. The parent setText() method took 3.76ms. Timing for filter() method provided in "Summary" tab (on the right) and in popup for getTransormation().
I found an answer on emoji2 page: https://developer.android.com/jetpack/androidx/releases/emoji2. Paragraph "Configuring automatic initialization".
So to disable emoji2 we should add this code to <application> tag in AndroidManifest.xml
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge">
<meta-data android:name="androidx.emoji2.text.EmojiCompatInitializer"
tools:node="remove" />
</provider>
The improvement in performance is obvious: onBind now takes 6.5ms at all instead of 11ms.