nextcloud / ios

📱 Nextcloud iOS App
https://itunes.apple.com/us/app/nextcloud/id1125420102
GNU General Public License v3.0
1.99k stars 884 forks source link

The whole application freezes during upload #888

Open iddm opened 5 years ago

iddm commented 5 years ago

Expected behaviour

The application does not freeze, and we can still use it during uploading files to the server, all the job is performed in a background thread without blocking the main thread. Also, responsiveness is not affected.

Actual behaviour

The application freezes during file upload, and almost does not respond as all of the touches and other events are queued in the main loop and are not processed at an expected time, what harms the user experience.

Steps to reproduce

Just upload a file either manually or by a synchronisation mechanism: make a photo or video using your iPhone and then open the app: it will start synchronisation, and this problem will occur.

iOS version

iOS 12.2

App version

Latest on the 19.06.2019, 2.23.7.9, 2019. The problem described was happening for a half year at least, so not only this version has this defect.

Server configuration

All versions of next cloud 14, 15 and 16 (not 16.0.1) in docker (so from dockerhub)

Operating system: iOS, Linux.

Web server: Nginx

Database: MariaDB

PHP version: The one in the official image of nextcloud in dockerhub.

Nextcloud version: (see Nextcloud admin page) 16.0.1

blizzz commented 5 years ago

@marinofaggiana do you have an idea?

sman-dk commented 5 years ago

Hi

I am seeing a behaviour similar to this on IOS 12.3.1. When I upload one or more photos the app goes back to the "login screen", as if the app was just started. However the login button does not work at all and the only solution is to quit the app and start it again.

The upload does progress in the background, but any further user interaction is impossible without restarting the app. Even after all the desired files are uploaded the login button still does not work.

This makes the IOS app almost unusable for uploading files, and I often find myself using the web interface instead.

jstawski commented 5 years ago

Hello, I am experiencing the same issue and it behaves like a memory leak as eventually the app crashes. Things move very slowly. I have been trying to upload my entire photo collection (over 7000 files) for the past two days. It is very slow.

jamesstout commented 5 years ago

Can confirm ... currently uploading 25000 photos ... interface becomes very laggy.

iddm commented 5 years ago

If anyone had wanted, this would have already been fixed after a week since this issue was initially created. Forget about it.

jamesstout commented 4 years ago

I spent a lot of time looking at this. Experimenting with putting network tasks on low prio threads:

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
  ...
});

However, after every upload, and I think maybe before each upload, the state is read/written to the Realm db - which seems to happen on the main thread, as it's kicked off on main:

https://github.com/nextcloud/ios/blob/b738135e785b5e4b0fb5ab871297863ab4a65656/iOSClient/AppDelegate.m#L1468-L1473

If you try to put on a background thread, you get a crash:

Instances of RLMRealm, RLMResults, or RLMArray, or managed instances of RLMObject are thread-confined, meaning that they can only be used on the thread on which they were created, otherwise an exception is thrown*

I've tried wrapping the db writes in async enclosures, but ... but I'm really not a Swift dev.

I've spotted quite a few possibilities for optimizations... what's the contribution process? Fork, branch off master?

marinofaggiana commented 4 years ago

It's complex because, especially in lan, the upload is in part in backgroud and in part in foreground o better in the first task (for refresh the UI), and this generate several slowdowns.

It can certainly be optimized or rewritten but it is not a priority.