Fragment Test

In mobile application development, a fragment is a modular, reusable piece of a user interface (UI) that lives inside an activity. Some common use cases for fragments are discussed hereunder:

  • Multi-pane layouts: Fragments are used to build adaptive UIs (e.g., a list on the left and details on the right for tablets, which split into separate screens on phones).

  • Modularity: Fragments enable reuse of modules across activities.

  • Dynamic UI: You can swap, add, or remove sections of a screen without loading a completely new activity, with the help of fragments.

From the above, its clear that fragments greatly influence a user's experience with the host activity. If one/more fragments of a UI activity slow down, its very likely that users will be frustrated with that activity, and eventually, with the app too. To avoid this, app developers need to keep an eye on fragment executions, proactively detect slowness in execution, and promptly fix the bottleneck, so that user experience with the corresponding host activity remains above-par at all times! This is what the Fragment test helps app developers achieve! 

This test tracks the number of times each fragment in the mobile app's UI executes, and the time taken by every fragment per execution. This sheds light on those fragments that are slow. Detailed analytics points to the precise executions that are slow and how this slowness affects the underlying host activity. Factors that can impact fragment performance such as network status, device type, geography of access, and battery charge are also reported as part of detailed metrics. This way, the test not only helps app developers spot the problem fragment, but also points them to the probable causes of the slowness, thereby enabling them to troubleshoot quickly and clear the issues hampering user experience.

Agent deploying the test : A remote agent

Outputs of the test : One set of results for every fragment used in the target app for each native app platform

Configurable parameters for the test
Parameter Description

Test Period

How often should the test be executed.

Proxy Host

If the eG agent communicates with the Mobile RUM collector via a proxy, then specify the IP address/fully-qualified host name of the proxy server here. By default, this is set to none, indicating that the eG agent does not communicate with the collector via a proxy.

Proxy Port

If the eG agent communicates with the Mobile RUM collector via a proxy, then specify the port at which the proxy server listens for requests from the eG agent. By default, this is set to none, indicating that the eG agent does not communicate with the collector via a proxy.

Proxy Username and Proxy Password

If the eG agent communicates with the Mobile RUM collector via a proxy server, and if proxy server requires authentication, then specify valid credentials for authentication against Proxy Username and Proxy Password. If no proxy server is used or if the proxy server used does not require authentication, then set the ProxyUsername and ProxyPassword to none.

Confirm Password

Confirm the Proxy Password by retyping it here.

Note:

If you Reconfigure the test later to change the values of the Proxy Username, Proxy Password, Confirm Password parameters, then such changes will be effected only if the eG remote agent monitoring the Mobile RUM component is restarted.

Number of Healthy Executions Per Test Period

By default, this parameter is set to 5 indicating that the detailed diagnosis of this test will collect and display metrics related to the top-5 normal/healthy fragment executions, in terms of the Average execution time, for each measurement period in the timeline chosen for detailed diagnosis. To identify the top 5, the eG agent sorts all healthy executions in a measurement period in the ascending order of their Average execution time, and picks the first 5 executions from this sorted list for display in the Detailed Diagnosis page and for storing in the eG database.

You can however, increase or decrease this value depending upon how many healthy executions you want to see in your detailed diagnosis, and how well-tuned or well-sized the eG database is.

If you do not want the detailed diagnosis to include any healthy execution, set the value of this parameter to 0. To view all healthy executions, set the value of this parameter to all. Before setting the value of this parameter to all, make sure that you have a well-sized eG database in place, as this setting will store details of every execution that registers an Average execution time value that is lower than the Slow Transaction Cutoff specification. On a good day, this can result in numerous executions, and can consume considerable space in the eG database.

Number of Slow Executions Per Test Period

By default, this parameter is set to 5 indicating that the detailed diagnosis of this test will display metrics related to the top-5 slow executions, in terms of the Average execution time, for each measurement period in the timeline chosen for detailed diagnosis. To identify the top 5, the eG agent sorts all slow executions in a measurement period in the descending order of their Average execution time, and picks the first 5 executions from this sorted list for display in the Detailed Diagnosis page and for storing in the eG database.

You can however, increase or decrease this value depending upon how many slow executions you want to see in your detailed diagnosis, and how well-tuned or well-sized the eG database is.

If you do not want the detailed diagnosis to include any slow execution, set the value of this parameter to 0. To view all slow executions, set the value of this parameter to all. Before setting the value of this parameter to all, make sure that you have a well-sized eG database in place, as this setting will store details of every execution that registers an Average execution time value that is higher than the slow transaction cutoff specification. On a bad day, this can result in numerous executions, and can consume considerable space in the eG database.

Slow Transaction Cutoff (Ms)

This test reports the count of slow executions and also pinpoints the executions that are slow. To determine whether/not a fragment execution is slow, this test uses the Slow Transaction Cutoff parameter. By default, this parameter is set to 4000 millisecs (i.e., 4 seconds). This means that, if an execution takes more than 4 seconds to complete, this test will consider that as a slow execution by default. You can increase or decrease this slow transaction cutoff according to what is ‘slow’ and what is ‘normal’ in your environment.

Note:

The default value of this parameter is the same as the default Maximum threshold setting of the Average execution time measure – i.e., both are set to 4000 millisecs by default. While the former helps eG to distinguish between slow and healthy executions for the purpose of providing detailed diagnosis, the latter tells eG when to generate an alarm on Average execution time. For best results, it is recommended that both these settings are configured with the same value at all times. Therefore, if you change the value of one of these configurations, then make sure you update the value of the other as well. For instance, if the Slow Transaction Cutoff is changed to 6000 millisecs, change the Maximum Threshold of the Average execution time measure to 6000 millsecs as well.

Tolerating Cutoff (MS)

This test reports the count of tolerating executions and also pinpoints the executions with a tolerating experience. For an execution to be considered as a tolerating execution, this test uses the Tolerating Cutoff parameter. By default, this parameter is set as 4 times the default value of the Slow Transaction Cutoff parameter. Since the default Slow Transaction Cutoff is 4000 milliseconds, the Tolerating Cutoff is set as 16000 milliseconds (4 * 4000) - i.e., 16 seconds - by default. This means that, if a fragment execution takes anywhere between 4 to 16 seconds, then, this test will consider that execution as a tolerating execution by default. You can increase or decrease this Tolerating Cutoff according to what is 'tolerating', what is ‘slow’ and what is ‘normal’ in your environment.

DD Frequency

Refers to the freqthe uency with which detailed diagnosis measures are to be generated for this test. The default is 1:1. This indicates that, by default, detailed measures will be generated every time this test runs, and also every time the test detects a problem. You can modify this frequency, if you so desire. Also, if you intend to disable the detailed diagnosis capability for this test, you can do so by specifying none against DD frequency.

Detailed Diagnosis

To make diagnosis more efficient and accurate, the eG Enterprise embeds an optional detailed diagnostic capability. With this capability, the eG agents can be configured to run detailed, more elaborate tests as and when specific problems are detected. To enable the detailed diagnosis capability of this test for a particular server, choose the On option. To disable the capability, click on the Off option.

The option to selectively enable/disable the detailed diagnosis capability will be available only if the following conditions are fulfilled:

  • The eG manager license should allow the detailed diagnosis capability
  • Both the normal and abnormal frequencies configured for the detailed diagnosis measures should not be 0.

 

Measurements made by the test
Measurement Description Measurement Unit Interpretation

Number of executions

Indicates the number of times this fragment was run.

Number

Compare the value of this measure across fragments to identify the 'most accessed' fragment.

You can also use the detailed diagnosis of this measure to know how long the fragment took to complete each time it was executed.

Apdex score

Indicates the apdex score of user satisfaction with this fragment.

Number

Apdex (Application Performance Index) is an open standard developed by an alliance of companies. It defines a standard method for reporting and comparing the performance of software applications in computing. Its purpose is to convert measurements into insights about user satisfaction, by specifying a uniform way to analyze and report on the degree to which measured performance meets user expectations.

The Apdex method converts many measurements into one number on a uniform scale of 0-to-1 (0 = no users satisfied, 1 = all users satisfied). The resulting Apdex score is a numerical measure of user satisfaction with the performance of enterprise applications. This metric can be used to report on any source of end-user performance measurements for which a performance objective has been defined.

The Apdex formula is:

Apdext = (Satisfied Count + Tolerating Count / 2) / Total Samples

This is nothing but the number of satisfied samples plus half of the tolerating samples plus none of the frustrated samples, divided by all the samples.

A score of 1.0 means all responses were satisfactory. A score of 0.0 means none of the responses were satisfactory. Tolerating responses half satisfy a user. For example, if all responses are tolerating, then the Apdex score would be 0.50.

Ideally therefore, the value of this measure should be 1.0. A value less than 1.0 indicates that the user experience with the fragment has been less than satisfactory.

Average execution time

Indicates the average time taken by this fragment to execute.

Milliseconds

This refers to the time it takes for a sub-screen component (i.e., fragment) to fully initialize, build its user interface, and become interactive for the user.

If the value of this measure is consistently high for a fragment, there is reason to worry. This is because, it implies that the fragment is running slowly. If this condition is allowed to persist, it can adversely impact user experience with the app as a whole. You may want to check the Apdex score in such circumstances to determine whether/not user experience has already been affected. Regardless, you should investigate the anomaly and quickly determine where the bottleneck lies.

Some of the common causes for slow fragment execution and the recommended steps to resolve them are as follows:

Heavy Work on the Main (UI) Thread

Such work includes executing network calls, heavy JSON parsing, database queries (Room/SQLite), or complex cryptographic operations within lifecycle callbacks like onCreateView(), onViewCreated(), or viewDidLoad().

To resolve this, follow the recommendations below:

  • Asynchronous Offloading: Move heavy computations to background threads using Kotlin Coroutines (Dispatchers.IO), RxJava, or Swift Grand Central Dispatch (DispatchQueue.global).

  • Architecture Abstraction: Shift data fetching entirely out of the Fragment/View Controller and into architectural components like a ViewModel.

  • Strict Mode Emulation: Enable StrictMode in debug builds to throw an immediate penalty or log warning if disk I/O or network operations occur on the main thread.

Complex and Deep Layout Hierarchies

Massive XML layout trees with deeply nested layouts (e.g., nesting several LinearLayouts inside one another) is one of the common causes of slow fragment execution.. This forces the system to run multiple expensive measurement and layout passes over the view hierarchy, delaying fragment attachment.

To resolve this, follow the recommendations below:

  • Flatten the View Hierarchy: Replace heavily nested layouts with ConstraintLayout (Android) or modern declarative Auto Layout / SwiftUI (iOS) to resolve constraints in a single pass.

  • Lazy Loading Elements: Use <ViewStub> in XML layouts to defer the inflation of complex, non-essential UI items (like error screens or expandable panels) until they are explicitly needed.

Inefficient Collection Loading & View Recreation

Initializing lists or grids (e.g., RecyclerView or UICollectionView) without proper view recycling, or loading uncompressed high-resolution images within the fragment can cause this issue. Over-allocating objects inside critical scroll paths triggers aggressive Garbage Collection (GC) pauses, creating a choppy experience.

To resolve this, follow the recommendations below:

  • Smart Diffing: Implement ListAdapter alongside DiffUtil (Android) or DiffableDataSource (iOS) to ensure only modified list elements are redrawn, rather than invalidating the entire list.

  • Downscale Images: Utilize lifecycle-aware image caching libraries like Coil or Glide for Android, and NSCache with hard limits for iOS to decode images at the exact dimensions required.

Memory Leaks Accumulating GC Pressure

Fragments are destroyed and recreated frequently (e.g., during screen rotation or fragment transitions). If background tasks, static singletons, or lingering listeners hold a strong reference to a destroyed fragment's view, that memory cannot be reclaimed. Over time, this triggers heavy background cleanup, causing severe navigation lag.

To resolve this, follow the recommendations below:

  • Nullify View Binding: In Android XML-based fragments, always nullify the view binding reference inside onDestroyView() to release references to UI elements.

  • Use Lifecycle-Aware Observers: Bind data observation to the fragment’s view lifecycle (viewLifecycleOwner) rather than the fragment instance lifecycle itself.

  • Break Retain Cycles: Ensure all trailing closures, delegates, and async handlers capture the host fragment/view controller weakly ([weak self]).

Mismanaged Fragment Transactions

Using .replace() aggressively instead of .add() and .hide()/.show() when dealing with heavy tabs or dashboards, can cause this issue. Every .replace() call completely destroys the fragment’s view hierarchy, forcing the entire fragment to go through the slow process of reinflating layouts and re-fetching local states upon return.

To resolve this, follow the recommendations below:

  • State Preservation: For top-level navigation (like bottom tabs), hide and show pre-instantiated fragments to keep their layouts hot in memory.

  • Modern Container Views: Migrate away from legacy <fragment> XML tags and opt for FragmentContainerView, which provides far safer and more predictable lifecycle executions.

Also, if consistent slowness is observed in a fragment, you can use the detailed diagnostics of this measure to identify the exact executions that are slow and whether/not that slowness has impacted the host activity. If it has, its a serious concern. In such a case, you can go back to the detailed diagnostics of the slow executions to determine the following:

  • Could a poor / jammed network connection have caused the slowness?

  • Is an incompatible device the reason for the slowness?

  • Has slowness been noticed only when fragments are executed from a specific geography?

  • Is the app draining battery when executing the fragment? Could the slowness have been caused by the poor battery charge?

You can decide on the course of remedial action based on what you infer from the detailed readings.

Executions per minute

Indicates the number of times this fragment was executed per minute.

Number

This is a good indicator of the workload imposed by the fragment on the app.

An unusually high value for this measure may require investigation.

Normal executions

Indicates the percentage of time for which this fragment executed normally.

Percent

The value of this measure indicates the percentage of time for which the fragment did not experience any slowness

Ideally, the value of this measure should be 100%. A value less than 50% is indicative of a serious problem, where most of the time the fragment is slow. Under such circumstances, you can use the detailed diagnosis of the Average execution time measure for deeper analysis of the slowness.

Slow executions

Indicates the percentage of time for which this fragment executed slowly.

Percent

Ideally, the value of this measure should be 0. A value over 50% implies that you are in a spot of bother, with the fragment being sluggish for over half of the time. Use the detailed diagnosis of the Average execution time measure to identify exact executions hat were slow.

Slow executions (Tolerating & Frustrated)

Indicates the number of times this fragment executed slowly.

Number

A fragment is considered to be slow when the average time taken to execute that fragment exceeds the Slow Transaction Cutoff configured for this test.

Ideally, fragment should run quickly. The value 0 is hence desired for this measure. If the value of this measure is high, it indicates that the fragment is often slow. To know which specific fragment executions are slow and why, use the detailed diagnosis of this measure.

Satisfied users

Indicates the number of times the fragment executed quickly, ensuring user satisfaction.

Number

A fragment is considered to be slow when the average time taken to execute that fragment exceeds the Slow Transaction Cutoff configured for this test. If this Slow Transaction Cutoff is not exceeded, then the user experience with that fragment is deemed to be ‘satisfactory’. To know which fragment executions have delivered a satisfactory experience to users, use the detailed diagnosis of this measure.

Ideally, the value of this measure should be the same as that of the Number of executions measure. If not, then it indicates that one/more fragments are slow – i.e., have violated theSlow Transaction Cutoff

If the value of this measure is much lesser than the value of the Tolerating users and the Frustrated users, it is a clear indicator that the UX with the fragment is below-par. In such a case, use the detailed diagnosis of the Tolerating users and Frustrated users measures to know which specific fragment executions were slow.

Tolerating users

Indicates the number of times this fragment's execution time exceeded the value set for the Tolerating Cutoff parameter of this test.

Number

If the Average execution timeof a fragment execution exceeds the Tolerating Cutoff configuration of this test, then such an execution is considered to be a Tolerating execution.

Ideally, the value of this measure should be 0. A value higher than that of the Satisfied users measure is a cause for concern, as it implies that the overall user experience with the fragment is less than satisfactory. To know which exact fragment executions are contributing to this sub-par experience, use the detailed diagnosis of this measure.

Frustrated users

Indicates the number of frustrated executions of this fragment.

Number

If the Average execution time is over 4 times the Slow Transaction Cutoff configuration of this test(i.e., > 4 * Slow Transaction Cutoff ), then such an execution is considered to be a Frustrated execution.

Ideally, the value of this measure should be 0. A value higher than that of the Satisfied users measure is a cause for concern, as it implies that the overall user experience with the fragment is less than satisfactory. To know which specific executions of the fragment are contributing to this sub-par experience, use the detailed diagnosis of this measure.

The detailed diagnosis of the Number of executions measure reveals the time each execution of the fragment took to complete. This way, the execution that was the slowest can be easily determined.

Figure 1 : The detailed diagnosis of the Number of executions measure of the Fragment test

The detailed diagnosis of the Average execution time measure reveals the time each execution of the fragment took to complete, the user experience with each execution, and the device, OS, country from which the fragment was run.

Figure 2 : Detailed diagnosis of the Average execution time measure of the Fragment test

The detailed diagnosis of the Satisfied users measure provides the details of fragment executions that ran quickly.

Figure 3 : Detailed diagnosis of the Satisfied users measure of the Fragment test

The detailed diagnosis of the Tolerating users measure provides the details of tolerating fragment executions - i.e., those executions that delivered only a tolerable experience to users.

Figure 4 : Detailed diagnosis of the Tolerating users measure of the Fragment test

The detailed diagnosis of the Slow executions measure provides the details of fragment executions that were slow.

Figure 5 : Detailed diagnosis of the Slow executions measure of the Fragment test