-
Notifications
You must be signed in to change notification settings - Fork 520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove workaround for ThreadPool not working #7080
Comments
I undid the band-aid and built against mono-2019-06, using the sample provided by #5333. After ~15-20 different tries, I couldn't reproduce the problem. Each time after 10+ seconds, the threadpool threads would kick back up and resume normal execution (Http requests too). Has anyone else been able to reproduce? If so, what device(s), versions, etc? |
@steveisok did you put your app into background mode on the device?
@migueldeicaza could you be more specific on this^ ? |
@marek-safar Yeah, I'd swipe up and wait at least 10 seconds (often longer). In addition, I opened other apps, did something, and then went back. |
Yes, this means that the NSUrlSession which is an API that can perform downloads in the background, even if the application is stopped does not work. So the hack cancels the downloads. @steveisok perhaps the heuristics for the OS have changed, and the app is not backgrounded, might be worth checking. @mandel-macaque can provide more details on the side effects. |
There's a similar issue on Android on at least one device (after a while, a background service can't schedule new Tasks to run). I've been looking at this piece of code: This The android device where I saw this has |
To followup on my theory that and also added some logging to note whether we ever call it when
So on the particular Android device that I'm watching, it certainly seems like we get into a situation where the native threadpool machinery was flooded with requests (count >= processorCount) but it s workers didn't unpark or start up to process them, and so I'm planning to look into a couple of things:
But maybe we should check in something like:
And just see what happens? |
Just a brief update. My previous comment is not the direction we ended up taking for the possibly-related Android issue. The fix we ultimately ended up going with is mono/mono#17927. Once backports of that PR are available for xamarin.ios, we could investigate removing the workaround in XI. Although, given that we haven't been able to reproduce the issue recently, we will first need to identify a way to induce the bad threadpool behavior on an ios device. |
@lambdageek - Git suggests that mono 2020-02 has this (via b6a351c3308). Could we look at removing the work around now? |
@chamons the PR also landed in 2019-10 and 2019-12 so you should be able to already try it on your stable bits. |
…andler for thethreadpool. When an application was moved the the background, the thread pool from mono would be left in an unknonw state, making applications to stale (https://xamarin.github.io/bugzilla-archives/58/58633/bug.html#c7). This work was added in dotnet#5463 We now set the default behaviour to skip the workaround to see if the new provided mono works as expected. We do not fully remove the workaround because we need some real world testing. If the new ThreadPool from mono does not work as expected we do provide a property to re-add the workaround. The BypassBackgroundSessionCheck can be set to false to allow users get it back. The following is an example usage of the API: ```csharp // create your own handler instance rather than using the one provided by default. var handler = new NSUrlSessionHandler() { BypassBackgroundSessionCheck = false, // readd the hack }; var httpClient = new HttpClient (handler); // use the handler with the hack ``` This is a partial fix for dotnet#7080
The Xamarin iOS and Mac team would like some customer testing with the this fix. Here are the instructions:
We'd like to change the default in future versions (#8296) and hearing from some customers would be very helpful. |
…andler for thethreadpool. (#8296) When an application was moved the the background, the thread pool from mono would be left in an unknonw state, making applications to stale (https://xamarin.github.io/bugzilla-archives/58/58633/bug.html#c7). This work was added in #5463 We now set the default behaviour to skip the workaround to see if the new provided mono works as expected. We do not fully remove the workaround because we need some real world testing. If the new ThreadPool from mono does not work as expected we do provide a property to re-add the workaround. The BypassBackgroundSessionCheck can be set to false to allow users get it back. The following is an example usage of the API: ```csharp // create your own handler instance rather than using the one provided by default. var handler = new NSUrlSessionHandler() { BypassBackgroundSessionCheck = false, // readd the hack }; var httpClient = new HttpClient (handler); // use the handler with the hack ``` This is a partial fix for #7080
Looks like we can remove the workaround, since we haven't gotten any feedback after turning it off by default. Scheduling it for .NET 8. |
…otnet#7080. Completely remove a workaround for an issue with the thread pool in Mono. We've previously turned this workaround off by default, and we got no reports of any problems. Fixes dotnet#7080.
Xamarin on iOS currently has a workaround for the Mono Thread Pool not working:
#5463
That workaround is necessary because the Mono's ThreadPool stops working after the app is suspended for 10 seconds:
https://xamarin.github.io/bugzilla-archives/58/58633/bug.html#c7
The workaround effectively kills all background support from Xamarin.iOS.
There is a repro that shows this problem in action (but might require disabling the incorrect bandaid that was put in place):
#5333
The text was updated successfully, but these errors were encountered: