jmonkeyengine icon indicating copy to clipboard operation
jmonkeyengine copied to clipboard

Multithreading in AssetManager

Open ghost opened this issue 10 years ago • 5 comments

Multithreading is an important issue right now. Taking advantage of it in jME3 is critical. Some areas where multithreading can be used:

  • Skeleton animation, mesh skinning
  • Particle update
  • Physics
  • Networking
  • Input polling
  • OGG/Audio streaming
  • Resource loading
  • Terrain streaming

The details on how to implement these areas using multithreading will be specified later.


Some parts of jME3 are already multi-threaded:

Physics runs in a parallel thread. Networking runs in a parallel thread. Audio and OGG streaming is done on a parallel thread. Terrain streaming/LOD is done in a parallel thread.

jME3 is still missing asset loading on a separate thread, which can be critical if the application loads assets dynamically.


The AssetManager is the last part of jME3 that needs to take advantage of multithreading.

Reference on googlecode: https://code.google.com/p/jmonkeyengine/issues/detail?id=94

ghost avatar Mar 24 '14 19:03 ghost

Actually, the assetmanager is quite capble of being used in a background thread, however the uploading to the gpu is not currently.

empirephoenix avatar Sep 23 '15 12:09 empirephoenix

To upload to GPU you can use Application.enqueue() with a Callable that calls RenderManager.preloadScene().

Actually what I was thinking was something like

Future<T> loadAssetLater(AssetKey<T> assetKey)

which would let you load an asset on a separate thread. Perhaps you can set the executor via

void setExecutorService(ExecutorService executorService)

shadowislord avatar Sep 23 '15 14:09 shadowislord

Long time, what's the status of this ? I will work on it, please provide adequate information on what's need to be done if possible, there a multiple approaches this can be done.

pavly-gerges avatar May 31 '22 22:05 pavly-gerges

I believe JME's asset manager is sufficiently multithreaded. In my opinion, what's missing is documentation---in other words, a tutorial explaining how to load assets in the background.

stephengold avatar Jun 01 '22 16:06 stephengold

I believe JME's asset manager is sufficiently multithreaded. In my opinion, what's missing is documentation---in other words, a tutorial explaining how to load assets in the background.

Hmm, I guess this is not the case, jme lacks an async TaskManager in general, see #75, and by building a good async task manager we will be able to natively load our assets easily without the need of external means of java concurrency, I was willing to put some effort onto this and try implementing the feature if that is the case.

pavly-gerges avatar Jun 02 '22 05:06 pavly-gerges