Hello,
I’m encountering an issue while developing with the Femto Mega and Orbbec SDK v2.4.8.
Problem Summary
My application crashes when it calls a function to get the device count after the Femto Mega is connected via POE for the first time since the program started. However, after this initial attempt (whether it crashes or succeeds), if I disconnect and reconnect the device within the same program session, it works perfectly from the second time onwards without any crashes.
Environment
- Device: Femto Mega
- Connection: POE (Standalone)
- Firmware: v1.2.8, v1.3.1 (Confirmed on both versions)
- SDK: OrbbecSDK v2.4.8
- OS: Windows 11
Problematic Code
The crash appears to happen when the scope of the following function is exited.
C++
static int getDeviceCount()
{
ob::Context ctx;
auto deviceList = ctx.queryDeviceList();
return deviceList->getCount();
}
My Analysis
I suspect the crash is caused by creating the ob::Context
instance (ctx
) as a local variable within the function. When the function returns, ctx
and deviceList
are destroyed. It seems this resource release process causes some kind of internal inconsistency, but only on the very first device connection.
Questions
- Is the correct approach to maintain a single, long-lived instance of
ob::Context
throughout the application’s lifetime (e.g., as a singleton or global variable), rather than creating and destroying it in a function each time? - If you have any information on similar issues or a solution to avoid this crash, please let me know.
Thank you for your help.