openpnp / openpnp-capture

A cross platform video capture library with a focus on machine vision.
MIT License
118 stars 49 forks source link

Fix / Use CoInitializeEx(NULL, COINIT_APARTMENTTHREADED) #68

Closed markmaker closed 1 year ago

markmaker commented 1 year ago

Description

On Windows Java 17 uses COM to provide Desktop functionality. Because COM has an inherently bad design, every library inside one process must conform in its use of COM. See:

https://bugs.openjdk.org/browse/JDK-8270269

Hence, in openpnp-capture we must equally use

CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)

I do not know if this really helps. It could be that in turn Java 11 now breaks. I have still haven't found the time to find out how to locally deploy it into OpenPnP (this PR is what I can quickly offer).

Justification

See: https://github.com/openpnp/openpnp/pull/1560

Implementation Details

Tested with win/test/openpnp-capture-test.exe. Still works.