realm.commitTransation takes extremely long up to ANR after migrating from 3.0.0
See original GitHub issueWith updating realm plugin from 3.0.0 to current my writing to database performance degrades very badly from couple of seconds with hundreds of items to ANRs when given table has 4000 rows.
From my examining I found that any subsequent commiting a editing transation to realm hangs up, but queries are fine, also inserts are fine. Also, if I insert to different table, it works, so only that one with larger amount of data has this problem. However it doesnt seem to be a deadlocking type of situation, as where I wait for a minute and dont close the app on anr dialog, the operation actually completes eventually.
Use case of my app is that upon pull to refresh it add new rows to given Ads table. I am adding them via 1 transation, so this hopefully is not the issue
public ArrayList<Long> addAdsToFilter(Filter filter, LinkedHashMap<String, Ad> remoteAds) {
ArrayList<Long> newAdIds = new ArrayList<>();
mRealm.executeTransaction(realm -> {
AtomicLong idCounter = RealmUtils.getIdCounter(realm, Ad.class);
for (String key : remoteAds.keySet()) {
Ad ad = remoteAds.get(key);
long id = idCounter.incrementAndGet();
ad.setId(id);
ad.setFilter(filter);
filter.addAd(ad);
newAdIds.add(id);
}
});
return newAdIds;
}
However the weird thing about simulating this bug is that it only shows its self after 2nd pull to refresh inserts. Before that even with 4000 items transations commit fine.
So the simulation is: 1 pull to refresh; editing any object - OK, 2. pull to refresh, now edit any object from that table and operation hangs up . (… however only updates seem to be problem, inserts work, so if I dont edit any object after 2nd refresh, I can insert data with 3rd refresh no problem)
Thank you for your help, let me know if you need me to provide you with more info
Realm version(s): 3.3.2 Realm sync feature enabled: no Android Studio version: 2.3.2 Which Android version and device: any
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (8 by maintainers)
Sorry I am currently busy, I will get back to you asap
If you still have this issue and can reproduce in a sample project, feel free to re-open @ursusursus.
Closing for now