On Mon, Dec 1, 2014, at 05:48 AM, Michael Rogers wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > Sorry if I'm misunderstanding the issue, but hasn't it always been > possible for a service (even a foreground service) to be killed by the > system without any methods being called? > > https://developer.android.com/guide/components/processes-and-threads.html#Lifecycle
You are right, this is standard policy. I don't think it is great policy, but they have added the extra low memory warning callbacks for Services in recent APIs, which is helpful. It is just interesting that they can give you a warning like "memory is crazy low, your time on this VM is short", and then when they actually kill -9 you, they don't first call onDestroy(). Instead, they expect you to clean-up in the warning callback, such that perhaps they won't ever have to kill you. Also, in terms of what is new here, is that since ICS, the tolerance of long running background Service instances, has been reduced greatly. I think this is related to improving foreground performance and battery life, overall, since running one app at a time (essentially) is the whole trick behind iOS feeling "smooth" and "fast" to end-users. We never really adjusted our mentality around that shift, and thus, the TorService instance generally had a shorter life span than pre-ICS. In addition, there was an interesting phenomenon we took advantage of, which was that even if the TorService instance was killed, the separate processes launched via Runtime.exec() for the tor and privoxy/polipo binaries were not killed. This often caused problems on upgrades, where the entire app was killed or uninstalled, and yet /tor and /polipo kept running. This was definitely a bug, but it also allowed us to be a bit lazy, because as long as these background processes kept running, the lifecycle of the TorService didn't matter so much. Ultimately, this caused many problems with orphaned processees and multiple instaces of /tor running, that caused all sorts of crazy. And another thing (i am running out of ways to say there is more), on early builds of Lollipop, this whole issue was really exacerbated with foreground apps that use a lot of memory, like Chrome browser. Using Chrome with Orbot (via Wifi or APN proxy settings on), caused almost an instant low memory warning in TorService, and then a kill -9. Often, Chrome browser itself would be killed, too. Fortunately, an upgrade to the final release ROM (on my Nexus 7 2013), stopped this behavior, proving that this extreme memory management was actually a bug and not a feature. Not to be forgotten, there was also a bug in TorService where setForeground() was not always being called, but since we call setOngoing(true) in our NotificationBuilder, it made it seem like it was from the UI perspective (you couldn't swipe away the service). I noticed this by running a task manager app, which indicated which services were foreground, and I noticed sometimes TorService was not being called. There is also a known issue with ICS, where receiving/registering for certain Broadcast types, can cause you Foreground=true Service to be reset to Foreground=false. I can't find the exact ticket, but is out there, and Google knows about it. All in all, it is a world of fun with Android, as always, especially if you aren't sticking to the mainstream guidelines for apps, which mostly are "use the cloud for all your processing and push notifications instead of background services". +n > > Cheers, > Michael > > On 01/12/14 08:14, Hans-Christoph Steiner wrote: > > > > Is there any documentation about onDestroy() no longer being > > called? That would be a pretty big change. Maybe something in > > TorService is crashing? Then onDestroy() wouldn't be called. > > > > .hc > > > > Nathan of Guardian: > >> I think we've finally gotten all the background service longevity > >> sorted out, especially on Lollipop where it seemed to be much > >> more brutal, in outright killing of the TorService instant, even > >> without calling onDestroy(). Anyhow, now startForeground() is > >> doing what it should be, we aren't binding any more (Just use > >> broadcasts and startService() calls), and Orbot doesn't show up > >> in recent apps anymore, so no more swiping away.... > >> > >> > >> /** 14.1.4 / 29-Nov-2014 / > >> b7fcbdc4e85071191cc95c3824e7b5a90d36d1e8 **/ > >> > >> * Stop background service being killed 1e0f640 adding > >> dummyactivity to stop task/broadcast from killing foreground > >> service ec9204a clean-up of code to make service more long-lived > >> and stable da4866c update polipo to latest head > >> > >> * Activity and theme updates 917cfa1 support SDK 16, add custom > >> theme, make Orbot singleTop activity 91f4fa0 cleanup landscape > >> layout ad7d92f clean-up / remove un-used code d5823e3 updates to > >> layout to make it cleaner 2d6c26a show exit node info in log > >> > >> APK Lollipop: > >> https://guardianproject.info/releases/Orbot-v14.1.4-LollipopPIE.apk > >> > >> > (.asc) > >> APK <= KitKat: > >> https://guardianproject.info/releases/Orbot-v14.1.4-UpToKitKat-nonPIE.apk > >> > >> > (.asc) > >> > >> Souirce: > >> https://gitweb.torproject.org/orbot.git/commit/b34d971193d843f1258904cba55779a58c819d0f > >> > >> > >> > >> > _______________________________________________ > >> Guardian-dev mailing list > >> > >> Post: [email protected] List info: > >> https://lists.mayfirst.org/mailman/listinfo/guardian-dev > >> > >> To Unsubscribe Send email to: > >> [email protected] Or visit: > >> https://lists.mayfirst.org/mailman/options/guardian-dev/hans%40guardianproject.info > >> > >> > >> > You are subscribed as: [email protected] > >> > > > > > > > > _______________________________________________ Guardian-dev > > mailing list > > > > Post: [email protected] List info: > > https://lists.mayfirst.org/mailman/listinfo/guardian-dev > > > > To Unsubscribe Send email to: > > [email protected] Or visit: > > https://lists.mayfirst.org/mailman/options/guardian-dev/michael%40briarproject.org > > > > You are subscribed as: [email protected] > > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.12 (GNU/Linux) > > iQEcBAEBCAAGBQJUfEeJAAoJEBEET9GfxSfMyFQH/A7UBdpxq78r1yyiaRWa0gJt > ++vcD36f/p3LQTysJRkAWEHaWzkre5BjnuiOM1q0QgxJRmJJK5L2wCIcJIVbTd+d > UCW7H6QB9QlXTYdK3MFMkYYfukWMCGwcPH28Het8nACwiv7PP9t4Ol2Fbxui7Eyo > kUcFKuEpA4bc3W52DX/FcINmJw3eF/thzg7zzuDgOq9DIRnjWIDuJRnFAlWOnQcO > NXOfhqokgnDBJjq91a0LnXiK8JUr7hFjd+5ov6Iyca9BpeY/mIvAQnPJ5/grgY1P > X+aeszQafffjQjgR1Iky9aGbV3KPne1zyQAkv464628yGEddOyPxmHol4bN2DqM= > =JgZt > -----END PGP SIGNATURE----- > _______________________________________________ > Guardian-dev mailing list > > Post: [email protected] > List info: https://lists.mayfirst.org/mailman/listinfo/guardian-dev > > To Unsubscribe > Send email to: [email protected] > Or visit: > > https://lists.mayfirst.org/mailman/options/guardian-dev/nathan%40guardianproject.info > > You are subscribed as: [email protected] -- Nathan of Guardian [email protected] _______________________________________________ Guardian-dev mailing list Post: [email protected] List info: https://lists.mayfirst.org/mailman/listinfo/guardian-dev To Unsubscribe Send email to: [email protected] Or visit: https://lists.mayfirst.org/mailman/options/guardian-dev/archive%40mail-archive.com You are subscribed as: [email protected]
