zulip / zulip-mobile

Zulip mobile apps for Android and iOS.
https://zulip.com/apps/
Apache License 2.0
1.28k stars 643 forks source link

App crashes when trying to upload photo from camera #5696

Open xeruf opened 1 year ago

xeruf commented 1 year ago

Sharing an image to Zulip Android works, but if I use the camera shortcut in the compose box, the app reopens after taking and confirming a picture. Runnign Lineage 19.1 on a Fairphone 3 without GSM.

gnprice commented 1 year ago

Thanks for the report.

I believe this is what currently happens if, while you're using the camera, the system decides that there aren't enough resources to keep the Zulip app in the background, and stops it. A camera app can be very memory-hungry, because phone cameras have a lot of pixels (so the images are big) and do fancy computational photography to process the images.

The way an Android app is expected to handle this is to use a certain API, onSaveInstanceState, to save enough state that when the app gets restarted, it's able to pick up where you left off. So we'd save information like "we're navigated to such-and-such a conversation, the user has the compose box open, and they had such-and-such draft content written in the message content box." Then when we got restarted with the result from the camera app, we'd have our bearings and know where to put that image and what UI to resume showing you.

This is a real issue, but it'll be a significant project to fix. So I don't think it's something we'll get to in the short term. Until we do, the workaround you have is the right one: take the photo separately, and then share it to Zulip.

gnprice commented 6 months ago

Because we're now focused on building a new Zulip mobile app in Flutter and this codebase is in maintenance mode, this isn't an issue we'll end up fixing in the existing codebase. But the same issue will apply to the Flutter app, so it's one we'll want to eventually address there.

In Flutter, the relevant API is RestorationManager. For example on Android I believe that uses the onSaveInstanceState that I mentioned above. So when the time comes to tackle this, we'll study that API and start using it.