NetLogo / LevelSpace

This is the LevelSpace extension repository. LevelSpace allows you to run NetLogo models |: from inside NetLogo models :|
Other
19 stars 8 forks source link

Implement our own InterfaceComponent #66

Closed qiemem closed 8 years ago

qiemem commented 8 years ago

Right now InterfaceComponent and friends does a bunch of crap that:

  1. We don't need.
  2. Causes memory leaks

In particular, this includes things like creating a new RuntimeErrorDialogue that is not disposed of properly, as well as attaching themselves to Exceptions.handler (which keeps a reference to the last loaded model).

There are many additional benefits. We could strip all the loading stuff we don't need, speeding up load times for gui models (enough to get rid of headless? perhaps). We might actually be able to get agent inspection to work.

There's a couple ways to do this:

  1. Move LiteWorkspace, AppletPanel, and InterfaceComponent from core to LevelSpace. This stuff should be removed from core anyway. Then we can do whatever we want with them.
  2. Just write our own based on those guys. They should still be removed from core though.
qiemem commented 8 years ago

wip-custom-ws branch holds the progress for this. faa4029 creates the custom InterfaceComponent and Workspace. Uncertain things:

qiemem commented 8 years ago

Currently, this occurs when I try to load Wolf Sheep or Sanpdile, but not simpler models:

java.lang.NullPointerException
 at org.nlogo.ls.gui.AwtScalable$ScalableComponent.scalableAttributes(ZoomableInterfaceComponent.scala:127)
 at org.nlogo.ls.gui.ZoomableContainer$class.org$nlogo$ls$gui$ZoomableContainer$$registerScalableAttributes(ZoomableInterfaceComponent.scala:52)
 at org.nlogo.ls.gui.ZoomableContainer$$anonfun$registerZoomableComponent$1.apply(ZoomableInterfaceComponent.scala:45)
 at org.nlogo.ls.gui.ZoomableContainer$$anonfun$registerZoomableComponent$1.apply(ZoomableInterfaceComponent.scala:45)
 at org.nlogo.ls.gui.ZoomableContainer$class.org$nlogo$ls$gui$ZoomableContainer$$recursively(ZoomableInterfaceComponent.scala:85)
 at org.nlogo.ls.gui.ZoomableContainer$class.registerZoomableComponent(ZoomableInterfaceComponent.scala:45)
 at org.nlogo.ls.gui.ZoomableInterfacePanel.registerZoomableComponent(ZoomableInterfaceComponent.scala:154)
 at org.nlogo.ls.gui.ZoomableInterfacePanel.loadWidget(ZoomableInterfaceComponent.scala:174)
 at org.nlogo.window.InterfacePanelLite$$anonfun$handle$1.apply(InterfacePanelLite.scala:266)
 at org.nlogo.window.InterfacePanelLite$$anonfun$handle$1.apply(InterfacePanelLite.scala:266)
 at scala.collection.immutable.List.foreach(List.scala:381)
 at org.nlogo.window.InterfacePanelLite.handle(InterfacePanelLite.scala:266)
 at org.nlogo.window.Events$LoadWidgetsEvent.beHandledBy(Events.java:502)
 at org.nlogo.window.Event.doRaise(Event.java:198)
 at org.nlogo.window.Event.raise(Event.java:122)
 at org.nlogo.window.ReconfigureWorkspaceUI$Loader$$anonfun$loadHelper$1.apply(ReconfigureWorkspaceUI.scala:37)
 at org.nlogo.window.ReconfigureWorkspaceUI$Loader$$anonfun$loadHelper$1.apply(ReconfigureWorkspaceUI.scala:37)
 at scala.collection.immutable.List.foreach(List.scala:381)
 at org.nlogo.window.ReconfigureWorkspaceUI$Loader.loadHelper(ReconfigureWorkspaceUI.scala:37)
 at org.nlogo.window.ReconfigureWorkspaceUI$.apply(ReconfigureWorkspaceUI.scala:19)
 at org.nlogo.ls.gui.InterfaceComponent$$anonfun$open$1.apply(InterfaceComponent.scala:88)
 at org.nlogo.ls.gui.InterfaceComponent$$anonfun$open$1.apply(InterfaceComponent.scala:88)
 at scala.Option.foreach(Option.scala:257)
 at org.nlogo.ls.gui.InterfaceComponent.open(InterfaceComponent.scala:88)
 at org.nlogo.ls.GUIChildModel$RunGUIChildModel$.run(GUIChildModel.scala:53)
 at org.nlogo.ls.GUIChildModel$RunGUIChildModel$.run(GUIChildModel.scala:25)
 at org.nlogo.window.ThreadUtils$$anon$2.run(ThreadUtils.scala:49)
 at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
 at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
 at java.awt.EventQueue.access$500(EventQueue.java:97)
 at java.awt.EventQueue$3.run(EventQueue.java:709)
 at java.awt.EventQueue$3.run(EventQueue.java:703)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
 at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
 at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
 at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
 at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
 at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
qiemem commented 8 years ago

Oh, this problem existed beforehand. It looks like it stems from the new file loading stuff.

qiemem commented 8 years ago

It results from trying to load a file that contains a switch. Sliders and inputs appear to be fine, so it's not anything that declares a global.

qiemem commented 8 years ago

NetLogo/NetLogo#1068 solves the stack trace.

Currently, it's using App.app's monitorManager. The upshot of this is that it runs code in the root model, which is obviously a big problem. Actually, it just get super weird in general...

Creating our own just worked!

Uri's asked for the 3d view to work. I'm going to try just creating a new GLViewManagerInterface, but I kind of doubt that will work after talking to Robert.

Again, creating our own just worked!

Currently, I'm working on delaying packing and showing the frame until requested, as it drastically speeds up load times.

qiemem commented 8 years ago

Currently, I'm working on delaying packing and showing the frame until requested, as it drastically speeds up load times.

I've decided to give up on this for now. There's a huge drop in performance when you hit ~500 GUI models, and it appears to result from creating any AWT components on model load. Thus, for now, we're going to maintain the separation of GUI and headless models.

qiemem commented 8 years ago

Fixed by faa40290ad312a848b12df494b6d30ecc3c3ecb3