Skip to content

react-native-webview - File download without granted storage permission crashes app on Android #5831

@magiskaoskar

Description

@magiskaoskar

🐛 Bug Report

Environment

Expo CLI 3.1.2 environment info:
System:
OS: macOS 10.14.6
Shell: 5.3 - /bin/zsh
Binaries:
Node: 12.6.0 - ~/.nvm/versions/node/v12.6.0/bin/node
Yarn: 1.19.0 - /usr/local/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v12.6.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Android Studio: 3.2 AI-181.5540.7.32.5056338
Xcode: 10.3/10G8 - /usr/bin/xcodebuild
npmPackages:
expo: ^35.0.0 => 35.0.0
react: 16.8.3 => 16.8.3
react-native: https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz => 0.59.8
react-navigation: ^4.0.6 => 4.0.10
npmGlobalPackages:
expo-cli: 3.1.2

App target: Standalone Android and Android Expo Client.

Steps to Reproduce

Create a new expo project.
Make sure storage permission is NOT accepted for the app (Expo client if you don't build a standalone app).
Try to download a file from a website in a webview (react-native-webview).

If you try to reproduce this bug in a standalone app you will need to add permissions "READ_EXTERNAL_STORAGE" and "WRITE_EXTERNAL_STORAGE" to app.json.

Expected Behavior

When clicking download it should ask for permission for storage. If the user accepts the permission it should download the file. If the user denies nothing should happen.

Actual Behavior

The app crashes.
Crash

Reproducible Demo

https://snack.expo.io/r1bjtCZuH

Download button is in the top right.

Other

There is also a similar issue with the camera in a webview. If you click on an <input type="file" accept="image/*"> the webview will ask if you want to take a photo or select an existing photo. If you choose "take photo" nothing will happen if the camera permission isn't already accepted.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions