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.

No comments: