Skip to content

IllegalStateException: Cannot invoke setValue on a background thread

Crashed when sending a message to a new contact.

Stacktrace:

java.lang.IllegalStateException: Cannot invoke setValue on a background thread
      at android.arch.lifecycle.LiveData.assertMainThread(LiveData.java:435)
      at android.arch.lifecycle.LiveData.setValue(LiveData.java:279)
      at android.arch.lifecycle.MutableLiveData.setValue(MutableLiveData.java:33)
      at org.briarproject.briar.android.attachment.AttachmentCreator.resetState(AttachmentCreator.java:183)
      at org.briarproject.briar.android.attachment.AttachmentCreator.onAttachmentsSent(AttachmentCreator.java:164)
      at org.briarproject.briar.android.conversation.ConversationViewModel.storeMessage(ConversationViewModel.java:295)
      at org.briarproject.briar.android.conversation.ConversationViewModel.lambda$createMessage$8$ConversationViewModel(ConversationViewModel.java:286)
      at org.briarproject.briar.android.conversation.-$$Lambda$ConversationViewModel$1LsoWDT2XwB7wPxBWawY1IIRFR0.run(Unknown Source:10)
      at org.briarproject.bramble.TimeLoggingExecutor.lambda$execute$0$TimeLoggingExecutor(TimeLoggingExecutor.java:36)
      at org.briarproject.bramble.-$$Lambda$TimeLoggingExecutor$Bqrtbsq_8LcRPoTWBOef6xh7gJg.run(Unknown Source:6)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
      at java.lang.Thread.run(Thread.java:784)

This is my fault - I recommended moving the onAttachmentsSent() call to a place that's on the UI thread on my branch, forgetting that it's on the crypto executor on master.