Bug 29559 - AsyncImageAndroid does not download image and throws System.Net.WebException
Summary: AsyncImageAndroid does not download image and throws System.Net.WebException
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 5.1
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: 6.0 (C6)
Assignee: Marek Habersack
Depends on:
Reported: 2015-04-29 17:41 UTC by Ben Beckley
Modified: 2015-07-20 15:47 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Ben Beckley 2015-04-29 17:41:26 UTC
Upon clicking the download button in the AsyncImageAndroid sample, the following occurs:

> I/mono-stdout(16765): System.Net.WebException: Error getting response stream (ReadDone4): ServerProtocolViolation ---> System.Exception:    at System.Net.WebConnection.HandleError(WebExceptionStatus st, System.Exception e, System.String where)
> I/mono-stdout(16765):    at System.Net.WebConnection.ReadDone(IAsyncResult result)
> I/mono-stdout(16765):   at System.Net.WebConnection.HandleError (WebExceptionStatus st, System.Exception e, System.String where) <0xa09e7f00 + 0x00114> in <filename unknown>:0 
> I/mono-stdout(16765):   --- End of inner exception stack trace ---
> I/mono-stdout(16765):   at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) <0xa09eac78 + 0x00160> in <filename unknown>:0 
> I/mono-stdout(16765):   at System.Net.WebClient.GetWebResponse (System.Net.WebRequest request, IAsyncResult result) <0xa09eac28 + 0x0002b> in <filename unknown>:0 
> I/mono-stdout(16765):   at System.Net.WebClient.DownloadBitsResponseCallback (IAsyncResult result) <0xa09ea808 + 0x000ab> in <filename unknown>:0 
> I/mono-stdout(16765): --- End of stack trace from previous location where exception was thrown ---
> I/mono-stdout(16765):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0xa098bd50 + 0x00024> in <filename unknown>:0 
> I/mono-stdout(16765):   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0xa098b828 + 0x000bb> in <filename unknown>:0 
> I/mono-stdout(16765):   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0xa098b648 + 0x0008b> in <filename unknown>:0 
> I/mono-stdout(16765):   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0xa098b5e8 + 0x0003f> in <filename unknown>:0 
> I/mono-stdout(16765):   at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () <0xa098b568 + 0x0001b> in <filename unknown>:0 
> I/mono-stdout(16765):   at AsyncImageAndroid.MainActivity+<downloadAsync>c__async0.MoveNext () <0xaeab2158 + 0x003c3> in <filename unknown>:0 

This error is reproducible on XA master 5.1.99-222 / f4b67981 but not reproducible on XA master 5.1.99-207 / 52456eda. Maybe a mono bump between those builds is the cause of this behavior, but that is just my guess. This isn't device specific as it has happened on a Nexus 7 running 5.0.2 and a Asus ZenFone 5 running 4.3.

Logcat and errors : https://gist.github.com/BenBeckley/c492d0a727da8f049d74

Reproduction steps:
1) Install XA 5.1.99-222 or higher (confirmed up to build 232).
2) Run monodroid-sample AsyncImageAndroid on device
3) Tap the download button
4) Observe that the download does not start (no progress in progress bar)
5) Observe the System.Net.WebException
Comment 1 Naqeeb 2015-04-30 12:33:25 UTC
I have checked this issue with sample 'AsyncImageAndroid' on Samsung Note 3 and able to reproduce successfully. To reproduce this issue I have followed steps given in bug description.

I am also getting System.Net.WebException. Please refer same as screeencast: http://www.screencast.com/t/OUkybc2h6L4

I am not getting Exception with XA 

Ide log: https://gist.github.com/Shruti360/8645fc120ffc5d2b68d1
adb log: https://gist.github.com/Shruti360/fab0e3ee5012136a425f
Application Output: https://gist.github.com/Shruti360/e5685e515e189ed3e38b

Environment info:
=== Xamarin Studio ===

Version 6.0 (build 368)
Installation UUID: 2939b8b4-8977-42bd-82d6-100275ccd9cd
	Mono 4.0.0 ((detached/d136b79)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400000143

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.iOS ===

Version: (Enterprise Edition)
Hash: 6481535
Branch: master
Build date: 2015-04-27 04:38:13-0400

=== Xamarin.Android ===

Version: (Enterprise Edition)
Android SDK: /Users/360_macmini/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_75"
Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: (Enterprise Edition)

=== Build Information ===

Release ID: 600000368
Git revision: 3a9151da91dfe587a5590d148dfc607871055177
Build date: 2015-04-24 19:15:33-04
Xamarin addins: 131be56848a6c3d27007395633bb453d713fc079
Build lane: monodevelop-lion-mac-templates-update

=== Operating System ===

Mac OS X 10.9.4
Darwin 360-MACMINIs-Mac-mini-2.local 13.3.0 Darwin Kernel Version 13.3.0
    Tue Jun  3 21:27:35 PDT 2014
    root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
Comment 2 Jonathan Pryor 2015-07-14 17:20:13 UTC
Could this be due to Referencesource migration?
Comment 3 Marek Habersack 2015-07-20 15:47:42 UTC
The sample works fine with the current Xamarin.Android/master. Tried on the following devices:

 - Nexus 9 (Android 5.1.1)
 - Dell Venue 7 (Android 4.4.4)
 - Nexus 5 (Android M)

I'm going to close the report because of the above results, please reopen if you can still repro with the current master.