Skip to content

Observers broken when multiple isolates are used #142

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

Closed
vaind opened this issue Nov 6, 2020 · 3 comments
Closed

Observers broken when multiple isolates are used #142

vaind opened this issue Nov 6, 2020 · 3 comments
Labels
bug Something isn't working
Milestone

Comments

@vaind
Copy link
Contributor

vaind commented Nov 6, 2020

Current observer implementation (used by query streams) is broken if the data is created by more than one isolate. In that case, the observer callback from the native side is executed in a "wrong" isolate, crashing the program.

Test-case to reproduce: https://github.com/objectbox/objectbox-dart/blob/async-and-isolates/test/isolates_test.dart#L85
error: Cannot invoke callback on incorrect isolate.

This is really an issue affecting any async callbacks from the native side, I'll create a followup to address it in a generic way.

In case the Store is only used from a single isolate, it should work fine AFAICT because the callback is issued from the same isolate. However, with the introduction of SyncClient, the observer may be called asynchronously even though lib user only uses a single isolate so this must be addressed.

@vaind
Copy link
Contributor Author

vaind commented Nov 7, 2020

Related to observers but not the same issue: resource management seems a little hard to do with Query.findStream() - the query itself must be closed at some point to avoid memory leak. e.g. stream_test.dart don't follow this...

@vaind
Copy link
Contributor Author

vaind commented Nov 26, 2020

Works fine (at least the isolates test that previously failed does) in #145

@vaind vaind added this to the 1.0 milestone Jan 21, 2021
@vaind
Copy link
Contributor Author

vaind commented Feb 25, 2021

Resolved by #145

@vaind vaind closed this as completed Feb 25, 2021
greenrobot-team added a commit that referenced this issue Apr 15, 2025
Also fix test that is asserting query parameters. This also nicely
verifies that passing the name works.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant