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

Use origURL from react-native-image-picker, when provided. #4475

Closed
wants to merge 5 commits into from

Conversation

chrisbobbe
Copy link
Contributor

@chrisbobbe chrisbobbe commented Feb 13, 2021

Major update (marking this as "blocked" until we investigate more): Looks like React Native has fixed issue facebook/react-native#27099 (linked here), with PR facebook/react-native#31457?! 🎉 I'd predict that this fix would be released in RN v0.65.


Part of #4340.

The added comments are pretty absurdly long, and I'd appreciate any recommendations for how to fix that while still having enough detail. 🙂

This follows the discussion on CZO up to here. My comment there still applies:

If I use origURL, then I can vary the quality in the React Native snippet above, and I don't see a change in the size the server reports: it's 4267773 whether that quality is 1.0, 0.4, or 0.5.

I'd love to have a better idea of why using origURL seemingly lets us bypass React Native's UIImageJPEGRepresentation call.

In particular, this change should eliminate the size inflation that happens when selecting an existing image from the media library on iOS—for some iOS versions. Unfortunately, we don't know the iOS version at which Apple will decide to remove a deprecated iOS API that this optimization depends on (discussion in chat).

We'd obviously prefer to use a library that didn't depend on a deprecated API for this optimization. Unfortunately, if we were to upgrade to the latest version of react-native-image-picker, we'd lose the optimization entirely. And on the most obvious alternative to react-native-image-picker—expo-image-picker—the symptom of the deprecated API being removed would be much worse than missing out on an optimization: it looks like the app would just crash.

As mentioned in the code comments, images coming straight from the camera will still be inflated to almost the same level as they were before. The major obstacle to fixing this is that React Native rudely interferes by uncompressing and recompressing such an image before uploading it, with a compressionQuality of 1.0 (the highest possible value; see discussion on CZO for more detail).

@chrisbobbe
Copy link
Contributor Author

Marking as blocked for now; see edit at top of PR description.

@chrisbobbe
Copy link
Contributor Author

Looks like React Native has fixed issue facebook/react-native#27099 (linked here), with PR facebook/react-native#31457?! 🎉 I'd predict that this fix would be released in RN v0.65.

Welp this was reverted; see: facebook/react-native#33760 (comment)

And react-native-image-picker has changed significantly since I sent this PR, and it's possible that the inflation there has gone away (react-native-image-picker/react-native-image-picker#2006) but we should verify experimentally.

Closing as stale.

@chrisbobbe chrisbobbe closed this Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-iOS blocked on other work To come back to after another related PR, or some other task. upstream: RN Issues related to an issue in React Native
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant