When I the data is synced, the android app crashes and following error is printed in console.
[libc] /buildbot/src/android/ndk-r25-release/toolchain/llvm-project/libcxx/../../../toolchain/llvm-project/libcxxabi/src/abort_message.cpp:72: abort_message: assertion "terminating with uncaught exception of type realm::LogicError: Binary too big
[libc] Exception backtrace:
[libc] <backtrace not supported on this platform>" failed
public async Task<Realm> GetDbInstanceAsync()
{
if (_realmApp != null && _realmApp.CurrentUser != null)
{
if (_flexibleSyncConfiguration == null)
{
_flexibleSyncConfiguration = new FlexibleSyncConfiguration(_realmApp.CurrentUser);
Realm.Compact(_flexibleSyncConfiguration);
}
Realm realm = null ;
// The async call below will only return once sync has run. If we have no internet, it won't return!
// Therefore, use the async call when we have no database file.
if (!File.Exists(_flexibleSyncConfiguration.DatabasePath))
realm = await Realm.GetInstanceAsync(_flexibleSyncConfiguration);
else
realm = Realm.GetInstance(_flexibleSyncConfiguration);
return realm;
}
return null;
}
And the part where the error is occurring is where the subscription is made:
public async Task SetupBasicSubscriptionsAsync()
{
try
{
if (_dbService == null)
{
_dbService = Ioc.Default.GetService();
}
var realm = await _dbService.GetDbInstanceAsync();//_dbService.GetDbInstance();
if (realm != null)
{
string id = _dbService.GetRealmApp().CurrentUser.Id;
//Check if subscriptions are already been subscribed or not.
var userSubscriptionName = "user_id";
var userSubscription = realm.Subscriptions.FirstOrDefault(x => x.Name == userSubscriptionName);
var shouldSubscribeForUser = userSubscription == null;
var chatsterSubscriptionName = "all_chatsters";
var chatstersSubscription = realm.Subscriptions.FirstOrDefault(x => x.Name == chatsterSubscriptionName);
var shouldSubscribeForChatsters = chatstersSubscription == null;
var conversationsSubscriptionName = "conversations";
var conversationsSubscription = realm.Subscriptions.FirstOrDefault(x => x.Name == conversationsSubscriptionName);
var shouldSubscribeForConversations = conversationsSubscription == null;
var conversationPrefSubscriptionName = "conversationsPrefs";
var conversationPrefSubscription = realm.Subscriptions.FirstOrDefault(x => x.Name == conversationPrefSubscriptionName);
var shouldSubscribeForConversationPref = conversationPrefSubscription == null;
var contactEntrySubscriptionName = "contactEntries";
var contactEntriesSubscription = realm.Subscriptions.FirstOrDefault(x => x.Name == contactEntrySubscriptionName);
var shouldSubscribeForContactEntries = contactEntriesSubscription == null;
var timelineSharedSubscriptionName = "timelinesShared";
var timelineSharedSubscription = realm.Subscriptions.FirstOrDefault(x => x.Name == timelineSharedSubscriptionName);
var shouldSubscribeForTimelineShared = timelineSharedSubscription == null;
var selfTimelineSubscriptionName = "selfTimelines";
var selfTimelineSubscription = realm.Subscriptions.FirstOrDefault(x => x.Name == selfTimelineSubscriptionName);
var shouldSubscribeForSelfTimeline = selfTimelineSubscription == null;
if (shouldSubscribeForUser || shouldSubscribeForChatsters || shouldSubscribeForConversations || shouldSubscribeForConversationPref || shouldSubscribeForContactEntries || shouldSubscribeForTimelineShared || shouldSubscribeForSelfTimeline)
{
realm.Subscriptions.Update(() =>
{
try
{
if (shouldSubscribeForUser)
{
var queryUsers = realm.All<User>().Where(o => o.Id == id);
realm.Subscriptions.Add(queryUsers, new SubscriptionOptions()
{
Name = userSubscriptionName,
UpdateExisting = true
});
}
//If I Comment out this block, app starts working
if (shouldSubscribeForChatsters)// This Subscription is causing the crash
{
var queryChatster = realm.All<Chatster>();//.Where(o => o.UserName != "");
realm.Subscriptions.Add(queryChatster, new SubscriptionOptions()
{
Name = "all_chatsters",
UpdateExisting = true
});
}
if (shouldSubscribeForConversations)
{
var queryConversation = realm.All<Conversation>().Where(o => o.AuthorID == id);
realm.Subscriptions.Add(queryConversation, new SubscriptionOptions()
{
//Name = "conversation",
Name = "conversations",
UpdateExisting = true
});
}
if (shouldSubscribeForConversationPref)
{
var queryConversation = realm.All<ConversationPreferences>().Where(o => o.AuthorID == id);
realm.Subscriptions.Add(queryConversation, new SubscriptionOptions()
{
//Name = "conversation",
Name = "conversationsPrefs",
UpdateExisting = true
});
}
if (shouldSubscribeForContactEntries)
{
var queryConversation = realm.All<ContactEntry>().Where(o => o.AuthorID == id);
realm.Subscriptions.Add(queryConversation, new SubscriptionOptions()
{
//Name = "conversation",
Name = "contactEntries",
UpdateExisting = true
});
}
if (shouldSubscribeForTimelineShared)
{
var querySharedTimeline = realm.All<TimelineShared>().Where(o => o.AuthorID == id);
realm.Subscriptions.Add(querySharedTimeline, new SubscriptionOptions()
{
Name = "timelinesShared",
UpdateExisting = true
});
}
if (shouldSubscribeForSelfTimeline)
{
var querySelfTimeline = realm.All<Timeline>().Where(o => o.AuthorID == id);
realm.Subscriptions.Add(querySelfTimeline, new SubscriptionOptions()
{
Name = "selfTimelines",
UpdateExisting = true
});
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
});
await realm.Subscriptions.WaitForSynchronizationAsync();
}
if(shouldSubscribeForUser)
NotificationsService.GetInstance().NotifySyncCompleted(objectType: ObjectType.User);
NotificationsService.GetInstance().NotifySyncCompleted(objectType: ObjectType.Chatster);
NotificationsService.GetInstance().NotifySyncCompleted(objectType: ObjectType.ConversationPrefs);
NotificationsService.GetInstance().NotifySyncCompleted(objectType: ObjectType.ContactEntry);
NotificationsService.GetInstance().NotifySyncCompleted(objectType: ObjectType.Timeline);
NotificationsService.GetInstance().NotifySyncCompleted(objectType: ObjectType.TimelineShared);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
@papafe I would also like to add that, when I changed the subscriptions method to subscribing one-by-one it started working.
So from this behavior, I guess there is a limit to how much data we can subscribe to in a single subscription?
And also,
Hoping you could tell me if there is any limit to the number of subscriptions you can have at one time?
@Ahmad_Pasha there shouldn’t be any limit to the number of subscriptions you can have.
Regarding your problem it would be really useful to see the stack trace, but unfortunately there is an issue with Android regarding producing stack traces. Would it be possible for you to try to run the project on iOS/MacOS and get the stack trace?
Sorry for the delay, it took some time for the build.
You can use package with version 10.15.1-pr-3029.526 from our night builds (instructions here).
Let me know how it goes