Hello.
I'm working on a 3d-render subsystem of a larger Embedded project, and I'm using LWJGL for that.
One of the problems that I ran into was that I need to somehow combine my work with Swing. Because the rest of the app is written heavily relying on it.
I solved that problem by having an AWT Canvas and rendering directly to it, by obtaining the XCB drawing surface and rendering directly to it.
And it seemed to have solved the problem. It works on my PC, and it also works on the embedded device that we're targeting.
However when we tried to merge my branch into the main project, an issue accourred. on some machines, for some reason XCB and XLib start crashing randomly and the app is unworkable.
All problems seem to be pointing to XCB and Multithreading. The error message itself suggests to use XInitThreads, but I couldn't find how to use it from LWJGL....
[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting...
What do I do? Is there any alternative?
Here's how I'm handling multithreading in my app:
public void lock() throws AWTException {
int lock = JAWT_DrawingSurface_Lock(ds, ds.Lock());
if ((lock & JAWT_LOCK_ERROR) != 0)
throw new AWTException("JAWT_DrawingSurface_Lock() failed");
}
public void unlock() throws AWTException {
JAWT_DrawingSurface_Unlock(ds, ds.Unlock());
}
I'm calling Lock() before doing anything at all with the drawing surface and Unlock() right after. But I also suspect that Swing could do something to it or to the Canvas without me handling it - and I don't really know what can be done about it...