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.
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.