bitstadium / HockeySDK-iOS

HockeyApp was retired and the SDKs are deprecated. Please use App Center instead.
https://github.com/microsoft/appcenter-sdk-apple
Other
597 stars 268 forks source link

AppNotTerminatingCleanly event reported for background sessions #518

Closed damirdavletov closed 6 years ago

damirdavletov commented 6 years ago

In version 5.1.2, when application process is started in background by location update or background fetch event and then killed in background by iOS, HockeyApp SDK generates AppNotTerminatingCleanly report. This was not present in v4 and looks like a bug. We had to downgrade the SDK for all our apps.

bmourat commented 6 years ago

Hey @damirdavletov

As it is stated in docs enableAppNotTerminatingCleanlyDetection api was tested only on iOS 6.1 and iOS 7 and may report false positives. I've tried to reproduce this issue today, but with no luck. To further investigate and reproduce this, i need some additional info:

  1. iOS version under test
  2. Device or simulator
  3. Setup code for CLLocationManager
  4. Code for handler locationManager:manager didUpdateLocations:locations

Best, Murat

damirdavletov commented 6 years ago

Hi @bmourat !

Thank you for the reply! We have used this detection for several years and it was very useful for us regardless of relatively small number of false positives. After we upgraded the Hockey SDK from v4.0.2 to v5.1.2 in one of our apps the number of such crashes rose from ~500pd to 60000pd. This number of false positives makes the feature useless for apps which wake up in background. After we downgraded to v4.1.6 the number when back down.

To answer your questions:

  1. The app's deployment target is iOS 10.0, so it happens on all iOS 10.x-11.x versions for us.
  2. We reliably reproduced it on devices when waking the process up with 'remote-notification' type of push. In hockeyApp we see that it's reproduced on all types of devices we support.
  3. CLLocationManager is set up like this for background [locationManager startMonitoringSignificantLocationChanges];
  4. In - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations method we perform some location filtering and send them to server that's it. Unfortunately, I can't copy-paste the code here. The fact that it crashes on location update is my assumption, I did not test it.

Exact steps to reproduce:

  1. Launch the app and send it to background
  2. Launch another app e.g. Facebook
  3. Launch a lot of apps like Safari, open videos there etc. as many as possible.
  4. Launch Facebook again check that it has been purged by iOS. If not do step 3 again.
  5. Send remote-notification push to the app so it's woken up by iOS. Make sure it's running, but don't launch it (We checked server logs).
  6. Do steps 2-4 again until the app is purged again.
  7. Open the app and check that the appNotTerminatedCleanly event is reported.

These steps were performed by manual QA to reproduce, I'm sure you can do it easier with kill(getpid(), SIGKILL); in background, but you get the idea. Please note that the app needs to be killed not by the user, but by iOS, otherwise it won't be woken up. For us it's easier to reproduce it with remote-notification push.

P.S. If you need more help reproducing let me know or ping me on Facebook: https://www.facebook.com/damir.davletov.12

ElektrojungeAtWork commented 6 years ago

Hey @damirdavletov,

could you please get in touch via support to share your code so we can repro the issue that you are seeing?