question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onStop() of previous activity is called only after 10 seconds

See original GitHub issue

I have an Activity A that starts an activity B, which contains a fragment, which in turn has a fullscreen LottieAnimationView. I display that animation while data is being fetched from the network.

I’ve noticed that the onStop() method from Activity A takes about 10 seconds to be called after B is started. In contrast, when we navigate from A to other activities, the method is called right after(< 1 second). This delayed calls makes the animation give a quick freeze, which is something we want to avoid.

Also, if I comment out the line that starts the animation in the fragment(lottieAnimationView.resumeAnimation();), onStop() is quickly called(~1 second). This makes me think that the long delay in calling that method is being caused by Lottie.

I’ve also replaced my json file with this one from lottie files: https://www.lottiefiles.com/1385-lets-go. The long delay persists.

I’m using 2.3.1 but I’ve already tried it on 2.5.0 and the behavior is the same.

Does that ring any bell already or do you need more info to investigate that?

Thanks in advance.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

9reactions
gpealcommented, Mar 11, 2018

@mateusgrb Thanks for the sample! I figured it out. Your animation actually runs significantly worse with hardware acceleration turned on. As a result, every frame was taking more than 16ms which caused Choreographer to post a vsync message at the front of the queue and prevented the onStop message from ever getting to the front until the animation stopped or a frame finished in time for the message queue to clear.

Simply turning off hardware acceleration caused your animation to become performant enough to run at 60fps.

Thanks for the fun challenge 😝

0reactions
mateusgrbcommented, Mar 1, 2018

@gpeal Here’s a minimal project that reproduces the issue. I’m running on a Nexus 6P Android 8.1.0

Note that LottieManager is a class that loads the composition on startup, so that it’s potentially already loaded when requested. That’s the strategy I’m using on my main app.

The animation used here is https://www.lottiefiles.com/1505-beauty

LottieIssue.zip

videotogif_2018 03 01_10 31 20

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android - onStop() will be called with a delay - Stack Overflow
Show activity on this post. I found my activities onStop() method will be called with a less than 10 seconds delay.
Read more >
The activity lifecycle | Android Developers
An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial...
Read more >
Understanding the Android activity lifecycle - LogRocket Blog
The onStop() method is called when the fragment is no longer visible, and is followed by the onDestroy() and onDestroyView() methods, which ...
Read more >
4. The Activity Lifecycle: Being an Activity - Head First Android ...
onCreate() gets called when the activity is first created, and it's where you do your normal activity setup. The onDestroy() method is the...
Read more >
Understanding Activity Lifecycle to Retain UI Data when Back ...
This is an override function called when the user presses the back button on an Android device. It has great implications on the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found