Amit Shekhar Profile picture
Apr 13 10 tweets 3 min read
Why an Android App lags?

A thread 🧵

I will start with the following statement:

Garbage Collector: The TAX on Android App Performance

#AndroidDev
The main reason for the low-performance Android App is that it runs GC very frequently.

Simple in one line: The time for which GC is running the actual app is not running.
When the app runs, it allocates many objects on the basis of your code, and when the objects are no longer referred to, the system call GC when there is memory pressure to deallocate those objects, so if the object allocation and deallocation are occurring on regular basis.
The GC is running on a regular basis to release memory, So the more time the GC is running, your app is not running for that time. So it seems the app is lagging. And hence, a bad experience for the user of the application.
The Android App updates its UI every 16ms (considering 60FPS -> 1000ms/60 = 16.67ms~16ms) for smooth UI rendering . So if the GC is running for that time, the app is unable to update UI for that time, which leads to skipping of a few frames, so it seems that the app is lagging.
So the actual reason is that the GC was running or may the work is doing too much in the main thread so that the app did not get time to render its UI smoothly.
Another reason is that maybe the app is doing too much in the main thread, so at that time if any method/task is taking more time than 16ms the app will be unable to update UI, which means lag will be there in the app for that time.
Basically, the system tries to redraw the UI after every 16ms.
What if our task on the main thread takes more than 16ms. For example, if our task takes 26ms. The system tries to update the UI, but it wasn’t ready. So it will not refresh anything. And, this caused the UI to be refreshed after 32ms instead of 16ms. There is a dropped frame.
Due to the frame drop, the user will find it laggy.

This is why an Android App lags.

That's it for now.

Happy Learning :)

Show your love by sharing this tweet with your fellow developers.

Follow @amitiitbhu for learning and sharing.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Amit Shekhar

Amit Shekhar Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @amitiitbhu

Aug 21, 2021
How does Voice And Video Call Works?

This tweet is all about how the voice and video call works on a high level.

Continued in this thread 👇 [Follow the thread below]

#AndroidDev #Kotlin #Android #Developer
Both voice and video calls depend on how we stream media between the two clients which are connected to each other. So, there must be something that can do the work of media streaming from one client to another client.

For media streaming, we need to know about WebRTC.
WebRTC is a free, open project that provides browsers and mobile applications with Real-Time Communications (RTC) capabilities via simple APIs. The WebRTC components have been optimized to best serve this purpose.
Read 16 tweets
Aug 20, 2021
Android App Release Checklist For The Production Launch

Continued in this thread 👇 [Follow the thread below]

#AndroidDev #Kotlin #Android #Developer
Add analytics to your Android application.
Turn off logging and debugging.
Read 21 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(