bug: Crash on iOS when you access the storedCalls
on threads other than the "bridge"-DispatchQueue
#5889
Labels
storedCalls
on threads other than the "bridge"-DispatchQueue
#5889
Bug Report
Capacitor Version
Platform(s)
iOS
Current Behavior
Calling
saveCall
orreleaseCall
from another queue other than the "bridge"-DispatchQueue
can cause crashes since Swift's dictionaries are not thread-safe.Expected Behavior
The expected behaviour would be no crashes. I understand that it may be required that the calls are saved or released on the "bridge"-
DispatchQueue
. But there is no possibility to do this from other threads which should be possible in my opinion since you may want to release a call after some asynchronous portion of code is done.getDispatchQueue()
is internal, so there is no way to schedule work on it other than reflection.Code Reproduction
In the JS portion you literally just do this:
And in the native part:
Other Technical Details
npm --version
output:8.5.2
node --version
output:v16.13.1
pod --version
output (iOS issues only):1.11.3
Additional Context
The crash (most of the time) is here:
This makes sense since Swift's dictionaries are not thread-safe and the 10.000 calls was causing race conditions most of the times I tried. I am suggesting to either put a lock around the
storedCalls
dictionary access or grant access to the internalDispatchQueue
so you can safely switch to the correct thread.The text was updated successfully, but these errors were encountered: