Skip to content

Observers broken when multiple isolates are used #142

Closed
@vaind

Description

@vaind

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions