Xad Kile

09/21/2022, 3:16 PM
I read a State<T> in a Deffered created in Dispatchers.Default and got this exception. Does this mean it is unsafe to read/write State and MutableState in threads other than the main thread? Or am I missing something here? Thanks
Copy code
java.lang.IllegalStateException: Method should be called from AWT event dispatch thread
	at org.jetbrains.skiko.SkiaLayer.needRedraw(SkiaLayer.awt.kt:427)

Kirill Grouchnikov

09/21/2022, 6:46 PM
This is very short on detail. You’ll need to provide the full stack trace, and also ideally a small reproducer for this. In Swing / AWT (which is the windowing API behind Compose on Desktop) there are rules on what kinds of operations are not permitted off the EDT - event dispatch thread. So depending on what you do in that dispatcher, you might be changing the UI state off the EDT - which is where it gets to that check and exception.

Xad Kile

09/22/2022, 2:18 AM
@Kirill Grouchnikov Thank you for you response. It seems I am on my own for this one because the only place I can trigger this exception is is a specific part in my production code, which I can't not disclose 😞 .Basically, I was trying to mutate the state inside a rpc call (using grpc). Maybe grpc and its thread has something to do with this.


09/22/2022, 10:47 AM
Generally using
from concurrently is totally safe, it seems here you also do something else.

Xad Kile

09/23/2022, 11:27 AM
@mcpiroman yes, I was doing something weird in the code, just fixed it 🤕