One of the hard to find issues developers come across in iOS apps is frame rate related issues. These issues are often overlooked, which tend to affect the user experience and smooth functioning of iOS apps.
Before we dive head first, let us take a look at some of the basic terminologies.
Screen refresh rate and Frame rate
Every device with a screen has something called screen refresh rate. It is the number of times the screen gets refreshed in a second which is measured in Hertz (denoted Hz) and is hardware-specific.
Whereas frame rate refers to the number of times UI frames are updated within a second. This is measured in frames per second or fps.
Higher the screen refresh rate, smoother will be the user experience for events like scrolling, gaming animation, switching over between apps and other UI events.
Screen refresh rate in a device remains constant which is generally around 60 Hz to 120 Hz depending on the type of device, while the frame rate can vary. Ideally, both screen refresh rate and frame rate should be the same in order for the user to experience smooth animations and to have fluid interactions with the app.
But there may arise situations where the screen content may not get updated as often as it is capable of. This is called frame rate dips. Frame rate dip occurs in an iOS app when resource-intensive tasks are executed in the UI thread. In such situations, frame rate in an iOS device with a screen refresh rate of 60 Hz can become less than 60 fps.
Reasons for frame rate bugs in iOS apps
Normally, frame rate bugs occur in iOS apps when the UI thread/ main thread, that is responsible for updating the user interface (UI) and processing user input events, gets stuck for a few milliseconds or even seconds.
Some of the scenarios that can cause UI thread block are when blending pixels with multiple values, off-screen rendering or even adding misaligned images to a view.
I am planning to write a separate blog post on each of these individual scenarios that cause frame rate bugs next.
So how do we detect frame rate issues?
Finotes is an automated bug reporting tool that is capable of detecting frame rate issues without the need for profiling the entire application.
With basic integration, Finotes development mode SDK is capable of monitoring UI/main thread. Whenever the UI thread gets stuck in iOS apps, Finotes detects and reports it. For more details, please visit our documentation pages on Objective-C and Swift.
Initializing Finotes in Objective-C
#import <FinotesCore/Fn.h>
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:
(NSDictionary *)launchOptions {
[Fn initialize:application];
return true;
}
Initializing Finotes in Swift
import FinotesCoreSwift
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions:
[UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Fn.initialize(application)
return true
}
Developers can also use inbuilt tools like Time profiler and Core Animation in Xcode Instruments to identify the root cause of frame rate issues and avoid them in iOS apps.
The only way to avoid frame rate issues in iOS apps is by ensuring that the UI thread has very less burden and all time-consuming processes are executed in separate threads. Most of the modern apps target 60 frames per second which is equivalent to 16.67 milliseconds per frame. Hence developers need to make sure to set app drawables at this stable frame rate.
Apart from frame rate issues, Finotes also detects API call issues, memory leaks, abnormal memory usage, function failures, and delays along with custom issues and crashes.
To know more about how Finotes detects and reports ANR issues (an extension of frame rate issues) in Android apps, please read our blog post on How to detect and fix ANR issues in Android apps.
Visit finotes.com to know more about Finotes. Detailed documentation is available at docs.finotes.com.
コメント