Running C++ early in shutdown without an observer
For late shutdown cleanup, we have nsLayoutStatics::Shutdown(). Do we have a similar method for running things as soon as we've decided that the application is going to shut down? (I know there are observer topics, but I'm trying to avoid having to create an observer object and to make sure that _it_ gets cleaned up properly.) -- Henri Sivonen hsivo...@mozilla.com ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Running C++ early in shutdown without an observer
Have you looked at nsIAsyncShutdown? On 07/06/2019 08:18, Henri Sivonen wrote: > For late shutdown cleanup, we have nsLayoutStatics::Shutdown(). Do we > have a similar method for running things as soon as we've decided that > the application is going to shut down? > > (I know there are observer topics, but I'm trying to avoid having to > create an observer object and to make sure that _it_ gets cleaned up > properly.) > ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Running C++ early in shutdown without an observer
On Fri, Jun 07, 2019 at 09:18:38AM +0300, Henri Sivonen wrote: For late shutdown cleanup, we have nsLayoutStatics::Shutdown(). Do we have a similar method for running things as soon as we've decided that the application is going to shut down? (I know there are observer topics, but I'm trying to avoid having to create an observer object and to make sure that _it_ gets cleaned up properly.) Observers are automatically cleaned up at XPCOM shutdown, so you generally don't need to worry too much about them. That said, nsIAsyncShutdown is really the way to go when possible. But it currently requires an unfortunate amount of boilerplate. ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Running C++ early in shutdown without an observer
On 6/7/2019 9:36 AM, Kris Maglione wrote: On Fri, Jun 07, 2019 at 09:18:38AM +0300, Henri Sivonen wrote: For late shutdown cleanup, we have nsLayoutStatics::Shutdown(). Do we have a similar method for running things as soon as we've decided that the application is going to shut down? (I know there are observer topics, but I'm trying to avoid having to create an observer object and to make sure that _it_ gets cleaned up properly.) Observers are automatically cleaned up at XPCOM shutdown, so you generally don't need to worry too much about them. That said, nsIAsyncShutdown is really the way to go when possible. But it currently requires an unfortunate amount of boilerplate. Note that on Android, you may never get an opportunity for a clean shutdown because the OS can kill your app at any time. I don't know what is the recommendation for shutdown activities on Android. The GeckoView team has had some recent bugs caused by shutdown tasks not running (e.g. committing cached font files or deleting temp files). I think these tasks were moved to startup or scheduled to run periodically. ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Running C++ early in shutdown without an observer
Even on Desktop, we needed to move some cleanup to startup, in case the process was killed by the OS. On 07/06/2019 20:40, Chris Peterson wrote: > On 6/7/2019 9:36 AM, Kris Maglione wrote: >> On Fri, Jun 07, 2019 at 09:18:38AM +0300, Henri Sivonen wrote: >>> For late shutdown cleanup, we have nsLayoutStatics::Shutdown(). Do we >>> have a similar method for running things as soon as we've decided that >>> the application is going to shut down? >>> >>> (I know there are observer topics, but I'm trying to avoid having to >>> create an observer object and to make sure that _it_ gets cleaned up >>> properly.) >> >> Observers are automatically cleaned up at XPCOM shutdown, so you >> generally don't need to worry too much about them. That said, >> nsIAsyncShutdown is really the way to go when possible. But it >> currently requires an unfortunate amount of boilerplate. > > Note that on Android, you may never get an opportunity for a clean > shutdown because the OS can kill your app at any time. > > I don't know what is the recommendation for shutdown activities on > Android. The GeckoView team has had some recent bugs caused by shutdown > tasks not running (e.g. committing cached font files or deleting temp > files). I think these tasks were moved to startup or scheduled to run > periodically. > ___ > dev-platform mailing list > dev-platform@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-platform ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Running C++ early in shutdown without an observer
On Fri, Jun 07, 2019 at 11:40:05AM -0700, Chris Peterson wrote: Note that on Android, you may never get an opportunity for a clean shutdown because the OS can kill your app at any time. I don't know what is the recommendation for shutdown activities on Android. The GeckoView team has had some recent bugs caused by shutdown tasks not running (e.g. committing cached font files or deleting temp files). I think these tasks were moved to startup or scheduled to run periodically. A lot of things really need to have flush timeouts with shutdown blockers for their finalizers. In JS land, we have helpers like DeferredTask and JSONFile for that. I don't think we really have anything comparable for C++. ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Running C++ early in shutdown without an observer
On Fri, Jun 7, 2019 at 9:45 PM Chris Peterson wrote: > > On 6/7/2019 9:36 AM, Kris Maglione wrote: > > On Fri, Jun 07, 2019 at 09:18:38AM +0300, Henri Sivonen wrote: > >> For late shutdown cleanup, we have nsLayoutStatics::Shutdown(). Do we > >> have a similar method for running things as soon as we've decided that > >> the application is going to shut down? > >> > >> (I know there are observer topics, but I'm trying to avoid having to > >> create an observer object and to make sure that _it_ gets cleaned up > >> properly.) > > > > Observers are automatically cleaned up at XPCOM shutdown, so you > > generally don't need to worry too much about them. That said, > > nsIAsyncShutdown is really the way to go when possible. But it currently > > requires an unfortunate amount of boilerplate. Thanks. (nsIAsyncShutdown indeed looks like it involves a lot of boilerplate.) > Note that on Android, you may never get an opportunity for a clean > shutdown because the OS can kill your app at any time. My use case relates to Windows only. -- Henri Sivonen hsivo...@mozilla.com ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: Running C++ early in shutdown without an observer
On 10/06/2019 10:28, Henri Sivonen wrote: >>> Observers are automatically cleaned up at XPCOM shutdown, so you >>> generally don't need to worry too much about them. That said, >>> nsIAsyncShutdown is really the way to go when possible. But it currently >>> requires an unfortunate amount of boilerplate. > > Thanks. (nsIAsyncShutdown indeed looks like it involves a lot of boilerplate.) I'll be happy to review patches that scrap the boilerplate :) Cheers, David ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform