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

Loading failed with "marshaling conversion 22 not implemented" #186

Open
blackdeng opened this issue Jul 31, 2024 · 1 comment
Open

Loading failed with "marshaling conversion 22 not implemented" #186

blackdeng opened this issue Jul 31, 2024 · 1 comment

Comments

@blackdeng
Copy link

blackdeng commented Jul 31, 2024

I'm integrating the Image3dAPI and the GE loader to a Unity project. Based on the TestViewer example, it looks like the Image3dAPI can be integrated as a managed plugin to Unity. I was able to retrieve information such as the bounding box, and frame count in my Unity C# code, but when I try to access the data using GetFrame, an exception was thrown "marshaling conversion 22 not implemented". Further stack trace attached below:

  at (wrapper managed-to-native) Image3dAPI.IImage3dSource.GetFrame(intptr,uint,Image3dAPI.Cart3dGeom,uint16[],Image3dAPI.Image3d&)
  at (wrapper cominterop) Image3dAPI.IImage3dSource.GetFrame(uint,Image3dAPI.Cart3dGeom,uint16[])
  at (wrapper cominterop-invoke) Image3dAPI.IImage3dSource.GetFrame(uint,Image3dAPI.Cart3dGeom,uint16[])

It seems the exception is because Unity C# uses Mono scripting backend which does not support SAFEARRAY in runtime. All APIs that return SAFEARRAY failed in Unity (returns null instead). Would it be possible to use a alternative type for arrays so that the library can be used in Unity?

@forderud
Copy link
Member

I'm sorry to hear about the limitation in Mono's scripting backend. I unfortunately don't think SAFEARRAY usage will be changed anytime soon, since v1 of the specification is already in commercial usage. We could consider changing it for future releases, but I fear it will lead to a more complex API. That's because it's valuable with a proper "array" object for managing image data. SAFEARRAY are also quite flexible, and facilitate both zero-copy in-process communication, copy-based out-of-process marshalling and zero-copy out-of-processing with shared memory. The latter is important for enabling security sandboxing without compromising on performance.

Have you attempted to contact Mono and suggest implementing SAFEARRAY support?

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