Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use caller Realm instead of Notifier Realm when calculating KeyPaths. #1594

Merged
merged 2 commits into from
Dec 8, 2023

Conversation

cmelchior
Copy link
Contributor

Fixes errors like ❌ asFlow_objectBound_withKeyPath[jvm] java.lang.IllegalStateException: [RLM_ERR_WRONG_THREAD]: Realm accessed from incorrect thread., but could happen with any KeyPath.

The problem was that we were calling a function in the notifier (from an arbitrary thread), and then using the notifier Realm (outside the notifier thread). So depending on the timing, sometimes it would return a thread-confined Realm.

I refactored the code, so we now calculate the keypath array outside the notifier using the caller Realm which should always be safe.

@cmelchior cmelchior merged commit ce3d333 into releases Dec 8, 2023
1 of 2 checks passed
@cmelchior cmelchior deleted the cm/fix-threading-with-keypaths branch December 8, 2023 10:56
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants