-
Notifications
You must be signed in to change notification settings - Fork 92
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
[Bug]: Unable to open realm on background isolate #1055
Comments
@geosebas You don't need to use a different In general |
To be a bit more precise
|
Hi @nielsenko. Thanks for the answer, but I'm not sure to understand something.
and then :
Of course I directly tried to use So the big question is, how can I access my realm from different isolate ? |
I forgot a process in there, have edited the answer. You should be able to open the realm again in another isolate in the same process, as long as you use the same config type, ie.
despite using the exact same user 🤔 I think you have hit a bug here. Will get back when I know more. |
Much clearer now :D
I got this error too !
|
@geosebas I believe this is an issue in realm-core caused by a comparison of Unlike most SDK we don't use native caching of app instances in realm-dart. This is because they cause trouble when used between different isolates (you may remember the hot-restart crash of 0.3.2+beta). I think that is what causes the current check to be defeated. The PR fixes it for me, in my test, and passes all existing tests in realm-dart, but let us see how it fares in core. |
Nice I will wait for the fix :) Thanks for your help and the quick answer ! |
Hi @nielsenko , Sorry to bother you but do you have any news about this ? On another point, do you know how the SDK handle the call to the manual reset handler when the realm is opened in more than one isolate ? What will happen if more than one Have a nice day :) |
I got a bit side-tracked, I will return to this now. |
Sorry I pressed 'enter' to soon so I edited my previous message ^^ |
I expect the fix to be included in the next release, but no promises. The second call to |
I have opened a PR realm/realm-core#6117 to surface the result. Once that land I will change |
Nice thanks a lot :) |
Hello there, just wanted to know if you have an idea about when will we have the next release and if this fix will be in the next release. Sorry to bother you just for that, but I will release soon to production my app, and I don't like the dirty workarround I did for this, so if I can have the fix before going in production, it will be perfect for me :) And not to bother you again with this type of question, do you have any channels where we can have theses type of info ? Like a discord or slack where we will know when you release, or if you're hold back or anything ? That would be great ! |
@geosebas This is dependent on a new release of realm-core. We have been hesitant to roll a release, since there was a number of issues with the latest realm-core version (13+), after a major refactoring of how frozen objects affects version pinning. These are slowly and steadily being worked through. I cannot give dates, but we are getting close. |
import 'dart:async';
import 'dart:isolate';
import 'package:realm_dart/realm.dart';
part 'isolate_test.g.dart';
@RealmModel()
class _Stuff {
late int no;
@override
String toString() => 'Stuff($no)';
}
// Note this is per isolate!
final realm = Realm(Configuration.inMemory([Stuff.schema]));
StreamSubscription monitorChanges(String isolateTag) {
return realm.all<Stuff>().changes.listen((event) {
print('$isolateTag: ${event.inserted}');
});
}
extension on StreamSubscription {
Future<void> cancelIn(int seconds) async {
await Future.delayed(Duration(seconds: seconds));
await cancel();
}
}
Future<void> main(List<String> arguments) async {
final s = monitorChanges('root');
await Isolate.spawn((message) async {
final s = monitorChanges('spawned');
realm.write(() => realm.addAll([
Stuff(1),
Stuff(2),
]));
await s.cancelIn(1);
}, null);
await s.cancelIn(1);
for (final stuff in realm.all<Stuff>()) {
print(stuff);
}
Realm.shutdown();
} Outputs:
|
What happened?
Hello,
I'm trying to follow the doc from here : https://www.mongodb.com/docs/realm/sdk/flutter/sync/sync-multiple-processes/
But as soon as I open the disconnected realm, I got this error :
My goal is to create complex data from multiple collection, so I need to do this in another Isolate so I don't freeze the UI.
To do that I use the
compute
function from flutter foundation.Here some of my code :
Synced realm :
DisconnectedRealm :
Flutter doctor :
Repro steps
Version
0.8.0rc
What Realm SDK flavor are you using?
MongoDB Atlas (i.e. Sync, auth, functions)
What type of application is this?
Flutter Application
Client OS and version
Android 33.0
Code snippets
No response
Stacktrace of the exception/crash you're getting
Relevant log output
No response
The text was updated successfully, but these errors were encountered: