I am getting an IllegalStateException during the adapter notifications in the launched coroutine in the update block because I had injected the Dispatchers.main.immediate CoroutineDispatcher instead of the Dispatchers.main CoroutineDispatcher so this coroutine for layout wasn't posted back to the main thread but run synchronously leading to the exception during layout.
Now, using the immediate dispatcher may be 'user error' but we could protect against it with a yield() in update()'s launch.
I am getting an IllegalStateException during the adapter notifications in the launched coroutine in the update block because I had injected the Dispatchers.main.immediate CoroutineDispatcher instead of the Dispatchers.main CoroutineDispatcher so this coroutine for layout wasn't posted back to the main thread but run synchronously leading to the exception during layout.
Now, using the immediate dispatcher may be 'user error' but we could protect against it with a yield() in update()'s launch.