Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
Created attachment 11326 [details]
Calling HttpClient.GetStreamAsync blocks the UI thread on Android.
**Steps to Reproduce:**
1. Run the attached sample on an Android simulator (tested on API 19)
2. Press the button
Notice the progress bar spinner does not animate (UI thread is blocked)
The progress bar should be able to animate while the work is being done.
**Build Date & Platform:**
Similar code on iOS works as expected.
awaiting something else instead of GetStreamAsync, like Task.Delay(2000) will show the expected results.
I have checked this issue and able to reproduce the above behavior with the help of sample and steps given in the bug description.Progress bar spinner does not animate but but project is still in progress shows in application output.
Ide Logs: https://gist.github.com/anonymous/35d7095847430566becc
Build Output: https://gist.github.com/anonymous/3749131b41099719b666
Application Output: https://gist.github.com/anonymous/f5f6a0f90d26f4b5ad1d
adb Logcat: https://gist.github.com/anonymous/f976407fcedf6cf6647b
=== Xamarin Studio ===
Version 5.9.2 (build 2)
Installation UUID: 0b7eaebc-a0ed-4b58-81df-91e378cad28c
Mono 4.0.1 ((detached/11b5830)
GTK+ 2.24.23 (Raleigh theme)
Package version: 400010043
=== Apple Developer Tools ===
Xcode 6.3.2 (7718)
=== Xamarin.iOS ===
Version: 22.214.171.124 (Enterprise Edition)
Build date: 2015-05-21 12:10:06-0400
=== Xamarin.Android ===
Version: 126.96.36.199 (Enterprise Edition)
Android SDK: /Users/Admin_Mac/Desktop/Anddk/android-sdk-macosx
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_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
=== Xamarin Android Player ===
Version: Unknown version
Location: /Applications/Xamarin Android Player.app
=== Xamarin.Mac ===
Version: 188.8.131.522 (Enterprise Edition)
=== Build Information ===
Release ID: 509020002
Git revision: 43735a4b905b571f69cf9428a3ea7b52aef55476
Build date: 2015-05-18 09:38:12-04
Xamarin addins: ab18ddff45f507ed74f36c2b65df9aee22e28a56
=== Operating System ===
Mac OS X 10.10.2
Darwin Admin-Macs-Mac-mini.local 14.1.0 Darwin Kernel Version 14.1.0
Thu Nov 13 18:36:56 PST 2014
The code in the provided sample behaves the way it should. The call that blocks is actually
which is correct since that call is synchronous. HttpClient.GetStreamAsync () is supposed to make the connection to the server and return a network stream as soon as it receives response from the server. This tends to happen pretty quickly, so await takes little time. Reading of the data actually happens below await, in reader.ReadToEnd () which is a blocking operation - this is why the UI thread blocks.
*Note: what's written below is just a guess*
The reason it works on Xamarin.iOS might be the underlying implementation of networking code used by HttpClient. On iOS it uses native network framework which *might* read the data before GetStreamAsync () returns and so when reader.ReadToEnd () is called it's just a quick local read instead of the actual network access.
So the issue might be a quirk/bug in Xamarin.iOS, or just a platform-specific behavior. In either case, the code as presented in the attached test case should be expected to block the UI thread.