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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing CAMERA_ROLL permissions when running in headless mode #7456

Closed
niekcandaele opened this issue Mar 24, 2020 · 2 comments 路 Fixed by #7962
Closed

Missing CAMERA_ROLL permissions when running in headless mode #7456

niekcandaele opened this issue Mar 24, 2020 · 2 comments 路 Fixed by #7962

Comments

@niekcandaele
Copy link

馃悰 Bug Report

Environment

Expo CLI 3.15.5 environment info:
System:
OS: Linux 4.15 Linux Mint 19.1 (Tessa)
Shell: 5.4.2 - /usr/bin/zsh
Binaries:
Node: 13.9.0 - ~/.nvm/versions/node/v13.9.0/bin/node
Yarn: 1.22.0 - ~/.nvm/versions/node/v13.9.0/bin/yarn
npm: 6.13.7 - ~/.nvm/versions/node/v13.9.0/bin/npm
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.6010548
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.5 => 0.61.5
npmGlobalPackages:
expo-cli: 3.15.5

Android. Bare React Native

Steps to Reproduce

We are trying to run some photo processing in the background when the app is closed. To do this, we are using Headless JS from React Native. This involves reading photos from the camera roll & getting AssetInfo from these.

When the app is still running and we run the BG task, everything works fine. When the app is terminated and we run the BG task, the headless task errors out.

Expected Behavior

I expected the app to be able to load Assets in a background task.

Actual Behavior

The function errors out with Error: Missing CAMERA_ROLL permissions.

Reproducible Demo

https://github.com/niekcandaele/repro-expo-medialibrary-issue

You can trigger the headless task with
adb shell cmd jobscheduler run -f com.testappbackgroundfetch 999

Logs when app is still running:

 LOG  [BackgroundFetch HeadlessTask] start:  undefined
 LOG  {"canAskAgain": true, "expires": "never", "granted": true, "status": "granted"}
 LOG  [BackgroundFetch HeadlessTask] response:  {"assets": [{Output truncated}]}

Logs when app is terminated:

 LOG  [BackgroundFetch HeadlessTask] start:  react-native-background-fetch
 LOG  {"canAskAgain": false, "expires": "never", "granted": false, "status": "denied"}
 LOG  Error getting assets from library! Error: Missing CAMERA_ROLL permissions.

image

@cruzach
Copy link
Contributor

cruzach commented Mar 25, 2020

Are you sure that the Android OS allows you to access the device's camera roll when the app has been backgrounded?

@MorelSerge
Copy link

Permission to the camera roll on Android is defined by the READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions. There is no restriction as to when these permissions can be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants