Solved Crashing when use QBluetooth on Windows 10 with a BTLE adapter
-
i am using:
Windows 10, up to date. Using a BTLE adapter (no BTLE driver built in)
QT 5.12.
Paired my BTLE device with Windows adapter.i am trying to connect to the device many times 10 seconds each time. because i don't know when my device power on.
normally, i got:
[2019-01-22T10:47:19.209+07:00][debug ] 0xe9c BTLEQtInputDevice::onStateChanged QLowEnergyController::ConnectingState
[2019-01-22T10:47:27.010+07:00][debug ] 0xe9c BTLEQtInputDevice::onStateChanged QLowEnergyController::UnconnectedState
it works fine.but after few times, it crashed: after QLowEnergyController::ConnectingState. it is:
[2019-01-22T10:47:19.209+07:00][debug ] 0xe9c BTLEQtInputDevice::onStateChanged QLowEnergyController::ConnectingState
Second Chance Assertion Failed: File
minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp, Line 904
( a form rised: Expression: _CrtlsValidHeapPointer(block))it is more often when i run on Debug mode.
my questions are:
- What am i missing? how can i pass this issue?
- does QT support full work flow and cases of BTLE on windows? (BTLE driver built in and BTLE adapter 3rd party)
thanks. ^^!
-
@Pham-Hoang said in Crashing when use QBluetooth on Windows 10 with a BTLE adapter:
my questions are:
- What am i missing? how can i pass this issue?
Try with Qt 5.11.3, it seems more stable.
Both Qt and Windows have serious bugs in Bluetooth support (even leading to system crashing). My recommendations are:
- put your bluetooth code in a plugin (or even better - in a separate process) and load it dynamically
- if QtBluetooth crashes - reload the plugin
- do not constantly scan for devices in the background - due to a memory leak in Windows it leads to runaway RAM consumption and crashes the whole system. Only do a manual scan when necessary (when user requests it)
- do not go below Qt 5.11.3 - it includes a fix for a crash in Qt's bluetooth module
- does QT support full work flow and cases of BTLE on windows? (BTLE driver built in and BTLE adapter 3rd party)
thanks. ^^!
Yep, it all works, although with many caveats and quirks.
-
@Pham-Hoang additionally to what @sierdzio said, make sure your windows is up to date with all updates.
That makes a huge difference!
-
@Pham-Hoang , you can try to use the win32-based plugin (not UWP plugin) from the wip/win branch of qtconnectivity module. Maybe it will be more stable. For this, you need to compile the qtconnectivity module yourself.
-
@Pham-Hoang said in Crashing when use QBluetooth on Windows 10 with a BTLE adapter:
es QT support full work flow and cases of BTLE on windows? (BTLE driver built in and BTLE adapter 3rd party)
thank you all. your information are very useful for me to dev on my project.
-
@sierdzio said in Crashing when use QBluetooth on Windows 10 with a BTLE adapter:
do not constantly scan for devices in the background - due to a memory leak in Windows it leads to runaway RAM consumption and crashes the whole system.
Is it possible to provide more details about this memory leak? Do you know if it has been fixed in recent builds of Windows?
-
@JKSH said in Crashing when use QBluetooth on Windows 10 with a BTLE adapter:
@sierdzio said in Crashing when use QBluetooth on Windows 10 with a BTLE adapter:
do not constantly scan for devices in the background - due to a memory leak in Windows it leads to runaway RAM consumption and crashes the whole system.
Is it possible to provide more details about this memory leak? Do you know if it has been fixed in recent builds of Windows?
I certainly hope it has been fixed, it's been at least 3-4 years since I run into it.
If I recall well, we were scanning devices with a timer every few seconds. Windows was not cleaning up correctly between scans or something. At first, RAM was only raising slowly, but after some 10-30 minutes it was beginning to snowball rapidly, taking all memory, crashing GPU drivers etc.
-
@sierdzio said in Crashing when use QBluetooth on Windows 10 with a BTLE adapter:
I certainly hope it has been fixed, it's been at least 3-4 years since I run into it.
If I recall well, we were scanning devices with a timer every few seconds. Windows was not cleaning up correctly between scans or something. At first, RAM was only raising slowly, but after some 10-30 minutes it was beginning to snowball rapidly, taking all memory, crashing GPU drivers etc.
Looks like the issue still exists, unfortunately: https://bugreports.qt.io/browse/QTBUG-105742