Skip to content
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

OrbbecSDKConfig_v1.0.xml is not found when the solution is a DLL #53

Open
diablodale opened this issue Mar 9, 2024 · 8 comments
Open

Comments

@diablodale
Copy link

diablodale commented Mar 9, 2024

Wrapper v1.9.1 does not find OrbbecSDKConfig_v1.0.xml when the compiled solution is a DLL.
The Orbbec codebase only looks for OrbbecSDKConfig_v1.0.xml in the directory of the application EXE.

My solution is a DLL. Meaning, I compile the wrapper and my code into a DLL. Not an EXE.
My solution is a plugin for a 3rd party application called Cycling74 Max. Therefore, the application is Max.EXE
3rd party EXEs are in a different locations than user plugin DLLs, OrbbecSDK.dll, or your wrapper k4a.dll.

Setup

  • Windows 10 or 11
  • VS community 2022 v17.9.2
  • Orbbec wrapper v1.9.1
  • Connect a Femto Mega to the same ethernet network (not USB)

Repro

The primary scenario is a Windows app EXE that dynamically loads a plugin DLL. This bug may occur in other DLL scenarios, however, these repro steps focus only on the primary scenario.

  1. Write an app EXE that has the capability to dynamically load any plugin needed. These plugins are not loaded when the EXE starts. They are loaded on-demand later when the user interacts with the app EXE. This is the normal scenario of a app that has plugins like 3d rendering, patching environments, etc. This app EXE does not use or call k4a or Orbbec APIs. This app EXE does not load any Orbbec DLLs.
  2. Write a plugin DLL that calls the k4a Orbbec wrapper APIs v1.9.1. The Orbbec wrapper DLL must not be immediately loaded by the plugin DLL. Instead, the Orbbec wrapper DLL must be delay-loaded using the Windows delay-load infrastructure. This is well known and supported https://learn.microsoft.com/en-us/cpp/build/reference/linker-support-for-delay-loaded-dlls?view=msvc-170.
  3. Install the app EXE into a protected read-only location like C:\Program Files
  4. Install the plugin DLL into a read-write user location like C:\Users\myusername\Documents
  5. Install the Orbbec wrapper DLL and Orbbec SDK DLL into the same read-write user location of step 4
  6. Customize a OrbbecSDKConfig_v1.0.xml. Change the value of EnumerateNetDevice from false to true.
  7. Save OrbbecSDKConfig_v1.0.xml into the same read-write user location of step 4
  8. Run the app EXE
  9. Verify that the plugin DLL was not loaded.
  10. Verify that both Orbbec DLLs were not loaded.
  11. Interact with the app EXE to cause the plugin DLL to be loaded

Result

The Femto Mega is not found.

Expected

Femto Mega is found because OrbbecSDKConfig_v1.0.xml was found and loaded

Notes

The bug is that Orbbec code does not load/search for OrbbecSDKConfig_v1.0.xml in the same directory as the Orbbec DLLs.
I used procmon and watched your code probe in the following locations. None of these are directories for my solution plugin DLL, OrbbecSDK.dll, or your wrapper k4a.dll. Therefore, your OrbbecSDK.dll and wrapper k4a.dll did not find OrbbecSDKConfig_v1.0.xml which causes no settings to be loaded and the Femto Mega not found.

C:\Program Files\Cycling '74\Max 7\OrbbecSDKConfig_v1.0.xml
C:\Program Files\Cycling '74\Max 7\Data\OrbbecSDKConfig_v1.0.xml
C:\Program Files\Cycling '74\Max 7\data\OrbbecSDKConfig_v1.0.xml
C:\Program Files\Cycling '74\Max 7\config\OrbbecSDKConfig_v1.0.xml
C:\Program Files\Cycling '74\Max 7\Config\OrbbecSDKConfig_v1.0.xml
C:\Program Files\Cycling '74\OrbbecSDKConfig_v1.0.xml
C:\Program Files\Cycling '74\Data\OrbbecSDKConfig_v1.0.xml
C:\Program Files\Cycling '74\data\OrbbecSDKConfig_v1.0.xml
C:\Program Files\Cycling '74\config\OrbbecSDKConfig_v1.0.xml
C:\Program Files\Cycling '74\Config\OrbbecSDKConfig_v1.0.xml
C:\Program Files\Cycling '74\Max 7\sdcard\Orbbec\OrbbecSDKConfig_v1.0.xml

My customer also reproduced this bug on their computer. They confirmed that it is required to move the OrbbecSDKConfig_v1.0.xml into the same folder as the app EXE. This confirms my above analysis.

My customer said they had to also make the app EXE directory read-write. You might want to check your code again and confirm that you are not accidentially requesting read-write permissions when opening your XML file.

@zhonghong322
Copy link

Firstly, did you download the XML configuration file from here (https://github.com/orbbec/OrbbecSDK/blob/main/misc/config/OrbbecSDKConfig_v1.0.xml) to ensure that the configuration file is correct?

Is the XML configuration file located in the same directory as the OrbbecSDK.dll?

@zhonghong322
Copy link

787119745dc6ca001959abf289314525

@diablodale
Copy link
Author

diablodale commented Mar 12, 2024

Unfortunately, you did not read my original post above. Please read it again in detail. And also do the repro steps. You clearly did not do those steps.

because you did not do these things, you are asking irrelevant questions. Your code is not loading the XML file in the same directory as your DLLs. I clearly wrote that above. And I provided proof of the locations in which you DO attempt to load the file. None of which are in the location you suggest.

@diablodale
Copy link
Author

I updated the OP with additional details in the reproduction steps. I also included further confirmation of this bug when my customer tested it on their computer.

@diablodale
Copy link
Author

While you are working on a fix for loading the XML file correctly, what workarounds are available to enumerate network devices?

Your api docs write ob_enable_net_device_enumeration() can be called with an ob_context before ob_query_device_list(). I can see in your implementation https://github.com/orbbec/OrbbecSDK-K4A-Wrapper/blob/main/src/orbbec/ob_k4a_impl.cpp several calls to ob_query_device_list(). You hide the ob_context inside a ob_context_handler as in this example https://github.com/orbbec/OrbbecSDK-K4A-Wrapper/blob/main/src/orbbec/ob_k4a_impl.cpp#L228

I could hardcode ob_enable_net_device_enumeration() into the API when your code creates the context. But a better approach would be a wrapper API or parameter call that can enable net device enumberation.

@diablodale
Copy link
Author

Checking back with you on this bug. A customer has paid for me to purchase two of your Femto sensors, I just ordered today. Are fixes or workarounds for this issue on your project list?

@diablodale
Copy link
Author

While you are working on a fix for loading the XML file correctly, what workarounds are available to enumerate network devices?

Your api docs write ob_enable_net_device_enumeration() can be called with an ob_context before ob_query_device_list(). I can see in your implementation https://github.com/orbbec/OrbbecSDK-K4A-Wrapper/blob/main/src/orbbec/ob_k4a_impl.cpp several calls to ob_query_device_list(). You hide the ob_context inside a ob_context_handler as in this example https://github.com/orbbec/OrbbecSDK-K4A-Wrapper/blob/main/src/orbbec/ob_k4a_impl.cpp#L228

I could hardcode ob_enable_net_device_enumeration() into the API when your code creates the context. But a better approach would be a wrapper API or parameter call that can enable net device enumberation.

@zhonghong322
Copy link

Due to the K4a wrapper, our initial design philosophy was to avoid changing the AKDK interface as much as possible. For your issue, need to add an interface to loader the xml config file or add a interface to enable the network. In future versions, we will consider adding this interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants