You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The plugins solutions that register mouse listeners register too many listeners.
This happens when I open multiple projects in MPS.
I used MPS 2024.1 and the current branch maintenance/mps20241.
I get these messages after adding some trace logs, opened 3 projects, opened a single editor and clicked a few times.
Notice how each project contributes a listener to the same editor component.
Installing DelegatingMouseListener de.itemis.mps.mouselistener.runtime.plugin.MouseListenerPlugin_ProjectPluginPart@2433481d to component jetbrains.mps.nodeEditor.NodeEditorComponent[,0,0,0x0,invalid,layout=jetbrains.mps.nodeEditor.EditorComponentLayoutManager,alignmentX=0.0,alignmentY=0.0,border=ViewBorder{myInsets=com.intellij.util.ui.JBInsets[top=0,left=0,bottom=0,right=0], myBorder=null},flags=321,maximumSize=,minimumSize=,preferredSize=]
Installing DelegatingMouseListener de.itemis.mps.mouselistener.runtime.plugin.MouseListenerPlugin_ProjectPluginPart@4bf576cf to component jetbrains.mps.nodeEditor.NodeEditorComponent[,0,0,0x0,invalid,layout=jetbrains.mps.nodeEditor.EditorComponentLayoutManager,alignmentX=0.0,alignmentY=0.0,border=ViewBorder{myInsets=com.intellij.util.ui.JBInsets[top=0,left=0,bottom=0,right=0], myBorder=null},flags=321,maximumSize=,minimumSize=,preferredSize=]
Installing DelegatingMouseListener de.itemis.mps.mouselistener.runtime.plugin.MouseListenerPlugin_ProjectPluginPart@2a80f8de to component jetbrains.mps.nodeEditor.NodeEditorComponent[,0,0,0x0,invalid,layout=jetbrains.mps.nodeEditor.EditorComponentLayoutManager,alignmentX=0.0,alignmentY=0.0,border=ViewBorder{myInsets=com.intellij.util.ui.JBInsets[top=0,left=0,bottom=0,right=0], myBorder=null},flags=321,maximumSize=,minimumSize=,preferredSize=]
Installing DelegatingMouseListener de.itemis.mps.mouselistener.runtime.plugin.MouseListenerPlugin_ProjectPluginPart@2433481d to component jetbrains.mps.nodeEditor.NodeEditorComponent[,0,0,0x0,invalid,layout=jetbrains.mps.nodeEditor.EditorComponentLayoutManager,alignmentX=0.0,alignmentY=0.0,border=ViewBorder{myInsets=com.intellij.util.ui.JBInsets[top=0,left=0,bottom=0,right=0], myBorder=null},flags=321,maximumSize=,minimumSize=,preferredSize=]
Installing DelegatingMouseListener de.itemis.mps.mouselistener.runtime.plugin.MouseListenerPlugin_ProjectPluginPart@4bf576cf to component jetbrains.mps.nodeEditor.NodeEditorComponent[,0,0,0x0,invalid,layout=jetbrains.mps.nodeEditor.EditorComponentLayoutManager,alignmentX=0.0,alignmentY=0.0,border=ViewBorder{myInsets=com.intellij.util.ui.JBInsets[top=0,left=0,bottom=0,right=0], myBorder=null},flags=321,maximumSize=,minimumSize=,preferredSize=]
Installing DelegatingMouseListener de.itemis.mps.mouselistener.runtime.plugin.MouseListenerPlugin_ProjectPluginPart@2a80f8de to component jetbrains.mps.nodeEditor.NodeEditorComponent[,0,0,0x0,invalid,layout=jetbrains.mps.nodeEditor.EditorComponentLayoutManager,alignmentX=0.0,alignmentY=0.0,border=ViewBorder{myInsets=com.intellij.util.ui.JBInsets[top=0,left=0,bottom=0,right=0], myBorder=null},flags=321,maximumSize=,minimumSize=,preferredSize=]
Click event at 86 182
Click event at 86 182
Click event at 86 182
Click event at 513 13
Click event at 513 13
Click event at 513 13
Click event at 216 351
Click event at 216 351
Click event at 216 351
Click event at 211 325
Click event at 211 325
Click event at 211 325
Click event at 210 307
Click event at 210 307
Click event at 210 307
This is from de.itemis.mps.mouselistener.runtime, but I can reproduce the same issue with de.itemis.mps.selection.runtime.
The reason is that these are project plugins and instantiated per project, so there exist multiple instances of e.g. de.itemis.mps.mouselistener.runtime.plugin.MouseListenerPlugin which all register on every editor component. Perhaps these should check each editor component if it belongs to their project before registering.
Also, as a second bug, when I close one of the projects, all mouse listeners stop working in the others. This is because in the (project-specific) dispose(), there is a call DelegatingMouseListener.uninstallAll(); resp. DragSelectionMouseListener.uninstallAll();
Changing this to application plugins solved the issue for me locally, they are also normally reloaded like project plugins when I rebuild the plugin in MPS.
Maybe there are other reasons I don't know why these are project plugins? But if we want to refactor this, I can create a pull request with my changes.
The text was updated successfully, but these errors were encountered:
I have to revisit my previous comment: When having multiple projects open and closing one, it is not the case that the mouse listener stops working completely. However, it looks like this works only "by chance".
One shared DelegatingMouseListener is used for the same EditorComponent by all project instances of the plugin. This leads to the same mouse listener object being registered multiple times.
On the other hand, when uninstalling, the current implementation of DelegatingMouseListener will always remove itself only once from the list of mouse listeners because it then removes itself from its cache before the second, third etc. project unregisters it.
This means that the mouse listeners are additionally "leaking", and without the line instances.removeKey(getEditorComponent()); I can indeed produce the problem that closing one project destroys the mouse listeners in all the other projects.
After having tested this a bit further, I believe that this is not by design and relies on the specific JDK implementation of addMouseListener/removeMouseListener. I will try to convert this to an application plugin so that the mouse listener mechanics is cleaned up.
The plugins solutions that register mouse listeners register too many listeners.
This happens when I open multiple projects in MPS.
I used MPS 2024.1 and the current branch
maintenance/mps20241
.I get these messages after adding some trace logs, opened 3 projects, opened a single editor and clicked a few times.
Notice how each project contributes a listener to the same editor component.
This is from de.itemis.mps.mouselistener.runtime, but I can reproduce the same issue with de.itemis.mps.selection.runtime.
The reason is that these are project plugins and instantiated per project, so there exist multiple instances of e.g.
de.itemis.mps.mouselistener.runtime.plugin.MouseListenerPlugin
which all register on every editor component. Perhaps these should check each editor component if it belongs to their project before registering.Or, even cleaner, they should just be ApplicationPluginDeclaration instead of ProjectPluginDeclaration, and so are instantiated only once.
Also, as a second bug, when I close one of the projects, all mouse listeners stop working in the others. This is because in the (project-specific) dispose(), there is a call
DelegatingMouseListener.uninstallAll();
resp.DragSelectionMouseListener.uninstallAll();
Changing this to application plugins solved the issue for me locally, they are also normally reloaded like project plugins when I rebuild the plugin in MPS.
Maybe there are other reasons I don't know why these are project plugins? But if we want to refactor this, I can create a pull request with my changes.
The text was updated successfully, but these errors were encountered: