Skip to content

PROPERTY_BUFFER_ALLOCATOR_IMPLEMENTATION set by LwjglContext gets ignored sometimesΒ #1822

@Ali-RS

Description

@Ali-RS

Hi

LwjglContext (in jme3-lwjgl3 module) specifies its own implementation of buffer allocator to be used by BufferAllocatorFactory by setting PROPERTY_BUFFER_ALLOCATOR_IMPLEMENTATION property in this static code block:

static {
final String implementation = BufferAllocatorFactory.PROPERTY_BUFFER_ALLOCATOR_IMPLEMENTATION;
if (System.getProperty(implementation) == null) {
if (Boolean.parseBoolean(System.getProperty(PROPERTY_CONCURRENT_BUFFER_ALLOCATOR, "true"))) {
System.setProperty(implementation, ConcurrentLWJGLBufferAllocator.class.getName());
} else {
System.setProperty(implementation, LWJGLBufferAllocator.class.getName());
}
}
}

the issue is that sometimes this property gets ignored by BufferAllocatorFactory and a ReflectionAllocator is created instead. That is because BufferAllocatorFactory.create() method sometimes is called before the LwjglContext sets the new property. Inside the BufferUtils class:

private static final BufferAllocator allocator = BufferAllocatorFactory.create();

Sometimes the order of these static executions is different, e.g the one in the BufferUtils runs before the LwjglContext, which will cause BufferAllocator allocator to get initialized with Reflectionallocator and bypass the LWJGL3 allocator.

Edit:
2 possible fixes are suggested for this issue:

#1674 (comment)

and:

#1674 (comment)

Edit2:
Forum topic:
https://hub.jmonkeyengine.org/t/buffer-allocator-implementation-set-by-lwjglcontext-gets-ignored-sometimes/45594

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that is supposed to work, but doesn't. More severe than a "defect".

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions