Disappearing facebook chat heads

      I was curious about the implementation of Facebook's chat heads launched few weeks back as a part of Facebook Home. Wondered if chat head was an overlay or being written directly to the surface but it didn't make sense for the framework to grant such control to an app and Facebook's home and chat head was being distributed as just yet another app from App store. So how does it work. Turns out that Chat head uses a public API, SYSTEM_ALERT_WINDOW and App store lets users know about this permission and that the app might display content on top of other applications.

    In android UI, all controls need a context to be created and Chat Head is no exception and is created by Facebook messenger application (com.facebook.orca). Killing Facebook messenger application clears active Chat Heads as the context isn't valid anymore. Based on the ownership of chat heads, it is indeed vulnerable to low memory killer, even though the chat head might have the focus and user might be interacting with it. Android Framework doesn't consider these app as important like a foreground activity. Focus activity gets 0 oom score but system_alert_window gets a best of only 2 (Nexus 4 running latest Jelly bean) and there by making it vulnerable to low memory killer. So i wouldn't be surprised if the chat heads disappear all of a sudden. Facebook probably didn't make this public but should definitely consider distributing a custom ROM and making chat heads full proof. But with increasing memory sizes, it might not happen.

   Update

   Recent versions of Facebook messenger has been updated to resolve the issue of disappearing chat heads. It looks like the developers have adopted the same approach as that of a music playback application. They have a foreground service which basically puts the process as a foreground process and that prevents the low memory killer from killing it. This foreground service causes a notification (Chat heads active) to be shown as long as the chat heads are active.



    However, like many things in memory management, process persistency is something that can't be guaranteed and Android's approach of foreground service is no exception, illustrated here.

2 comments:

Sadhana said...

If you don’t have time to read the entire topic and just want to find out what the Best stock For long-term investment. Here is for you...
Manappuram Finance private placement
RIL group
Zoom app
Sundar Pichai compensation

Anonymous said...

Maya Akhter