Rich-text Reply

Android SDK - RecyclerView Sluggish After Adding SDK

thorben 05-26-15
Accepted Solution

Android SDK - RecyclerView Sluggish After Adding SDK



I added the SDK to our application. 

I'm doing the setup (Optimizely.startOptimizely) in the Activity's onCreate and have created on OptimizelyCodeBlock with a default and three branches. 


After adding the SDK, I noticed that the scroll speed of our RecyclerView is really sluggish. Are you tracking events while scrolling that could cause this? 


I had two goals setup that used a touch event that is triggered while scrolling. I have since removed this from the experiment (via online editor) and any branching code is also removed (from the app). I only have the startOptimizely/OptimizelyCodeBlock code left yet the scroll performance is still bad. 

As an experiment I build the app without any Optimizely code and the performance is normal. 


Before I dig in as to what the problem might be, are you aware of anything that could cause RecylerView scroll perfromance to be impacted? 



Level 2

Re: Android SDK - RecyclerView Sluggish After Adding SDK

Hi Thorben,
The Optimizely SDK uses a ViewTreeObserver to identify views that maybe have been modified via the visual editor or may have tap goals. Scrolling a RecyclerView can cause many calls to the ViewTreeObserver especially if the individual rows are complex. We're working on optimizing performance, but if you want a quick work-around, you can disable all view tracking: by calling Optimizely.setVisualExperimentsEnabled(false);

Definitely look out for improvements in this space!
thorben 05-27-15

Re: Android SDK - RecyclerView Sluggish After Adding SDK

It would be awesome to add this to the FAQ on the Android SDK documentation page. I only glanced over the part for the "VISUAL EDITOR CONFIGURATION" and even from that it isn't obvious that there could be a performance hit (I guess mentioning the view hierarchy is kinda).

Also I guess one should keep in mind that it needs to be enabled during development in order to use the Editor to set up the codeBlocks as well as during testing/verification of codeBlocks but needs to be disabled before going to prod.
Level 2