SimonSimCity / Xamarin-CrossDownloadManager

A cross platform download manager for Xamarin
MIT License
149 stars 68 forks source link

[Android] Files remain pending #96

Closed Sebberrou closed 6 years ago

Sebberrou commented 6 years ago

Hi, In my Xamarin forms project I use CrossDownloadManager to download files from a local device with its own wifi. It is working fine in iOS and Android before 7.0. But after Android 7.0 when I start the download it remain pending, I could debug only on an emulator but i have the same behavior. PropertyChanged event call once TotalByteExpected at -1 and Status on Pending

Any ideas what could cause it ? Thank you

SimonSimCity commented 6 years ago

Sorry for the late response. I do not have much time to work on this or spend time reproducing it, but I don't want to let you down on this one. It reminds me of https://github.com/SimonSimCity/Xamarin-CrossDownloadManager/issues/33 where a files above a certain size could not be downloaded from some Android version on.

Can you please confirm if it also fails using the demo project of this repo? https://github.com/SimonSimCity/Xamarin-CrossDownloadManager/tree/develop/DownloadManager

If this works, please create a minimal Xamarin forms project and try to get it working there. If it works, try to either build up on the minimal project or strip down yours to try if there's anything blocking.

Another approach which you could also use is to clone this repo to your machine and add the projects of this library to yours instead of using the nuget-package. This will give you the possibility to debug in detail 1. how this plugin works and 2. where the bug could be.

Hope this helps.

Sebberrou commented 6 years ago

Don't worry having your library is already really good :)

First thing I managed to handle the problem in some android by handling the PENDING State case DownloadFileStatus.PENDING: CrossDownloadManager.Current.AbortAll(); I could then restart the download and it work.

but the problem remain on a samsung S8. Finally I think i just had to disable the mobile Network download. I left it by default and only though to turn it off when I ran your sample haha, It will be tested on a samsung S8 later this day. Thank you already :)

SimonSimCity commented 6 years ago

Have you had a chance to look at it again?

Aborting all downloads if one of them enters the pending-state doesn't sound very efficient - but I think I'd need an Samsung S8 in order to properly reproduce it. Could you try to get it?

Btw - do you also see this problem in the simulator or only on a real device? It could also well be that the manufacturer here blew something up with the changes he made to the Android code-base. Samsung is quite known for doing that.

I'm personally using this library on an Android 8.1.0 without any problems and don't know of anyone else facing issues like this. Please also check if there are outstanding updates for the packages you use.

Sebberrou commented 6 years ago

Yes, it does not work for my coworker with a Samsung S8 but in the end it worked for the customer with the same phone.

And for canceling all download yes I added a check to do it only if all downloads are pending.

The main problem must have been allowing mobile network download when downloading from a wifi with no internet connection, but now I think it will work, Thank you for your help :)