Comments (7)
If I comment "query.cars.appendContentsOf(carsObjects)" then everything seems to be ok with tableView updates/inserts/delete.
If I leave it uncommented then as I can conclude some additional notifications are sent to the RealmResultsController and it tries to delete and reload at the same index path or something like that.
But now I also encountered 'attempt to delete row 0 from section 0, but there are only 0 sections before the update'. Which makes no sense as at that point the db has 0 rows because it's the first app launch. If I preload the db with at least 1 record, then this error also does not occur.
And that becomes spooky. Maybe the models inside the results controller are not updated yet(background thread) when it responds the number of rows to the tableView and in the same time tries to already do some updates on the tableView. I really can't find any real clue about what's happening behind.
After more debugging:
This 'attempt to delete row 0 from section 0, but there are..' occurs because for some reasons it inserts that row, then inserts another, then updates that first row and then ends tableView updates.
And the tableView complains that it is illegal to insert and then "delete". In this case I suppose that update for the table view means = delete + insert. Thus the delete from the tableView point of view is illegal as at that point of time there were no objects yet, so you cannot delete it.
Supposal : the ResultsTableViewController should not insert and update the same row in the same begin/end updates session especially if it is about the initial state when there were no objects before that begin update.
from realmresultscontroller.
Tried to listen to Realm Notifications and I this is what I've got in the notifications
NSConcreteNotification 0x15df0ee0 {name = CarObject-/cars/renault-megane-coupe}
Unfortunately it does not show what operation was made on object, in order to debug the ResultsController behaviour.
from realmresultscontroller.
Hi @Carpemeid ,
I am going to dive into this issue right now, has happened a few times in our app also.
Thanks for the detailed information.
I'll keep you up to date
from realmresultscontroller.
Hi @Carpemeid,
This issue has (theoretically) been solved, and will be included in the 0.4.1
version.
I want to comment that this issue is not completely related with RRC, is a bad usage of it.
The source of the problem occurs when you try to do different actions to the same object inside a write transaction. Such as:
realm.write {
let object = // retrieve object with primaryKeyValue = 123
let anotherObject = ObjectSubclass()
anotherObject.primaryKeyValue = 123
realm.deleteNotified(object)
realm.addNotified(object)
}
What #67 is going to do, is to prevent a crash on the endUpdates, by handling these problem. But this is not going to ensure that the data is as expected. There is a restriction applied, the stablished order of importance is DELETE>UPDATE>ADD. So, if you add and remove the same object, it is going to be treated as a deletion.
Appart from that, we added a Log telling what has happened. If you want to take have more information about what is the duplicate, just set a symbolic breakpoint RealmResultsController.warnDuplicated
Also, you were complaining about because subscribing to notifications was sending the object. Now it is sending a RealmChange
object that has all you need.
That said, feel free to reopen the issue if you that happens to you when we release 0.4.1
from realmresultscontroller.
But the only thing I was doing in the realm transactions was adding with update (theoretically inside the transaction I have only that operation.. of course somewhere in the back Realm may delete/add/update in order to make the update work as expected).
And I cannot avoid using [add with update] because I cannot know if my db will contain the objects that are going to be "updated" unless I do an additional reading transaction and compare all that stuff manually. But doing an additional reading for that does not seam a good solution.
from realmresultscontroller.
@Carpemeid I understand, don't get me wrong. It is not that I am saying that doing this is wrong. My message was not in that direction, sorry about it.
My point was, the way we defined the usage of the RRC, was this one, and that was what we expected the users to use it. There's another thing here, we did not completely think about this scenario. We talked about this, and agreed that we are going to implement, in the future, a timeline based behaviour. That is, the last thing you do, is the one that is going to prevail.
from realmresultscontroller.
Yep, of course. I understood) just wanted to make sure I got your point.
from realmresultscontroller.
Related Issues (20)
- When asking for the RRC sections, getting RealmSections without objects HOT 6
- Remove TEST init HOT 1
- Filter info in README HOT 1
- Detecting changes introduced in an object saved through a relationship of another object HOT 3
- Defend against empty string in SortDescriptor?
- Create method to do manual changes notifications in Realm objects HOT 1
- .
- Swift 2.0 support? HOT 3
- Move RealmNotification inside RealmLogger
- Method to remove filter
- feature request: find indexPath of an object in the results
- Calling delegate methods in other queue delays rendering UITableView HOT 2
- When using addNotified() I am getting a 'Object must be from the Realm being queried' error HOT 2
- Cannot pass RealmRequest to RealmResultController HOT 5
- RealmResultsController causes SegFault #11 in Xcode 7.3.1 HOT 4
- Support for Realm 1.0? HOT 8
- Sections Not Updating Correctly HOT 2
- Library incompatible with Swift 3? HOT 1
- have you considered extending this to all RealmCollection types?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from realmresultscontroller.