jMonkeyEngine / jMonkeyEngine/jmonkeyengine

PROPERTY_BUFFER_ALLOCATOR_IMPLEMENTATION set by LwjglContext gets ignored sometimes

Open
#1,822 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
4.3k
Forks
1.2k
Avg merge
4d 7h
Merged PRs (30d)
14

Description

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:

https://github.com/jMonkeyEngine/jmonkeyengine/blob/8af0c92991eab9c2027dfd94be09f2170beea630/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglContext.java#L91-L102

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:

https://github.com/jMonkeyEngine/jmonkeyengine/blob/8af0c92991eab9c2027dfd94be09f2170beea630/jme3-core/src/main/java/com/jme3/util/BufferUtils.java#L65

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:

https://github.com/jMonkeyEngine/jmonkeyengine/issues/1674#issuecomment-1086843067

and:

https://github.com/jMonkeyEngine/jmonkeyengine/issues/1674#issuecomment-1129832078

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the static initialization in jme3-core/src/main/java/com/jme3/util/BufferUtils.java and BufferAllocatorFactory.create(), then compare it with the property setup in jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglContext.java. Investigate the two proposed fixes linked from issue #1674 and verify that the LWJGL3 allocator is selected regardless of static initialization order.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.