To ensure Xlib (and all libraries consuming it) is properly initialized in thread-safe mode, you must make sure that XInitThreads() is called before any other call (direct or indirect) to Xlib.
In Pale Moon, this call appears in toolkit/xre/nsAppRunner.cpp (around line 3242 in current PM version), where you can see:
Code: Select all
#ifdef MOZ_X11
// Init X11 in thread-safe mode. Must be called prior to the first call to XOpenDisplay
// (called inside gdk_display_open). This is a requirement for off main tread compositing.
// This is done only on X11 platforms if the environment variable MOZ_USE_OMTC is set so
// as to avoid overhead when omtc is not used.
//
// On nightly builds, we call this by default to enable OMTC for Electrolysis testing. On
// aurora, beta, and release builds, there is a small tpaint regression from enabling this
// call, so it sits behind an environment variable.
//
// An environment variable is used instead of a pref on X11 platforms because we start having
// access to prefs long after the first call to XOpenDisplay which is hard to change due to
// interdependencies in the initialization.
# ifndef NIGHTLY_BUILD
if (PR_GetEnv("MOZ_USE_OMTC") ||
PR_GetEnv("MOZ_OMTC_ENABLED"))
# endif
{
XInitThreads();
}
#endif
Obviously, if NIGHTLY_BUILD is undefined (or 0) and neither of MOZ_USE_OMTC or MOZ_OMTC_ENABLED environment variables are set, then XInitThreads() is *not* called.
I suggest systematically calling XInitThreads() instead (it won't hurt PM since Electrolysis is not used).
Note that some OpenGL drivers (e.g. NVIDIA's proprietary driver) will need Xlib to be initialized multi-threaded in order to be able to themselves use multi-threaded rendering.