Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashes when force stopped while background location task created using expo-task-manager and expo-location is active #28728

Open
vedant-patil-mapup opened this issue May 9, 2024 · 0 comments
Labels
needs review Issue is ready to be reviewed by a maintainer

Comments

@vedant-patil-mapup
Copy link

Minimal reproducible example

https://github.com/vedant-patil-mapup/expo-background-location-crash-example

What platform(s) does this occur on?

Android

Did you reproduce this issue in a development build?

No (only happens in a standalone build)

Summary

Expected behaviour:
App should not crash even if the background service got terminated due to force stop or device reboot.

Actual behaviour:

  • The app crashes if background service was started by the app and if the app was force stopped or device rebooted, this happens on standalone app.
  • The app won't crash if it was force stopped, but the background service was not active during when app was force stopped.
  • The app crashes only if there are some extra dependencies installed, other than the ones required for background service.

Works fine with these dependencies:

{
    "expo": "~50.0.17",
    "expo-status-bar": "~1.11.1",
    "react": "18.2.0",
    "react-native": "0.73.6",
    "expo-task-manager": "~11.7.3",
    "expo-location": "~16.5.5"
}

Crashes with these dependencies:

{
    "expo": "~50.0.17",
    "expo-status-bar": "~1.11.1",
    "react": "18.2.0",
    "react-native": "0.73.6",
    "expo-task-manager": "~11.7.3",
    "expo-location": "~16.5.5",

    // adding below dependencies makes the app crash on force stop
    "expo-device": "~5.9.4",
    "expo-document-picker": "~11.10.1",
    "expo-linear-gradient": "~12.7.2",
    "expo-font": "~11.10.3",
    "expo-haptics": "~12.8.1",
    "expo-keep-awake": "~12.8.2",
    "expo-linking": "~6.2.2",
    "expo-localization": "~14.8.4",
    "expo-system-ui": "~2.9.4",
    "expo-notifications": "~0.27.7",
    "expo-speech": "~11.7.0",
    "expo-updates": "~0.24.12",
    "expo-web-browser": "~12.8.2"
}

Logcat error logs:

❌ Cannot install JSI interop: java.lang.IllegalArgumentException: The module wasn't created! You can't access the app context.
java.lang.IllegalArgumentException: The module wasn't created! You can't access the app context.
	at expo.modules.kotlin.modules.Module.getAppContext(Module.kt:21)
	at expo.modules.kotlin.ModuleHolder$jsObject$2.invoke(ModuleHolder.kt:28)
	at expo.modules.kotlin.ModuleHolder$jsObject$2.invoke(ModuleHolder.kt:26)
	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
	at expo.modules.kotlin.ModuleHolder.getJsObject(ModuleHolder.kt:26)
	at expo.modules.kotlin.jni.JSIInteropModuleRegistry.getCoreModuleObject(JSIInteropModuleRegistry.kt:116)
	at expo.modules.kotlin.jni.JSIInteropModuleRegistry.installJSI(Native Method)
	at expo.modules.kotlin.AppContext.installJSIInterop(AppContext.kt:155)
	at expo.modules.kotlin.KotlinInteropModuleRegistry.installJSIInterop(KotlinInteropModuleRegistry.kt:128)
	at expo.modules.adapters.react.NativeModulesProxy.getConstants(NativeModulesProxy.java:103)
	at com.facebook.react.bridge.JavaModuleWrapper.getConstants(JavaModuleWrapper.java:127)
	at com.facebook.jni.NativeRunnable.run(Native Method)
	at android.os.Handler.handleCallback(Handler.java:942)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
	at android.os.Looper.loopOnce(Looper.java:223)
	at android.os.Looper.loop(Looper.java:324)
	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:234)
	at java.lang.Thread.run(Thread.java:1012)
✅ Constants were exported
No native ExponentConstants module found, are you sure the expo-constants's module is linked properly?
Error: Cannot find native module 'ExpoFontLoader', js engine: hermes
Running "main
Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes
Could not find generated setter for class com.facebook.react.views.drawer.ReactDrawerLayoutManager
Could not find generated setter for class com.facebook.react.uimanager.LayoutShadowNode
Could not find generated setter for class com.facebook.react.views.scroll.ReactHorizontalScrollViewManager
FATAL EXCEPTION: mqt_native_modules
Process: com.vedantmapup2254.exampleapp, PID: 12242
com.facebook.react.common.JavascriptException: Error: Cannot find native module 'ExpoFontLoader', js engine: hermes, stack:
requireNativeModule@1:633722
anonymous@1:661107
loadModuleImplementation@1:16921
guardedLoadModule@1:16469
metroRequire@1:16091
anonymous@1:659022
loadModuleImplementation@1:16921
guardedLoadModule@1:16469
metroRequire@1:16091
anonymous@1:658512
loadModuleImplementation@1:16921
guardedLoadModule@1:16469
metroRequire@1:16091
anonymous@1:23493
loadModuleImplementation@1:16921
guardedLoadModule@1:16469
metroRequire@1:16091
anonymous@1:23365
loadModuleImplementation@1:16921
guardedLoadModule@1:16469
metroRequire@1:16091
anonymous@1:23182
loadModuleImplementation@1:16921
guardedLoadModule@1:16426
metroRequire@1:16091
global@1:15643

	at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:65)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
	at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:149)
	at com.facebook.jni.NativeRunnable.run(Native Method)
	at android.os.Handler.handleCallback(Handler.java:942)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
	at android.os.Looper.loopOnce(Looper.java:223)
	at android.os.Looper.loop(Looper.java:324)
	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:234)
	at java.lang.Thread.run(Thread.java:1012)

Logcat error logs:

Invariant Violation: Failed to call into JavaScript module method RCTEventEmitter.receiveTouches(). Module has not been registered as callable. Bridgeless Mode: false. Registered callable JavaScript modules (n = 10): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, HMRClient, AppRegistry.
          A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
Invariant Violation: Failed to call into JavaScript module method RCTEventEmitter.receiveTouches(). Module has not been registered as callable. Bridgeless Mode: false. Registered callable JavaScript modules (n = 10): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, HMRClient, AppRegistry.
          A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
FATAL EXCEPTION: mqt_native_modules
Process: com.vedantmapup2254.exampleapp, PID: 11943
com.facebook.react.common.JavascriptException: Invariant Violation: Failed to call into JavaScript module method RCTEventEmitter.receiveTouches(). Module has not been registered as callable. Bridgeless Mode: false. Registered callable JavaScript modules (n = 10): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, HMRClient, AppRegistry.
          A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes, stack:
invariant@1:90840
__callFunction@1:100605
anonymous@1:99123
__guard@1:100063
callFunctionReturnFlushedQueue@1:99081

	at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:65)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
	at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:149)
	at com.facebook.jni.NativeRunnable.run(Native Method)
	at android.os.Handler.handleCallback(Handler.java:942)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
	at android.os.Looper.loopOnce(Looper.java:223)
	at android.os.Looper.loop(Looper.java:324)
	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:234)
	at java.lang.Thread.run(Thread.java:1012)

Steps to reproduce:

  • Start the app, enable background location service and close the app.
  • Force stop the app, and open it again, it should crash
  • If it works fine on first try, repeat the steps and it should crash on second or third try

Environment

expo-env-info 1.2.0 environment info:
System:
OS: macOS 14.4.1
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.8.0 - /opt/homebrew/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 10.1.0 - /opt/homebrew/bin/npm
Watchman: 2023.10.02.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.14.3 - /Users/vedantpatil/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms: DriverKit 23.4, iOS 17.4, macOS 14.4, tvOS 17.4, visionOS 1.1, watchOS 10.4
Android SDK:
API Levels: 29, 33, 34
Build Tools: 29.0.2, 30.0.3, 33.0.0, 33.0.1, 33.0.2, 34.0.0
System Images: android-34 | Google APIs ARM 64 v8a, android-34 | Google Play ARM 64 v8a
IDEs:
Android Studio: 2022.3 AI-223.8836.35.2231.10671973
Xcode: 15.3/15E204a - /usr/bin/xcodebuild
npmPackages:
expo: ~50.0.17 => 50.0.18
react: 18.2.0 => 18.2.0
react-native: 0.73.6 => 0.73.6
npmGlobalPackages:
eas-cli: 8.0.0
Expo Workflow: bare

Expo Doctor Diagnostics

✔ Check Expo config for common issues
✔ Check package.json for common issues
✔ Check native tooling versions
✔ Check dependencies for packages that should not be installed directly
✔ Check for common project setup issues
✔ Check for issues with metro config
✔ Check npm/ yarn versions
✔ Check Expo config (app.json/ app.config.js) schema
✔ Check that packages match versions required by installed Expo SDK
✔ Check for legacy global CLI installed locally
✔ Check that native modules do not use incompatible support packages
✔ Check that native modules use compatible support package versions for installed Expo SDK

Didn't find any issues with the project!

@vedant-patil-mapup vedant-patil-mapup added the needs validation Issue needs to be validated label May 9, 2024
@expo-bot expo-bot added needs review Issue is ready to be reviewed by a maintainer and removed needs validation Issue needs to be validated labels May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review Issue is ready to be reviewed by a maintainer
Projects
None yet
Development

No branches or pull requests

2 participants