Rebuilding Facebook for Android
facebook.com
facebook.com
a) Reducing Garbage Collection - Very standard, not creating new objects in tight loops should be in the 'very obvious' category, regardless of GC or not.
b) Writing a Custom Event Bus - Would be great if they released theirs so we could compare it to the existing ones - https://github.com/greenrobot/EventBus - http://square.github.com/otto/
c) Moving Photos to the Native Heap - Feels like this would have very heavy costs in transferring the photo back into the dalvik VM for display? Possibly control of allocation/de-allocation + absolute memory tracking makes this net positive for the Facebook app - but what about multitasking? Will the Facebook app free up this memory when swapped to the background?
d) Writing a Custom ListView Recycler - This one is genuinely interesting, and hopefully Facebook can commit this back into Android AOSP! If not, hopefully some Google devs can take a look at the default recyclers and see if they can implement the same improvements.
On rewriting the ListView recycler, I'm doubtful how much improvement they could get considering that code works fine for thousands of apps including Google's. If there were any gains to be had google's engineer's would have found them.
http://developer.android.com/reference/android/graphics/Bitm...
When creating bitmaps. It seems to act as a hint to the BitmapFactory to allocate the bitmap in a different memory space to where it would create a stock standard java object. There seems to be some pros and cons to this approach - namely the memory allocated to the bitmap could be disposed at any time, meaning the bitmap would have to be reloaded from disk, or wherever it came from.
I will try out the flag in my own app, and see what impact it has.
The news feed is mostly light red (3x overdraw): http://ara.sh/private/facebook_news_feed_overdraw.png
The side bar is simple enough that it shouldn't be overdrawn 2x (green) all over either: http://ara.sh/private/facebook_sidebar_overdraw.png
Compare this to the Google+ feed view which has significantly less overdraw (and scrolls a lot better): http://ara.sh/private/google_plus_news_feed_overdraw.png
I'm not particularly fond of Holo, so I'm ok with this.
Scroll is laggy and there are only ~5 articles before I have to refresh.
I end up using the mobile version because it isn't as laggy and doesn't require location services and the potential to track me as easily.
The Facebook app should be like the Google+ app if they want to make Android users happy.
I'm able to get into the pictures loaded feed under 5 seconds on 3G and under 4 seconds on WiFi. And I get about 10 articles before I have to refresh (which takes less than a second) to see more.
I'm using a HTC One X.
I was able to bring the loading times down to something reasonable but it isn't consistent. Out of 10 times, only 30 or 40 percent were < 5 seconds.
There are anywhere from 5 to 10 articles at any given time on the first page of my feed. It still takes a second or two to reload and after about 6 pages, the scrolling is so laggy so I can't be bothered to use the app.
It's a shame, really, that a platform that popular with all the resources, still has massive performances problems and still has legacy stuff lying around (like the three dot menu in the bottom right on 4.0+ devices).
wonder what B2G perf will be like. excited.
Calculations:
CPU
- Dalvik VM doing JIT into ARM ASM
Graphics:
GPU
- OpenGL/Drivers
-- (a) Directly running OpenGL calls (native)
-- (b) Dalvik VM doing JIT
--- Semi-lightweight translation of 2D drawings
You don't really lose more than a couple percent on the 'many layers' compared to writing raw assembler, aside from using Android's View framework which is about as performant as most GUI toolkits in most situations.It sounds like they are doing bitmap processing in the true "native" sense (i.e. C). The earlier references to "native" make me think they are referring to standard Android/Java code as opposed to WebViews.