-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Windows 11 WinRT initialization failure #31
Comments
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Considering it has been 6 months since this issue was last updated and new exception handling will be part of v0.5.0. I think we can close this issue. Feel free to open a new one if problems arise. |
Actually it still doesnt work for me and I have no ideas how to investigate it further. And I am still not sure if its only for my laptop or not |
So far I haven't been able to replicate it and no other reports have come in about this. I suspect there might be some weird deadlock or concurrency issue that could be affecting, but there are plenty of additional checks right now to prevent this stuff from happening. Are you using the current commit at the tip of |
Using the latest commit instead deadlock and winrt exception I see that it fails to connect and its definitely better. But I reproduce it 100% times and in exactly the same place and only when I call it from python. It works for all other languages. |
I think nobody else reported it probably because more likely not many people tried to call it from python like this and using win11.. |
btw it connects using python_simpleble and connect.py example |
Can you link again the latest version of the code where this is happening? I think we have some multi-threading problems happening. |
This comment was marked as outdated.
This comment was marked as outdated.
simpleble_peripheral_connect fails with timeout in _attempt_connect and async_get |
Can you print the output that you get from |
Also, in |
@kdewald thanks for the hint. WINRT_IMPL_CoGetApartmentType(&cotype, &qualifier);
+ std::cerr << "cotype is " << cotype << "qualifier " << qualifier << std::endl;
+
if (cotype == -1 /* APTTYPE_CURRENT */) {
// TODO: Investigate if multi or single threaded initialization is needed.
winrt::apartment_type const type = winrt::apartment_type::multi_threaded;
winrt::hresult const result = WINRT_IMPL_CoInitializeEx(nullptr, static_cast<uint32_t>(type));
+ std::cerr << (long)result << std::endl;
} And: return async.GetResults();
} catch (const winrt::hresult_error& err) {
+ std::cerr << (long)err.code().value << " " << winrt::to_string(err.message()) << std::endl;
throw SimpleBLE::Exception::WinRTException(err.code().value, winrt::to_string(err.message()));
} catch (const std::exception& err) {
+ std::cerr << err.what() << std::endl; The output is:
So, WINRT_IMPL_CoInitializeEx is not even called |
for other languages cotype is -1 and its executed. But I have not checked other languages with GIL... |
I've tried to force call it wo if check for single threaded and multiple threaded and it didnt work either |
I think you need to call that function from within your library in the main thread. I'll keep looking to see if anything else comes up. |
Also, what Python version are you using? That could also be related. |
its in the main thread. Since simpleble creates its own threads for callbacks,etc I dont need to create any other threads manually |
wow, it works if I use 3.10.5! Thanks a lot I was struggling with it for months! |
Hey all, seems I'm running into the same issue now with my InsideBlue tool, which use my Pascal bindings. Got a new laptop running Windows 11 and I can no longer connect to any BLE device from InsideBlue. Scanning works as usual but connecting attempt takes long and finally fails everytime. I recompiled the SimpleBLE DLLs with the latest pull from github on Windows 11, but no change. Since the issue has been close quite a while back, what did fix the issue with Python? Any other clues? |
After updating from Windows 10 to Windows 11 in Python I get a deadlock(never ends, 0% CPU usage). Its weird that I cannot reproduce it in C++
Connected with a debugger to python and got that call stack:
In
_attempt_connect
method atGetGattServicesAsync
async_get
never ends due to some reason.Not a solution for this particular issue but maybe it makes sense to add an option to configure the timeout for waiting? Non-zero exit code or exception is definitely better than deadlock
The text was updated successfully, but these errors were encountered: