aryk
August 24, 2020, 10:45am
1
In the Expo app and compiled version, having background fetching while the app is running crashes the app when opening after the app is killed:
@kleinhenz Yes it is the same issue. I solved it by ejecting from expo and upgrading the expo-task-manger to 8.4.0. Was a pain to set up since I am a newb with Android Studio, but it got the job done. No crashes so far. I hear the SDK 39 will include this fix so there won’t be a need to eject anymore.
opened 08:30AM - 27 Jul 20 UTC
closed 10:48PM - 07 Oct 20 UTC
Android
TaskManager
## 🐛 Bug Report
### Summary of Issue
The Android Expo client gets unstable … when using background tasks. From the first time a client app with background tasks is started inside the client, the client gets unstable and crashes on start (even before getting to the app selector screen). Aparrently, sometimes it can get to the app selector and selection of an app is possible. After that, the app runs stable until the next restart.
The adb log on a crash looks this:
```
07-27 09:15:53.816 6576 6657 E Expo : Cannot initialize app loader. host.exp.exponent.taskManager.ExpoHeadlessAppLoader
07-27 09:15:53.816 6576 6657 W System.err: java.lang.ClassNotFoundException: host.exp.exponent.taskManager.ExpoHeadlessAppLoader
07-27 09:15:53.816 6576 6657 W System.err: at java.lang.Class.classForName(Native Method)
07-27 09:15:53.816 6576 6657 W System.err: at java.lang.Class.forName(Class.java:454)
07-27 09:15:53.816 6576 6657 W System.err: at java.lang.Class.forName(Class.java:379)
[...]
```
As the app can be started after multiple tries and runs stable after that, I assume this is some kind of race condition. Note: the crash appears *before* getting to the app selector screen, so I *guess* it is not an issue with the client app(s).
Also, the issue *does not* appear in a built standalone app, only in the Expo client. The client is nearly unusable due to this issue.
### Environment - output of `expo diagnostics` & the platform(s) you're targeting
```
Expo CLI 3.22.1 environment info:
System:
OS: Linux 5.6 Fedora 32 (Workstation Edition) 32 (Workstation Edition)
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 14.5.0 - ~/.nvm/versions/node/v14.5.0/bin/node
Yarn: 1.22.4 - ~/.nvm/versions/node/v14.5.0/bin/yarn
npm: 6.14.5 - ~/.nvm/versions/node/v14.5.0/bin/npm
npmPackages:
expo: ^38.0.8 => 38.0.8
react: ~16.11.0 => 16.11.0
react-dom: ~16.11.0 => 16.11.0
react-native: https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz => 0.62.2
react-native-web: ~0.11.7 => 0.11.7
npmGlobalPackages:
expo-cli: 3.22.1
```
Android device is a OnePlus 6, Android 10, Expo client version 2.16.1.
### Reproducible Demo
### Steps to Reproduce
Create an app with a background task. The background task pulls in Location info. Run it in the Android client.
### Expected Behavior vs Actual Behavior
Expected: run the app without issue and stable on reloads. Actual: Expo client is crashing on startup, crashing on client app startup, crashing at app reload. It is crashing all over the place.
opened 06:38PM - 05 Aug 20 UTC
closed 02:19PM - 24 Dec 20 UTC
Android
bug
Location
⭐️ Root Cause Known
## 🐛 Bug Report
### Summary of Issue
I registered a task for receiving the … location updates in the background using `Location.startLocationUpdatesAsync(taskName, options)`, And defined a task in the global scope using `TaskManager.defineTask(taskName, task)`. The app frequently crashes when killed if the background task is active.
- The Expo client refuses to start unless clearing its storage on Android.
- The standalone app starts after at least two trials with a crash message.
### Environment
- expo: `^38.0.0`
- expo-task-manager: `~8.3.0`
- expo-location: `~8.2.1`
### Screenshot
<img src='https://user-images.githubusercontent.com/22864831/89450617-1a368d80-d75b-11ea-8188-09e3cce36932.jpeg' width=200/>
### Steps to Reproduce
1- `Location.startLocationUpdatesAsync`
2- `TaskManager.defineTask`
3- Kill the application.
### Expected Behavior vs Actual Behavior
- **Expected behavior:** The running task terminates smoothly.
- **Actual behavior:**: The running task is killed, and the app can be restarted without a crash message.
Effectively startLocationUpdatesAsync is completely broken in the managed workflow for Android which means one cannot have a location-based app function properly in Expo’s managed workflow.
I’ve heard rumors that this is fixed for SDK 39.0 but none of these threads mention that it was fixed.
Can someone from Expo comment on the state of this issue?
1 Like
nfleig
August 24, 2020, 2:49pm
2
Please have a look at Issue # 9288 .
system
Closed
September 23, 2020, 2:49pm
3
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.