Hate these types of exceptions. It happens when I spam input into my chatbox - im not entirely sure why it happens however. Would it be useful for me to post the xml and chat controller?
This is the exception:
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
at java.util.AbstractList$Itr.next(AbstractList.java:343)
at de.lessvoid.nifty.elements.Element.renderInternalChildElements(Element.java:471)
at de.lessvoid.nifty.elements.Element.renderChildren(Element.java:466)
at de.lessvoid.nifty.elements.Element.render(Element.java:434)
at de.lessvoid.nifty.elements.Element.renderInternalChildElements(Element.java:472)
at de.lessvoid.nifty.elements.Element.renderChildren(Element.java:463)
at de.lessvoid.nifty.elements.Element.render(Element.java:443)
at de.lessvoid.nifty.elements.Element.renderInternalChildElements(Element.java:472)
at de.lessvoid.nifty.elements.Element.renderChildren(Element.java:466)
at de.lessvoid.nifty.elements.Element.render(Element.java:434)
at de.lessvoid.nifty.elements.Element.renderInternalChildElements(Element.java:472)
at de.lessvoid.nifty.elements.Element.renderChildren(Element.java:466)
at de.lessvoid.nifty.elements.Element.render(Element.java:434)
at de.lessvoid.nifty.elements.Element.renderInternalChildElements(Element.java:472)
at de.lessvoid.nifty.elements.Element.renderChildren(Element.java:466)
at de.lessvoid.nifty.elements.Element.render(Element.java:434)
at de.lessvoid.nifty.elements.Element.renderInternalChildElements(Element.java:472)
at de.lessvoid.nifty.elements.Element.renderChildren(Element.java:466)
at de.lessvoid.nifty.elements.Element.render(Element.java:434)
at de.lessvoid.nifty.elements.Element.renderInternalChildElements(Element.java:472)
at de.lessvoid.nifty.elements.Element.renderChildren(Element.java:466)
at de.lessvoid.nifty.elements.Element.render(Element.java:434)
at de.lessvoid.nifty.elements.Element.renderInternalChildElements(Element.java:472)
at de.lessvoid.nifty.elements.Element.renderChildren(Element.java:466)
at de.lessvoid.nifty.elements.Element.render(Element.java:434)
at de.lessvoid.nifty.elements.Element.renderInternalChildElements(Element.java:472)
at de.lessvoid.nifty.elements.Element.renderChildren(Element.java:466)
at de.lessvoid.nifty.elements.Element.render(Element.java:434)
at de.lessvoid.nifty.elements.Element.renderInternalChildElements(Element.java:472)
at de.lessvoid.nifty.elements.Element.renderChildren(Element.java:466)
at de.lessvoid.nifty.elements.Element.render(Element.java:443)
at de.lessvoid.nifty.elements.Element.renderInternalChildElements(Element.java:472)
at de.lessvoid.nifty.elements.Element.renderChildren(Element.java:466)
at de.lessvoid.nifty.elements.Element.render(Element.java:434)
at de.lessvoid.nifty.elements.Element.renderInternalChildElements(Element.java:472)
at de.lessvoid.nifty.elements.Element.renderChildren(Element.java:466)
at de.lessvoid.nifty.elements.Element.render(Element.java:434)
at de.lessvoid.nifty.elements.Element.renderInternalChildElements(Element.java:472)
at de.lessvoid.nifty.elements.Element.renderChildren(Element.java:466)
at de.lessvoid.nifty.elements.Element.render(Element.java:434)
at de.lessvoid.nifty.screen.Screen.renderLayers(Screen.java:256)
at de.lessvoid.nifty.Nifty.render(Nifty.java:167)
at com.jme3.niftygui.NiftyJmeDisplay.postQueue(NiftyJmeDisplay.java:99)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:542)
at com.jme3.renderer.RenderManager.render(RenderManager.java:563)
at org.whiterush.main.WhiteRushBase.update(WhiteRushBase.java:322)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:112)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:162)
at java.lang.Thread.run(Thread.java:619)
As far as im aware im not doing anything I shouldnt - so it may simply be a problem within the library! Let me know if you need the extra detail.
I also had a ConcurrentModificationException with Nifty before, but only once and I couldn't reproduce it, so I'm not sure what else was using the ArrayList in my case.
Can you reproduce this error, does it happen every time you do something certain?
Your xml-file could probably help to shed some light on this yes, though these kinds of errors can be hard to trace.
I've made a patch to fix the problem you had before with the scroll panel and have made an example of how to make a chat panel work automatically, so when that's out (and this error is reproducable) you could compare them and perhaps see where the difference lies. It should be out when word wrapping is fixed as my solution freezes otherwise when you type in certain lengths of words. In the meanwhile, make sure you're using the latest svn version and try to reproduce the bug in an as limited setting as possible.
Well i just fire stuff into an scrollpanel as fast as possible! Your fix for a chat panel excites me greatly! Baring in mind im using the jME3 distribution within jme3, can you tell me when it will be ready for a shot?
This exception occurs when you change a list you are at the moment using.
e.g. for (Screen s : allScreens) {}
If you now add something or remove from allScreens that exceptions is thrown. So you are adding or removing
something of the nifty screens while that is used. Somewhere in the forum we discussed that problem already(don't know if there was a real sollution). You have to postpone that actions until nifty is done-updating. I'm not sure about the jme3 internals but there is something like a queue that can be filled with callables/futures and that is executed in a safe state.
Or take a look at java's new concorrent structured. I know there is a ConcurrentHashmap, there may also be something for the arraylist you are using. These things make sure things like this don't happen.
In my PluginFramework for Java I personally use a java.util.concurrent.ArrayBlockingQueue I think this might works in your case as well.
You use it like this:
final boolean result = clientMessages.get(message.getClientId()).offer(message);
final Message message = clientMessages.get(clientId).remove();
I use this in my network layer as well, since I have seperate write, read and accept threads.
Actually, I think it's a list in the Nifty library so the OP can't change that if that's the case.
It could of course be an error like the one ttrocha is describing.
If Nifty is single-threaded throughout this problem couldn't really happen within the library so it'd have to be something in a separate thread from somewhere else trying to modify the list.
Perhaps Nifty could implement a safe queue to avoid these kinds of issues?
renegadeandy said:
Well i just fire stuff into an scrollpanel as fast as possible! Your fix for a chat panel excites me greatly! Baring in mind im using the jME3 distribution within jme3, can you tell me when it will be ready for a shot?
Well, Nifty 1.2 just came out, so void deserves a break for a while, but when he's rested a refreshed I'm sure it won't take long before he's gone through my proposed fixes and if we get the word wrapping fixed then, I'll make sure the code is working as it should and release it along with a test to show how it works.
Then someone who works on the JME3 code will have to update the Nifty code they use from svn to make it work for you.
I don't think it'll be very long a wait. :)
The wrapping has been fixed and the fix committed and the chat panel is working perfectly with my latest version of Nifty.
However, there's one change still missing in the Nifty repositories.
The event system for elements is being revamped and the required change to ScrollPanel to make this chat panel work has not been committed yet awaiting decisions on how to implement the new system.
I'm on vacation this week and so is void as it happens, so don't get your hopes up on anything happening this week, sorry.
When we both get back we'll get back to working on the event system and this will be implemented too, or if one of the other developers work on it meanwhile, but they're very busy too. There are many exciting things coming to Nifty soon!
I read your implementation of the chat panel on the forum on sourceforge. At least, I think I did, lol
I personally am going a slightly different approach, I want to be able to have both an image (player icon) and the actual text on a line in the chat. I'm guessing this won't be possible with your setup and I would need to create my own still?
No problems there, I was already working on my own chat control so no real harm done.
My implementation of the chat panel consists only of a control with a scroll panel around a label and with a controller making it feel more like a control. The big new thing is that the scroll panel will listen to changes in the label and adjust it's size automatically and also scroll in the direction you specify automatically.
These changes to the scroll panel have not been committed yet, awaiting a reworked events system.
If you want to have images in front of each line in the panel you'd have to make some changes in my implementation or make your own, as that is a pretty specific feature.
Yeah, I know. That's what I was doing. My current approach is to have each line as a panel with an image and a text. The text element does the whole word wrapping right?
Having it this way, makes the scroll automaticaly work right so no worries there. It's just the code to get the whole Chat line added each time I have to add a new line that's giving me some headaches atm. but nothing I can't fix.
Oh, I also completed my MessageBox control if you're interested. When I finish this chat control I'll send you the code for it as well. See if you can find any improvements and maybe if it will be usefull for others as well.
I finsihed my chat control so far that it is possible to type message which wil appear in the chat scrollpanel.
I setup my scrollpanel to contain a panel. To this panel I then add chat-lines. A chat-line is another control consisting of an image and a label. That all works well enough. The only problem at this time is that, when I add enough chat-lines to run out of scrollpanel, it doesn't scroll…
Could this be a problem with the scroll panel, or do I also need to resize the panel within the scrollpanel containing the chat-lines?
Yes, this is the fix I have waiting to be committed.
You still have to resize the panel inside the scrollpanel yourself when you add something, but the problem is that the current scrollpanel doesn't know that the panel has changed size and so you can't see the new part of the panel.
Also there is no autoscroll in the current implementation.
These two things are fixed in the coming patch and you'll be able to set the scrollpanel to autoscroll up/down/left/right/up+left/up+right/down+left/down+right/not at all.
It's all finished and I will commit it as soon at the new event system for elements in done and committed as this will require a minor change in the scrollpanel code.
Hopefully I'll have a little time to work on that in the coming days and void is also working on the overall event system, so I think it won't be long now!
Great, then I'll just have to wait a little while longer…
Ah well, this gives me time to incorporate SpiderMonkey into the login screen and to start work on the server.
I also still need to add a second scrollpanel to show all the people in the chatroom and to figure out a way to display multiple chat room and create some sort of context menu for the people in the chatroom so you can start a private convo etc. But that shouldn't be too hard I think.
We decided to implement the common Observer pattern anyway for now, since the new event system was more complex than I thought at first, so the chat area control should now work!
Ok, I did a quick cheout of the nifty svn for Nifty and the default controls. Added the new scroll opanel and ran into a few missing methods. Perhaps not all your related classes were comitted correctly?
I'm currently not at my home comp, but I'll look into which classes / methods were missing tonight and I'll let you know.
I added them manually but I feel I'm missing something (or it could just be my controller class that's not completely correct yet since I haven't changed that one because the scrolling works slightly weird. But that was just a small test way late last night so sleep deprevation may have been a factor.
I'll test some more tonight and let you know how it turns out.