SRGSSR / srguserdata-apple

A framework to store user data and synchronize it with an account
MIT License
1 stars 0 forks source link

Crash with preferences #4

Closed defagos closed 3 years ago

defagos commented 3 years ago

Preference synchronization might crash due to preference log entries being a mutable array which can be accessed by several threads at the same time.

The crash happens because the mutable array is changed while being enumerated.

We can mitigate this issue by replacing the array with an immutable one. This does not make the class thread-safe and the code is therefore still incorrect, but at least we won't crash.

In the future we should probably improve our implementation, e.g. by using actors (iOS 15+, though) or nicely crafted reactive pipelines (iOS 13+).

defagos commented 3 years ago

Done and merged into develop.