mixpanel / mixpanel-react-native

Official React Native Tracking Library for Mixpanel Analytics
https://mixpanel.com
Apache License 2.0
107 stars 47 forks source link

Long Background Task Termination: Mixpanel Instance applicationDidEnterBackground was called over 30 seconds ago #132

Closed jakecronin closed 2 years ago

jakecronin commented 2 years ago

Problem

My app is occasionally terminating in background after 30 seconds in release mode. The below warning appears after ~30 seconds of the app being sent into the background when running with the debugger.

2022-04-17 13:53:10.414266-0400 Siro[83233:4914219] [BackgroundTask] Background Task 297 ("Called by Siro, from $s8Mixpanel0A8InstanceC29applicationDidEnterBackground33_0CB45E1C8B4A4433813A640264188496LLyy10Foundation12NotificationVF"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.

Has anyone else encountered this issue or know of a fix?

Per the error message, the issue seems to be caused by the Mixpanel package, but I find it strange that there is not already an issue report about this issue.

A second strange element is that only ~10% of our users have encountered this issue.

Any ideas?

Environment Information

I do not know if this issue is also occurring on Android

Mixpanel Version: "mixpanel-react-native": "^1.3.10"

Output from npx react-native info: System: OS: macOS 12.3.1 CPU: (10) x64 Apple M1 Pro Memory: 745.50 MB / 32.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 15.13.0 - ~/.nvm/versions/node/v15.13.0/bin/node Yarn: Not Found npm: 7.7.6 - ~/.nvm/versions/node/v15.13.0/bin/npm Watchman: 2022.03.21.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: Not Found IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7935034 Xcode: 13.3.1/13E500a - /usr/bin/xcodebuild Languages: Java: 11.0.15 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.67.4 => 0.67.4

zihejia commented 2 years ago

it should be fixed in 1.4.0. Please feel free to reopen if the problem still exists.