Java_org_mozilla_gecko_GeckoAppShell_onLowMemory is called from DalvikVM thread. But NotifyObservers only works on XUL main thread (in other word, NS_IsMainThread() == TRUE). So onLowMemory may not work on Android.
Created attachment 498970 [details] [diff] [review]
Comment on attachment 498970 [details] [diff] [review]
The behavior of nsAppShell::NotifyObservers() is going to be different depending on if you are on the main thread or not. If you are on the main thread, you will directly call nsIObserverService::NotifyObservers. This call will enumerate all listeners and synchronously call Observe. In the non-main-thread case, nsAppShell::NotifyObservers() will simple post an event and immediately return.
I think I would prefer that you make nsAppShell::NotifyObservers just post events regardless of which thread it is called on.
Otherwise looks fine.
Created attachment 501197 [details] [diff] [review]
minor clean up from last patch to address my concern.
onLowMemory still doesn't work on this test case:
See bug 736436
Hm, though, that is not our fault, it's android who fails to notify us. re-closing. will file a separate bug.