mbeddr/mbeddr.core

actionsfilter.runtime causes assertion "!app.isDispatchThread()"

Opened this issue · 1 comments

The action filter causes assertion:

Exception java.lang.Throwable: Assertion failed: assert !app.isDispatchThread()
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:220)

at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.<init>(ActionManagerImpl.java:135)

at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)

at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)

at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)

at com.intellij.serviceContainer.ConstructorInjectionKt.instantiateUsingPicoContainer(constructorInjection.kt:47)

at com.intellij.serviceContainer.ComponentManagerImpl.instantiateClassWithConstructorInjection(ComponentManagerImpl.kt:890)

at com.intellij.serviceContainer.ServiceComponentAdapter.createAndInitialize(ServiceComponentAdapter.kt:51)

at com.intellij.serviceContainer.ServiceComponentAdapter.doCreateInstance(ServiceComponentAdapter.kt:41)

at com.intellij.serviceContainer.BaseComponentAdapter.getInstanceUncached(BaseComponentAdapter.kt:119)

at com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:73)

at com.intellij.serviceContainer.BaseComponentAdapter.getInstance$default(BaseComponentAdapter.kt:66)

at com.intellij.serviceContainer.ComponentManagerImpl.doGetService(ComponentManagerImpl.kt:609)

at com.intellij.serviceContainer.ComponentManagerImpl.getService(ComponentManagerImpl.kt:583)

at com.intellij.openapi.client.ClientAwareComponentManager.getFromSelfOrCurrentSession(ClientAwareComponentManager.kt:37)

at com.intellij.openapi.client.ClientAwareComponentManager.getService(ClientAwareComponentManager.kt:22)

at com.intellij.openapi.actionSystem.ActionManager.getInstance(ActionManager.java:29)

at com.mbeddr.mpsutil.actionsfilter.runtime.ActionFilter$12.select(ActionFilter.java:155)

at com.mbeddr.mpsutil.actionsfilter.runtime.ActionFilter$12.select(ActionFilter.java:153)

at jetbrains.mps.internal.collections.runtime.ISelector.invoke(ISelector.java:12)

at jetbrains.mps.internal.collections.runtime.impl.SelectingSequence$SelectingIterator.moveToNext(SelectingSequence.java:60)

at jetbrains.mps.internal.collections.runtime.impl.SelectingSequence$SelectingIterator.hasNext(SelectingSequence.java:32)

at jetbrains.mps.internal.collections.runtime.impl.FilteringSequence$FilteringIterator.moveToNext(FilteringSequence.java:61)

at jetbrains.mps.internal.collections.runtime.impl.FilteringSequence$FilteringIterator.hasNext(FilteringSequence.java:34)

at jetbrains.mps.internal.collections.runtime.ListSequence.fromIterable(ListSequence.java:122)

at jetbrains.mps.internal.collections.runtime.AbstractSequence.toListSequence(AbstractSequence.java:215)

at com.mbeddr.mpsutil.actionsfilter.runtime.ActionFilter.getActions(ActionFilter.java:161)

at com.mbeddr.mpsutil.actionsfilter.runtime.ActionFilter.applyFilters(ActionFilter.java:132)

at com.mbeddr.mpsutil.actionsfilter.runtime.ActionFilter.addFilters(ActionFilter.java:92)

at com.mbeddr.mpsutil.actionsfilter.runtime.ActionFilter.setFilters(ActionFilter.java:123)

at com.mbeddr.mpsutil.actionsfilter.runtime.ActionFilter.setFilters(ActionFilter.java:127)

at com.mbeddr.mpsutil.actionsfilter.runtime.ActionsApplicationComponent.applyFilter(ActionsApplicationComponent.java:64)

at com.mbeddr.mpsutil.actionsfilter.runtime.ActionsApplicationComponent.lambda$loadState$0(ActionsApplicationComponent.java:46)

at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)

at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:789)

at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:740)

at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:734)

at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)

at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)

at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:759)

at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:918)

at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:766)

at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:450)

at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:791)

at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:449)

at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)

at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:624)

at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:447)

at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:881)

at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:493)

at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)

at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)

at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)

at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)

at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)

at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

MPS: 2022.2.1
Mbeddr: 2022.2.23923.7909945

Our customer said that ther exception appeared spontanously multiple times. Is there anything we can do to prevent the problem?

The problem is probably that in ActionFilter#getActions the class ActionManager gets initialized when this class is the first one that calls ActionManager.getInstance. The initialization is not allowed on the EDT/UI thread but the code is executed here on the EDT thread. We would probably need to move the SwingUtilities#invokeLater call to the actual location where we need to update the UI, so that the initialization happens on the right thread or we quickly move to another thread for this single line of code.