Nowadays, when experts discuss User Interfaces (UI) they mostly care about frame-rates. Even if the human eye can process up to 25 Frames Per Second (FPS), digital visual content must be displayed at more than 30 FPS. It is widely accepted that frame-rates higher than what the eye can handle can significantly improve visual content quality. A modern multimedia device should be able to produce at least 60 FPS on its screen, so it can render High Definition media content without sacrificing even one bit of data.
On a multipurpose device, such as a smartphone or a tablet, a 60 FPS User Interface is not that easy to achieve. The very limited processing power of these devices, as well as the need for the Operating System to run heavy house-keeping tasks simultaneously, make things quite complex. Software must be carefully crafted so it takes full advantage of hardware and runs as fast as possible.
Google has done a great job with Android’s User Interface. Pixel devices feature some special kernel code additions and tweaks, so they can deliver a constant 60 FPS User Interface. Results are exceptional. Other Vendors have come with their own solutions on their high-end devices.
Not all of us own a high-end device though. But that does not mean that there is no room for improvement on our devices as well. Fortunately, Google implemented a generic feature inside the Android Framework, to help increase the UI frame-rates. This feature is available for devices running Android Nougat and newer. It was mainly created as a debug feature, to help device developers identify ‘jitter’. It is not strange that most devices currently ship with this feature disabled.
How Does it Work?
When a special build.prop property is enabled, Android Framework identifies code threads responsible for rendering the UI. It then schedules these threads with the realtime priority SCHED_FIFO. SCHED_FIFO is one of the many scheduling priorities supported by the Linux kernel Task Scheduler. When a task is scheduled with SCHED_FIFO priority, kernel guarantees that this task will run as soon as possible. SCHED_FIFO takes precedence over any other scheduling priority. This makes sure that drawing the UI becomes the most important task of the system. By eliminating waiting time between the time the UI drawing operation gets scheduled and the time it actually runs, frame-rate increases significantly.
Things seem very promising at a first glance, but there are some caveats. Less capable devices might get in trouble when this feature is enabled. It might become impossible for Android to keep up with other tasks, like processing touch screen input or playing music in the background. Some devices might even become slower overall. When a SCHED_FIFO task runs, it will not give control back to the Operating System unless it completes or sleeps. This means that any other task that needs to run must wait until the SCHED_FIFO task finishes its duty. Typically, devices that feature more than two processor cores should be able to handle this feature adequately. If results are not ideal, there is always some room for improvement by tweaking the kernel Task Scheduler (although this is for more experienced users).
How to Enable
As mentioned above, to enable higher FPS on Nougat+ devices (mentioned as the ‘use_fifo_ui’ feature from now on), you need to add a line into your build.prop file. You can find more information about editing build.prop in MiSense 4.0 (HTC Sense 4 Style) for MIUI GB & MIUI V4.
Just insert the following line into your build.prop file, save it and reboot your device:
Android Framework will pick up the new property automatically at boot and results should appear immediately.
How to Inspect Results
Android Nougat and newer pack a rendering profiling tool under Developer Options. This can be used to inspect the FPS achieved by the Android Framework during displaying various Apps. You can enable it by going to Developer Options and clicking Profile GPU Rendering, under the Monitoring tab.
By selecting ‘on screen as bars’, you will get something like the following:
This is actually a real-time graph of frame-rates. Each column represents a single frame. Various colors represent different stages of the rendering process (deeper discussion about them would be outside of the scope of this article). You will also notice a horizontal line. That line represents the limit of 60 FPS. Columns that end below that line represent frames displayed at a frame-rate higher than 60FPS. Frames that grow above the horizontal line are considered ‘too slow’.
You can take graphs of some apps with the ‘use_fifo_ui’ feature enabled and disabled and identify if this feature actually helps increase your device frame-rates.
- While all Nougat+ based ROMs should support the feature discussed above, some stock vendor ROMs might have this feature completely removed. The build.prop edit was tested and found working on AOSP and LineageOS based ROMs.
- Make sure you have a backup before trying out the build.prop edit. There is a chance that Android system becomes unstable when you enable this feature.
- ‘use_fifo_ui’ might only increase FPS while using normal Apps. OpenGL Apps (ie. games) will not benefit at all from this tweak.