Slick Forums

Discuss the Slick 2D Library
It is currently Sun Jul 21, 2019 8:48 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Sat May 10, 2014 8:08 pm 
Offline

Joined: Mon Mar 28, 2011 9:42 pm
Posts: 19
I've been fiddling with Artemis vanilla for a while in a libgdx project. I've encountered the following problem when I spawn a new Entity during a process event.

The stack trace is
Code:
Thread [LWJGL Application] (Suspended)   
   Object.hashCode() line: not available [native method]   
   HashMap<K,V>.hash(Object) line: not available   
   HashMap<K,V>.getEntry(Object) line: not available   
   HashMap<K,V>.get(Object) line: not available   
   GroupManager.add(Entity, String) line: 49   
   EntityFactory.spawnInfected(int, int) line: 80   
   InfectedAISystem$1.handleSight(Entity, Entity) line: 50   
   InfectedAISystem$VisiblePair.checkForVisibility() line: 130   
   InfectedAISystem.processEntities(ImmutableBag<Entity>) line: 98   
   InfectedAISystem(EntitySystem).process() line: 57   
   World.process() line: 354   
   Play.update(float) line: 98   
   GameStateManager.update(float) line: 44   
   Game.render() line: 58   
   LwjglApplication.mainLoop() line: 206   
   LwjglApplication$1.run() line: 114   


The line which causes this code is `EntityFactory.worldReference.getManager(GroupManager.class).add(e, INFECTED);`.

WorldReference is already initialized. GroupManager is valid. I broke down the line a little further and found the lock seems to happen in the .add call.

As near as I can tell, the program is running indefinitely without doing a hard crash, as I've often seen before. It just runs forever without so much as the terminate program dialog popping up. When I figure out how to bind the source.jar to this project, I can dig deeper, but in the meanwhile I feel like the issue might have something to do with the modification happening during a process() event. Has anyone experienced this before?


Top
 Profile  
 
PostPosted: Sun May 11, 2014 2:11 pm 
Offline

Joined: Sun Jun 03, 2012 9:21 pm
Posts: 49
Are you by any chance running artemis in a multithreaded environment? It appears to be a thread issue, alternatively entity has a faulty hashcode implementation (only if you've extended Entity).

I seem to remember that there used to be some problem with GroupManager in the past, but I might be mistaken. Regardless, you shouldn't run vanilla artemis - it has too many bugs that were never fixed. There are several forks that fix all bugs present in vanilla. Gdx-artemis and mine (artemis-odb) fix these; there are other forks too, but I'm not sure to what degree they remedy the bugs.

_________________
agrotera: bytecode-weaving antiboilerplate lib for artemis. | artemis-odb: bugfixing and performance optimized fork.


Top
 Profile  
 
PostPosted: Sun May 11, 2014 5:04 pm 
Offline

Joined: Mon Mar 28, 2011 9:42 pm
Posts: 19
It looks like it is a threading issue. I can resolve it by pooling the group adds and entity spawns until the end of the world processing function. I have not overridden or extended entity.

I think I might have taken a look at your implementation a while back, but didn't use it since I wasn't sure how to use the Maven repository with gradle, but I'll pull a jar and try again. Should be a drop-in replacement, ja?


Top
 Profile  
 
PostPosted: Sun May 11, 2014 5:26 pm 
Offline

Joined: Sun Jun 03, 2012 9:21 pm
Posts: 49
Do you run multiple threads in your game? Artemis is single threaded, so when dealing with multiple threads you need to synchronize, or better compartmentalize, access to artemis - if that is the case.

Vanilla artemis was a little flaky when it came to creating entities during an ongoing process loop. Sounds like it might be what's causing it, though I don't remember seeing your particular problem. Worth a short anyway.

The Underkeep and Naturually Selected 2d both use gradle - they're linked from the readme too.
- https://github.com/DaanVanYperen/naturally-selected-2d
- https://github.com/DaanVanYperen/underkeep

Edit: artemis-odb should be fully API-compatible with vanilla (up until when/if artemis-odb 1.0.0 is released - but I'd rather avoid breaking compatibility).

_________________
agrotera: bytecode-weaving antiboilerplate lib for artemis. | artemis-odb: bugfixing and performance optimized fork.


Top
 Profile  
 
PostPosted: Mon May 12, 2014 3:53 am 
Offline

Joined: Mon Mar 28, 2011 9:42 pm
Posts: 19
Yeah, it looks like it was a threading issue.

For anyone who happens to be reading this thread in the future (or is searching for "artemis entity system gradle libgdx") or is looking for a way to add artemis-odb to the new libgdx with gradle, edit build.gradle and add the following to the project core dependencies:

Code:
        compile fileTree(dir: 'libs', include: '*.jar')
        compile group: 'net.onedaybeard.artemis', name: 'artemis-odb', version: '0.5.0'


EDIT: By the way, the fork made a fine drop-in replacement, junkdog. Thanks.


Top
 Profile  
 
PostPosted: Mon May 12, 2014 8:21 am 
Offline

Joined: Sun Jun 03, 2012 9:21 pm
Posts: 49
You don't need to grab it from maven repo directly; I'm not familiar with gradle but it looks like you've placed the artemis jars inside 'libs/'?

Version 0.6.0 is just around the corner btw; only thing remaining is writing some documentation - I don't expect any more commits before release. The snapshot url is: https://oss.sonatype.org/content/reposi ... -SNAPSHOT/

_________________
agrotera: bytecode-weaving antiboilerplate lib for artemis. | artemis-odb: bugfixing and performance optimized fork.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group