Closed Bryan-Lamb closed 10 months ago
The same crash randomly happened to my app on Android 12 as reported by crashlytics. Hopefully this is a valid solution and the newest version will not have this issue.
Interested to hear any thoughts you may have on this @EricKuck
+1 We've observed this crash happening for a while now too
Thanks for taking a look at this one. I'm not sure this is the fix we need though. The test actually passes without any changes to the backstack. Additionally, is blocking the right way to handle this? If all changes are happening on the main thread, that could result in a deadlock.
Affected Version: Conductor 3.2.0
Context: In a typical Controller, we begin observing events from our ViewModels (using channels/flows) in the
LifecycleListener.postAttach()
callback which often result in a navigation call such aspushController()
orsetRoot()
.In particular with
setRoot()
we've been encountering an interesting crash for quite some time and after investigation narrowed down a reproducible scenario to be:setRoot()
being calledsetRoot()
while the Backstack is still being iterated over by theLifecyleHandler
There appears to be an existing issue with similar circumstances
Suggested Change Make Backstack synchronised by changing it's type from an
ArrayDeque
to aLinkedBlockingDeque
I've added a test to simulate this scenario which will fail with the previous
ArrayDeque
implementation, confirmed all tests are passing, but interested to know if there may be other unintended consequences of this change.