-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Connectivity implementation not thread-safe on Windows, returning incorrect network status #9972
Comments
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Not quite a duplicate of but probably same underlying cause as #7393 |
using |
@MagicAndre1981 yes as I said in the workarounds if you consistently access from same thread it's not an issue, but it is not always possible/practical to do that, and it is thread safe on the other platforms. Also, in .Net Maui you need to use |
I've been working with a customer who is also seeing this issue. |
FYI that was the point I gave up Windows MAUI development. After many disappointments, this was the final one, breaking the app. |
ok, this will be fixed with #10062 and the fixed code also calls it on Main Thread |
Great stuff, thanks @jsuarezruiz and @BenBtg! |
@jsuarezruiz Does this also fix #7393? |
Why does Internet check have to run on UI thread anyways? |
I am super not sure about things. I am reverting the main thread "fix" as this is breaking other things: microsoft/WindowsAppSDK#2965 (comment) But I cannot repro the original issue anymore nor can I repro the issue in this microsoft/WindowsAppSDK#2965 (comment) I think this may have been a windows app sdk issue and they fixed it - or maybe even an OS issue. I had an issue with XXH1 and it was fixed in XXH2. (can't recall offhand anymore, but yeah... OS was dodgy) |
Description
On the WinUI platform, any calls to Connectivity.Current only work from the first thread to access the property. Subsequent calls from any other thread will cause a silent thread access exception:
![image](https://user-images.githubusercontent.com/6000851/188937048-03e10458-1176-4f4f-9ece-54077e616743.png)
That will end in a value of Unknown being returned:
![image](https://user-images.githubusercontent.com/6000851/188937277-c26dfd2b-fe02-4435-853b-bd0bc0798c43.png)
Doesn't matter which thread is first - main thread or background thread, it will always return correct value, and continue to return the correct value for that thread. But if you try to access it from a different thread, that is when this issue occurs.
Steps to Reproduce
I've linked to a sample repro below. Just run and click button 1 then button 2, or button 2 then button 1 to invert the outcome.
Main thread before bg thread:
![xJ9MaGocEK](https://user-images.githubusercontent.com/6000851/188937925-0000c476-eedd-4471-91c2-3ddc6d63c762.gif)
Bg thread before main thread:
![TSWdWFLxeB](https://user-images.githubusercontent.com/6000851/188937892-54d808b5-96e4-4d18-a904-42f54ecfc424.gif)
Link to public reproduction project repository
https://github.com/breenbob/MauiWindowsConnectivityIssue
Version with bug
6.0.400
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
10.0.17763.0
Did you find any workaround?
If checks are always done on the same thread you won't see the issue, but that's not a feasible long term solution.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: