-
Notifications
You must be signed in to change notification settings - Fork 25k
Description
Just received a random Android crash from the crash reporting tool. I haven't been able to reproduce it, but the headless task runs every 60 minutes and is intended to finish before the 30s timeout it is given. The crash happened from a headless task that didn't run with the app previously initialized (with an UI / main activity). Crash
java.lang.AssertionError Tried to finish non-existent task with id 2.
Assertions.java:72 com.facebook.infer.annotation.Assertions.assertCondition
HeadlessJsTaskContext.java:164 com.facebook.react.jstasks.HeadlessJsTaskContext.finishTask
HeadlessJsTaskContext.java:202 com.facebook.react.jstasks.HeadlessJsTaskContext$3.run
Handler.java:873 android.os.Handler.handleCallback
Handler.java:99 android.os.Handler.dispatchMessage
Looper.java:214 android.os.Looper.loop
ActivityThread.java:6986 android.app.ActivityThread.main
Method.java:-2 java.lang.reflect.Method.invoke
RuntimeInit.java:494 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run
ZygoteInit.java:1445 com.android.internal.os.ZygoteInit.main
After tracing the error, I ended up here: https://github.com/facebook/react-native/blob/0.61-stable/ReactAndroid/src/main/java/com/facebook/react/jstasks/HeadlessJsTaskContext.java#L202 , here https://github.com/facebook/react-native/blob/0.61-stable/ReactAndroid/src/main/java/com/facebook/react/jstasks/HeadlessJsTaskContext.java#L111 and here https://github.com/facebook/react-native/blob/0.61-stable/ReactAndroid/src/main/java/com/facebook/react/jstasks/HeadlessJsTaskContext.java#L165
From the above I can't really tell if the task timed out and it failed to be notified, or if it finished on time, but the timeout also fired (a race condition between the is running check and the actual finish call?) causing the crash. For me this assertion seems a bit to aggressive, and it should be just a warning rather than an app crash.
React Native version:
System:
OS: macOS Mojave 10.14.6
CPU: (4) x64 Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz
Memory: 221.69 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.15.3 - /usr/local/bin/node
npm: 6.13.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.3, 29.0.2
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 11.2.1/11B53 - /usr/bin/xcodebuild
npmPackages:
react: 16.12.0 => 16.12.0
react-native: 0.61.5 => 0.61.5
npmGlobalPackages:
create-react-native-app: 2.0.2
create-react-native-module: 0.10.2
react-native-cli: 2.0.1
Steps To Reproduce
- Create a headless js task with 30 seconds timeout or so. The JS code should not exceed the timeout.
- Run the task from an alarm manager, or something that allows you to run it periodically (e.g., react-native-background-fetch)
- Observe the crash. Note, this crash is quite random, and happened once in a 30d time period of about 350 android devices.