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

BUG. Sending pictures with apple device doesn't work. #4340

Open
tthomasb opened this issue Dec 15, 2020 · 12 comments
Open

BUG. Sending pictures with apple device doesn't work. #4340

tthomasb opened this issue Dec 15, 2020 · 12 comments
Labels
a-compose/send Compose box, autocomplete, camera/upload, outbox, sending a-iOS upstream: RN Issues related to an issue in React Native

Comments

@tthomasb
Copy link

Hello,

some IPhone users noticed that sending pictures doesn't work. We try taking pictures and send them doesn't work in the Zulip app ... Also taking photos with the IPhone camera and just choose them doesn't work. They using IOS 14.2. Is this an Apple bug? Is there a solution for this? Android, Windows client and webapp work for us. Do you need more informations?

Thanks for your answer.

Greetings from germany

Thomas

@shaurya2612
Copy link
Contributor

@ThomasBaeuml Hi Thomas ! Could you send a short vid/gif of what is exactly happening, as the iphone camera is not available on emulators

@pratyaksh123
Copy link

@ThomasBaeuml I think this was just a permissions issue.Just go to settings and check the permissions for photos.

@tthomasb
Copy link
Author

Hey,
@pratyaksh123 No zulip has every permissions.
@shaurya2612 Sorry for late response. I was on a vacation. Below you can see the video.
At first i try du choose a picture from my recordings (Bottom left picture image).
After that i try to take a picture in Zulip and send it... but both doesn't work for all Apple users...

IMG_0518.MP4

@tthomasb
Copy link
Author

tthomasb commented Feb 1, 2021

Are there some news?

@chrisbobbe
Copy link
Contributor

chrisbobbe commented Feb 1, 2021

Thanks for the report!

Here's one bug we're tracking in this area: #2684. We don't yet show a loading indicator while we're waiting for the image to be uploaded. #4129 is open as a way to fix that bug; we should review and resolve that.

But I think you're saying that the image is never uploaded, even after waiting a reasonable amount of time, say, a few minutes. Is that right?

There have been a few bugs that have started to surface with iOS 14, like #4365; this could be one of them. But it's possible that some other variable is involved, or that it's not only happening on iOS 14. I did just test on an iPhone 12 Pro simulator running iOS 14.3, and I was able to send a picture.

You might have already tried this, but I'd be interested to know (especially with the knowledge about the unfortunate bug #2684): what happens if you choose an extremely small image from the media library, so it should get uploaded very quickly, and you wait for a whole minute or two with a good Internet connection? There won't be a progress indicator, but I'd be interested to know if it gets uploaded at all.

@tthomasb
Copy link
Author

tthomasb commented Feb 2, 2021

Thanks for your quick reply.

We have run a few scenarios.

/etc/zulip/settings.py MAX_FILE_UPLOAD_SIZE = 5

  • Android/ PC can send images with a size of 3 MB (MAX_FILE_UPLOAD_SIZE = 5). Apple cannot. But once I set MAX_FILE_UPLOAD_SIZE = 80 IOS can send 3 MB.
    (Why are Apple images with the same size bigger than Android images? Looks like an Apple problem...)
  • Compressed images are sent after a certain time, even though the internet connection is very good.
  • Maybe a feedback if the image is to big or there is a problem to send it would be a good feature request.
  • Also a compression of the images would be a good new feature.

Is there option to fix this? For my company there is no option to set MAX_FILE_UPLOAD_SIZE so high.

@chrisbobbe
Copy link
Contributor

chrisbobbe commented Feb 10, 2021

Thanks so much for that investigation, @ThomasBaeuml!

(Why are Apple images with the same size bigger than Android images? Looks like an Apple problem...)

That's odd! I'm seeing some reported issues (here, here) in a library we use for interacting with the platform's media library. It looks like people suspect that library is choosing an artificially large file on iOS; I'm looking into it.

@gnprice gnprice added a-compose/send Compose box, autocomplete, camera/upload, outbox, sending a-iOS upstream: RN Issues related to an issue in React Native labels Feb 11, 2021
@j-perl
Copy link

j-perl commented Feb 12, 2021

Any news yet? However small they are. We also rely on react-native-image-picker and we have the exact same problem.

@chrisbobbe
Copy link
Contributor

chrisbobbe commented Feb 12, 2021

Any news yet? However small they are. We also rely on react-native-image-picker and we have the exact same problem.

Welcome to Zulip, @j-perl! 🙂 It sounds like you've arrived here from a different React Native project, where you've run into a problem with choosing an image from the media library on iOS and uploading it to a server.

We've been debugging at https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/JPEG.20file.20sizes/near/1116254. Feel free to follow our conversation there. Before you do so, please read the chat.zulip.org community guide. 🙂

I expect to send a zulip-mobile PR later today, with at least a partial fix and an explanation for it.

One key finding is that passing 1.0 as the compressionQuality argument to iOS's UIImageJPEGRepresentation tends to produce an image with an inflated size. We wish there were a standard recommendation for a good value to use, but we haven't found one.

For us, there are two layers where UIImageJPEGRepresentation can get applied: one in react-native-image-picker, and one in React Native itself, just before sending the POST request to upload the image to the server (in the code here, mentioned in a comment on facebook/react-native#27099).

Our plan for now is to stay on react-native-image-picker v2, which exposes origURL, the path to the original image on the device (though the package uses a deprecated iOS API to get this value, yikes). This means ignoring the copy of the image that gets made with UIImageJPEGRepresentation and just using the original. Somehow (please let us know if you find out how!), using origURL also seems to let us bypass React Native's UIImageJPEGRepresentation call, and when the server receives the file, it reports a normal file size.

@chrisbobbe
Copy link
Contributor

We've found that you can get logs from the Objective-C code to the Chrome remote-debugging console (I was surprised to see them not going to Xcode) by using RCTLog and making this change to the AppDelegate.m:

- RCTSetLogThreshold(RCTLogLevelError);
+ RCTSetLogThreshold(RCTLogLevelInfo);

@j-perl
Copy link

j-perl commented Feb 12, 2021

@chrisbobbe Hi! How rude of me! Indeed, I came from another project which relies on react-native-image-picker as well and the way I got here was from this thread you mentioned react-native-image-picker/react-native-image-picker#1419. The issue described here resembles a lot to the issue we have. I should have instead reported this issue there. I apologize for any inconvenience. I thank you very much for the findings so far! Rest assured that if we find anything, we will inform you as well.

We have just upgraded to react-native-image-picker v3 but will not hesitate to downgrade again if necessary...

Again, many thanks.

Regards

chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this issue Feb 13, 2021
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this issue Feb 13, 2021
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this issue Feb 13, 2021
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this issue Feb 13, 2021
@chrisbobbe
Copy link
Contributor

Just filed #4752—the server does time out if it waits too long for a file to upload, which could explain some files just never getting uploaded at all! It's still a problem that the files are way bigger than they need to be (#4475 is a partial solution for that), but Tim suggests we can get around the timeouts by uploading files in chunks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-compose/send Compose box, autocomplete, camera/upload, outbox, sending a-iOS upstream: RN Issues related to an issue in React Native
Projects
None yet
Development

No branches or pull requests

6 participants