pegnose
pegnose

Reputation: 51

Fragment onResume() has >300 ms delay after migrating to AndroidX

After migrating one of my apps to AndroidX I can see the visibility settings for views in some of my fragments (androidx.fragment.app.Fragment) take effect. All views are visible by default in the layout xml. Some views which get hidden pop out, others that get shown pop in. The visibilities are set via onResume().

I took timestamps and found out that onResume() starts >300 ms after onStart() has returned. I cannot find anything in my project responsible for this and it is a drastic change to pre-AndroidX.

The activity extends AppCompatActivity, but I also tried FragmentActivity as super class. No effect. I tried running it as a release APK, but it does not matter. Plus the device is reasonably fast it being a OnePlus 8T.

Here is the time stamping code along with the results:

    @Override
    public void onStart() {
        Log.d(TAG, "LAG_ " +  System.currentTimeMillis() + " onStart");
        super.onStart();
        Log.d(TAG, "LAG_ " +  System.currentTimeMillis() + " onStart super started");
    }

    @Override
    public void onResume() {
        Log.d(TAG, "LAG_ " +  System.currentTimeMillis() + " onResume");
        super.onResume();
        Log.d(TAG, "LAG_ " +  System.currentTimeMillis() + " onResume super resumed");

        [...]
    }
2021-10-29 17:43:20.496 18138-18138/ ... LAG_ 1635522200496 onStart
2021-10-29 17:43:20.496 18138-18138/ ... LAG_ 1635522200496 onStart super started
2021-10-29 17:43:20.811 18138-18138/ ... LAG_ 1635522200811 onResume
2021-10-29 17:43:20.817 18138-18138/ ... LAG_ 1635522200817 onResume super resumed

In the current state the app cannot be released. I am curious to find out what is the culprit or what I am doing wrong. Help greatly appreciated!

EDIT: Installing a fragment with child fragments actually takes multiple seconds for the views to appear.

Upvotes: 0

Views: 229

Answers (0)

Related Questions