In some cases, a race condition can occur after adding a performer or tag to scene.
While, the onActivityResult is called before onResume, it is possible that the scene data fetched in onResume happens before the mutation in onActivityResult completes. And then the UI updates in onActivityResult occurs before the ones in onResume. This is possible because network calls and UI updates occurs in different coroutines. In this surprisingly common case, the scene is successfully modified, but the UI doesn't reflect the changes.
This PR fixes that race condition by optionally allowing a QueryEngine and MutationEngine to share a ReadWriteLock allowing the mutations to block queries when needed.
Since this is a concurrency issue, it requires thorough testing and extra scrutiny.
In some cases, a race condition can occur after adding a performer or tag to scene.
While, the
onActivityResult
is called beforeonResume
, it is possible that the scene data fetched inonResume
happens before the mutation inonActivityResult
completes. And then the UI updates inonActivityResult
occurs before the ones inonResume
. This is possible because network calls and UI updates occurs in different coroutines. In this surprisingly common case, the scene is successfully modified, but the UI doesn't reflect the changes.This PR fixes that race condition by optionally allowing a
QueryEngine
andMutationEngine
to share aReadWriteLock
allowing the mutations to block queries when needed.Since this is a concurrency issue, it requires thorough testing and extra scrutiny.