Piwigo / Piwigo-Mobile

Piwigo iOS Mobile Application
MIT License
98 stars 30 forks source link

[BUG] Upload gets stuck with 'Failed to retrieve photo.' #549

Closed bcl closed 1 month ago

bcl commented 10 months ago

Describe the bug and how to reproduce When uploading images it frequently gets stuck. It says 'Failed to retrieve photo.' under the photos. It then stops trying to upload anything (confirmed by running tcpdump on the server and watching for traffic).

Steps to reproduce the behavior:

  1. Go to list of photos to upload
  2. Watch it try a few uploads, fail, and get stuck. It seems to always have 5 listed in 'Impossible Uploads'

Expected behavior Upload photos or show clear errors that can help debug the issue.

What did you do already

Screenshots If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

Additional context

This was also happening with a previous release of the mobile app and I had given up using it to upload. After a recent update it started working better. And then I upgraded my server to 13.8.0 and it started having issues with uploads freezing again.

I tried clearing the whole cache, so now it has over 1000 photos to re-upload or check, and it does a few of them and then quits. No error are logged in the piwigo debug logs, php logs, or webserver logs. I can capture traffic between the server and the mobile app and nothing looks obviously wrong, it tests a few image checksums, gets some info back, and then quits.

I have also confirmed that the piwigo mobile app is allowed access to 'All Photos' in the iOS settings.

EddyLB commented 10 months ago

The error 'Failed to retrieve photo' tells that the app could not retrieve the file of the photo/video stored in the Photos app and therefore could not prepare the upload.

Can you please describe the photos/videos which cannot be uploaded? their format? name? etc.

bcl commented 8 months ago

Sorry for the delay. They are all jpeg images taken with the iPhone camera. I've since upgraded the phone, the new one is running iOS 16.6 and it has the same problem. Except now there are 1800 pending uploads :)

I've added some diagnostic logging to pwg.images.php and used tcpdump to capture the traffic. The client does the following for 5 images and then quits:

- - - [12/Oct/2023:18:38:00 -0700] "POST /ws.php?format=json&method=pwg.session.getStatus HTTP/1.1" 200 459 "-" "Piwigo/533 CFNetwork/1410.0.3 Darwin/22.6.0"
- - - [12/Oct/2023:18:38:00 -0700] "POST /ws.php?format=json&method=pwg.images.exist HTTP/1.1" 200 67 "-" "Piwigo/533 CFNetwork/1410.0.3 Darwin/22.6.0"
- - - [12/Oct/2023:18:38:00 -0700] "POST /ws.php?format=json&method=pwg.images.getInfo HTTP/1.1" 200 2589 "-" "Piwigo/533 CFNetwork/1410.0.3 Darwin/22.6.0"

The payloads look reasonable, the getInfo request returns a pile of json with information about the image that starts out like this:

{"stat":"ok","result":{"image":{"id":43975,"file":"IMG_2213.JPG","date_available":"2023-07-30 21:42:30", ...

The client has visible thumbnails for all the images, so I assume it is accessing the photo library (permission are set so that it is allowed to access it). When I tell it to 'clear 5 failed uploads' it tries the next 5 sometimes, or gets stuck.

So as far as I can tell, the client has access to the photos. It's calculating the checksum and has thumbnails visible in the upload dialog. It gets the info from the server that the photo already exists, but at that point something goes wrong and it quits trying after 5 photos. I don't see any errors in the server logs, and I don't see any requests other than those 3 repeating (after the initial login requests).

Also, it can successfully access the photos on the server FWIW, I can view them all just fine.

EddyLB commented 1 month ago

Fixed together with #554