ChrisCarini/jetbrains-auto-power-saver

"Must be executed on UI thread" exception when alt+tabbing into the IDE

Closed this issue · 6 comments

Got this when alt+tabbing into Rider:

Must be executed on UI thread

java.lang.IllegalStateException: |E| Wrong thread null
	at com.jetbrains.rdclient.protocol.RdDispatcher.assertThread(RdDispatcher.kt:56)
	at com.jetbrains.rider.protocol.EarlyBackendStarter$switchingScheduler$1.assertThread(EarlyBackendStarter.kt:85)
	at com.jetbrains.rd.util.reactive.IScheduler$DefaultImpls.assertThread$default(Scheduler.kt:16)
	at com.jetbrains.rd.framework.base.RdReactiveBase.assertThreading(RdReactiveBase.kt:22)
	at com.jetbrains.rd.framework.base.RdReactiveBase.localChange$rd_framework(RdReactiveBase.kt:41)
	at com.jetbrains.rd.framework.impl.RdOptionalProperty.set(RdProperty.kt:128)
	at com.jetbrains.rider.inspections.RiderInspectionsHost$1$1.powerSaveStateChanged(RiderInspectionsHost.kt:43)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.intellij.util.messages.impl.MessageBusConnectionImpl.deliverMessage(MessageBusConnectionImpl.java:102)
	at com.intellij.util.messages.impl.MessageBusImpl.doPumpMessages(MessageBusImpl.java:446)
	at com.intellij.util.messages.impl.MessageBusImpl.pumpWaitingBuses(MessageBusImpl.java:406)
	at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:395)
	at com.intellij.util.messages.impl.MessageBusImpl.sendMessage(MessageBusImpl.java:372)
	at com.intellij.util.messages.impl.MessageBusImpl.lambda$createTopicHandler$1(MessageBusImpl.java:242)
	at com.sun.proxy.$Proxy127.powerSaveStateChanged(Unknown Source)
	at com.intellij.ide.PowerSaveMode.setEnabled(PowerSaveMode.java:24)
	at com.chriscarini.jetbrains.autopowersaver.FocusPowerSaveService$IdeFrameStatePowerSaveListener.lambda$onFrameActivated$0(FocusPowerSaveService.java:80)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at com.intellij.util.concurrency.SchedulingWrapper$MyScheduledFutureTask.run(SchedulingWrapper.java:224)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

It happened about 4 times with slight variations on the stack trace (since it seems it also happens during onFrameDeactivated of the com.chriscarini.jetbrains.autopowersaver.FocusPowerSaveService$IdeFrameStatePowerSaveListener)

JetBrains Rider 2019.2.3
Build #RD-192.7317.11, built on October 16, 2019
Runtime version: 11.0.4+10-b304.77 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1450M
Cores: 12
Registry: ide.tree.horizontal.default.autoscrolling=false, performance.watcher.sampling.interval.ms=200, ide.borderless.title.product=false, performance.watcher.unresponsive.interval.ms=1000, ide.tooltip.initialDelay.highlighter=0, search.everywhere.settings=true, parameter.info.max.visible.rows=10, ide.win.file.chooser.native=true, ide.borderless.title.project.path=false, search.everywhere.pattern.checking=false, ide.tooltip.initialDelay=0, ide.borderless.title.classpath=false, ide.require.transaction.for.model.changes=false
Non-Bundled Plugins: com.chriscarini.jetbrains.jetbrains-auto-power-saver, com.cschar.power.mode3.zeranthium, com.intellij.ideolog, com.intellij.resharper.HeapAllocationsViewer, com.notime.intellijPlugin.backgroundImagePlus, izhangzhihao.rainbow.brackets

Hi @AnomalousUnderdog - thank you for reporting this! I was not able to easily reproduce this in IntelliJ CE, was there anything special about how you were alt + tab into / out of the Rider IDE? I think I have a fix for this, but without being able to reproduce, its hard for me to know for certain.

Unfortunately, I don't recall anything special with the way I alt+tabbed. It pretty much happened immediately after I installed and started using auto-power-saver.

@AnomalousUnderdog gotcha - did it happen all the time, or just occasionally? I pushed a fix for this and published it to the JetBrains plugin repo - if you don't mind trying again once it's approved (JetBrains has to approve it before being available) and let me know your results that's be much appreciated!

Well, it only happened once, but that was because I deactivated it after it happened. I will try again with the current version I have to see if it always happens.

EDIT: Ok, it happens all the time. I can see that the moment that Solution-wide Analysis in Rider is paused, the exception occurs.